Code Contract editing extensions

Compatible with ReSharper
Jan 24, 2016
9 146
Simplifies adding preconditions, postconditions and object invariant during day-to-day activities.
Detects Code Contract error/warnings in the IDE.

Download plugin

Recent change notes

*What's new in 0.10.0.1*
Support for R# 10

*What's new in 0.9.2.4*
Updated to API for ReSharper 9.2
Minor bug fixes.
Support for nameof(s) in requires

*What's new in 0.9.0.2*
Fixed false positive warnings on Code Contract preconditions in the async methods and iterator blocks (#48)
Added quick fix for "suspicious legacy precondition" in async methods and iterator blocks.

*What's new in 0.9.0.1*
Fixed an issue that if-throw preconditions were checked via Code Contract Statements rules. (#47)

*What's new in 0.9.0*
1. Indexer Support (#46)
- Context actions for adding preconditions and postconditions for indexers
2. Warning for preconditions in async methods (#39)
3. Warning for preconditions in methods with iterator block (#37)
4. Warning for using events in preconditions (#18)

Bug fixes
1. #42 - warning for incompatible return types in properties.

*What's new in 0.8.0*
Support for Code Contract Compiler warnings and errors inside the editor.

1. Inconsistent preconditions visibility
- Warn on Contract.Requires() when CustomException does not have ctor(string) or ctor(string, string) (#4).
- Warn on Contfact.Requires() when CustomException is less visible then the enclosing method (#3).
- Error when Contract.Requires less visible members in the predicate than the enclosing method.

2. Errors for malformed method contracts
- Error for Requires/Ensures after EndContractBlock (#21)
- Error for Requires/Ensures in the middle of the method (#26, #22)
- Error when Ensures placed before Requires (#29, #9)
- Error for calling void-return method in the contract block (#5)
- Warning for calling non-void return method in the contract block (#25)
- Error on method calls as a source of contract error message (Contract.Requires(false, GetMessage())
- Error on non-static internal strings used as a source of contract error message (#2)
- Error on assignments in the contract block (#9)
- Error on Assert/Assume calls in the contract block (#6)
- Error on using Requires/Ensures in the try block (#10)
- Warning on redundant EndContractBlock (for instance used after Contract.Requires/Ensures).

3. Postcondition checks
- Error for inconsistent method return type with Contract.Result (#34)

4. Other features
- Generated contract classes would be marked with ExlucdeFromCodeCoverageAttribute if this option is enabled in the plug-in options page. (#31)
- Warn on redundant Contract.Requires on nullable arguments

Bug fixes
- Generate call to base-class constructor if needed for newly generated contract class (#33)
- Added support for contract classes for generic interfaces and abstract classes (#16)

Bug fixes (v.0.7.51)
- Minor fix: enabled generic version for enum check requires.

New features (v.0.7.5)
- Added combo action that convert if-throw precondition check to Contract.Requires (both - gneric and non-generic versions);
- Added combo action that convert between generic and non-generic Contract.Requires

Requires: Requires for enum (https://github.com/SergeyTeplyakov/ReSharperContractExtensions/issues/1)
- Added combo action that adds precondition check for enums and nullable enums with Contract.Requires(Enum.IsDefined(typeof(SomeEnumType), someEnumValue));
- Added combo action that adds postcondition check that enum and nullable enum result is defined by Enum.IsDefiined method.

New features (v.0.7.0)
- Added combo actions that will add Contract.Requires for all method arguments
- Added Plug-in Settings (available at R# Options page):
* Use generic Contract.Requires by default
* Check string arguments with Contract.Requires(!string.IsNullOrEmpty(arg)) by default for string arguments

New features (v.0.6.0)
- Added support for preconditions for property setters
- Addes support for preconditions for property setters for abstract class and interfaces (Combo Requries)
Bug fixes
- Fixed issue with invalid order of Contract.Invariant statements in the object invariant method.