Code Contracts like a charm!
sergeyteplyakov / codecontracts.analyzer Goto Github PK
View Code? Open in Web Editor NEWRoslyn-based plug-in that simplify using Code Contract library
License: MIT License
Roslyn-based plug-in that simplify using Code Contract library
License: MIT License
I.e. for public Task<string> Foo()
refactoring should generate Contract.Ensures(Contract.Result<string> != null)
, but not Contract.Ensures(Contract.Result<Task<string>>() != null
.
Add Not-null requires/Add not-null ensures context actions should not be available on nullables.
For instance:
if method has return null
, if (arg != null)
, var foo = arg?.boo
etc.
Property postcondition and statement in ObjectInvariant method are equivalent.
The only difference that in some cases postconditions are hard to use, especially with C# 6.0 features like read-only auto-properties and properties with an expression body.
Refactoring that converts from one implementation to another would be very useful.
Example:
public DateTime TimeStamp? { get; } = DateTime.UtcNow;
public DateTime AnotherTimeStamp => DateTime.Utc.Now;
Preconditions are for public methods only! in private methods Contract.Assert
/Contract.Assume
methods should be used.
Benefits: performance benefits by disabling Assert
/Assume
but leaving Requires
.
Fix can warn on this and provide a fix to convert to Contract.Assert
/Contract.Assume
.
Following code will lead to warning:
class Foo
{
public readonly int N = 42;
public Foo()
{
// error CC1011: This/Me cannot be used in Requires of a constructor
Contract.Requires(N == 42);
}
}
Move the core logic out of the existing projects.
Reason: ability to use this logic in the different contexts.
Tool can't warn (because of potential nullable types), but can emit an information tip to add Requires
/Ensures
for public methods (for public/internal types?).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.