Redundant Assertions - prodot/ReCommended-Extension GitHub Wiki
If known at some point that x is not null, highlight the assertion as redundant:
Debug.Assert(x != null)Contract.Assert(x != null)-
.AssertNotNull(x)*
Tip
A context action is always available to remove the null-forgiving operator or the assertion.
* The inline assertion is determined when all the conditions are met:
- the method name starts with "AssertNotNull"
- the method is an extension method
- the method has single parameter
- the method's parameter type equals to the method return type
- the method is annotated with the
[NotNull] - the method is annotated with the
[DebuggerStepThrough]
Note
The analyzer can be configured or deactivated in the ReSharper Options or Rider Settings dialog.