Releases: SergeyTeplyakov/ReSharperContractExtensions
Support for R# 10
This version is availabe at the gallery: https://resharper-plugins.jetbrains.com/packages/ReSharper.ContractExtensions/
What's new?
- R# 10.0 support
R# 9.2 support
This version is availabe at the gallery: https://resharper-plugins.jetbrains.com/packages/ReSharper.ContractExtensions/0.9.2.5
What's new?
- R# 9.2 support
- Minor bug fixes
- Support for
nameof
operator
Many thanks to @Diagonactic for help with R# 9.2 migration!
Indexers and suspicios preconditions
Where can I get it?
https://resharper-plugins.jetbrains.com/packages/ReSharper.ContractExtensions/0.9.0
What's new in 0.9.0
Indexers support
Now the tool supports preconditions and postconditions for indexers! (Thanks for @StevenLiekens for the suggestions)
Warnings for using preconditions in the async methods
Preconditions of any for should be avoided in the async method. The users would expect asynchronous error when the precondition fails. But with async method exception would never be thrown to the caller. The resulting task would be faulted instead.
This means that instead of using following code:
public async Task MethodAsync(string s)
{
// Contract failure will not be raised to the caller!
Contract.Requires(s != null); // the tool will worn now!
await Task.Delay(42);
}
Following code should be used:
public /*async*/ Task MethodAsync(string s)
{
// Now the precondition is "synchronous" and would be thrown back to the caller!
Contract.Requires(s != null);
return DoMethodAsync(s);
}
private async Task DoMethodAsync(string s)
{
await Task.Delay(42);
}
The same issue would be for any form of preconditions: using Contract.Requires
, if-throw
etc.
Warnings for using preconditions in the methods with iterator blocks
Iterator blocks (yield return
) are implemented in the same way as async
method. This means that those features share the same issues.
Argument validation in the iterator blocks are not synchronous: the code would be executed only on the first MoveNext()
method of the iteartor:
Basic support for CC errors and warnings
You may find new version at: https://resharper-plugins.jetbrains.com/packages/ReSharper.ContractExtensions/0.8.0
Support for Code Contract Compiler warnings and errors inside the editor
- Inconsistent preconditions visibility
- 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).
- Postcondition checks
- Error for inconsistent method return type with Contract.Result (#34)
- 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
Enum support and Contract conversions
New features
- 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 (#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.
Binaries at R# Gallery
https://resharper-plugins.jetbrains.com/packages/ReSharper.ContractExtensions/0.7.51
Demo
Convert null-check preconditions from if-throw to Contract.Requires
Convert range check from if-throw to Contract.Requires
Add precondition check for enum argument
Add postcondition check for enum argument
Method Combo Requires
New features
- 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<ArgumentNullException> by default
- Check string arguments with Contract.Requires(!string.IsNullOrEmpty(arg)) by default for string arguments
Binaries at R# Gallery
https://resharper-plugins.jetbrains.com/packages/ReSharper.ContractExtensions/0.7.0
Demo
Add preconditions for all arguments
Check string arguments with string.IsNullOrEmpty
(Note, this feature should be turned on at plug-in settings page, available at R# Options)
0.6
New features
- 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.
This release available at R# Gallery: https://resharper-plugins.jetbrains.com/packages/ReSharper.ContractExtensions/