The problem is that ReSharper's analysis engine doesn't understand it, so we would get an error/warning like this:
Which is obviously not correct, since aString.isNull() will return true in this case.
To deal with this, I added a couple JetBrains ContractAnnotation to those Extension Methods:
And now ReSharper’s engine will detect that those code paths (that previously flagged the null exception) will never be taken:
Note that I also added Contract Annotations to the isFalse and isTrue extension methods
The only annoying thing is that it seems that the ContractAnnotation class needs to be in the JetBrains.Annotations namespace, which I didn’t really want to include in the FluentSharp.CoreLib.dll (I’m sure there is a a workaround, which I’ll find later)
References:
- IntelliJ IDEA :: Contract Annotations
- JetBrains .NET Tools Blog » Contract Annotations in ReSharper 7
- JetBrains .NET Tools Blog » ReSharper NullReferenceException Analysis and Its Contracts
- Code Annotations
- c# - ReSharper - Possible Null Assignment when using Microsoft.Contracts - Stack Overflow
- Providing Intellisense, Navigation and more for Custom Helpers in ASP.NET MVC « Hadi Hariri's Blog
- mvba/FluentAssert · GitHub
- How to add custom code analysis in ReSharper - Stack Overflow