Parameter Asserts Follow
Hi all
Parameter Asserts
Purpose:
This plugin highlights method parameters that are not asserted for null and provides context actions for generating assert statements.
Example:
Wrong:
void Foo(object parameter) {
}
Right:
void Foo(object parameter) {
System.Diagnostics.Debug.Assert(parameter != null, "Parameter \"parameter\" cannot be null.");
}
Relevance:
This is probably only usable, if you have a coding convention that no method can accept a null parameter.
Not supported:
The plugin requires that the assert statements are method calls - not inline tests for null.
Supported:
void Foo(object parameter) {
MyAsserts.AssertNotNull(parameter);
}
Not Supported:
void Foo(object parameter) {
if (parameter == null) throw new Exception("Parameter \"parameter\" cannot be null.");
}
Configuration:
The plugin can be configured in the ReSharper/Options/Highlighting/Parameter Asserts page. I have attached a screenshot of the configuration that we use in our project.
Best regards
Jakob Christensen
Attachment not added (general error): "ParameterAsserts.jpg"
Attachment(s):
Parameter Asserts.zip
Please sign in to leave a comment.