Using Annotations to Assist ReSharper in Analyzing Your Code

(The code - posted here as images to demonstrate ReSharper’s code analysis - is also available on Github.) Anyone who uses ReSharper is familiar with the little squiggly line indicating a “warning” of one kind or another. And anyone who develops with .NET is familiar with the ubiquitous NullReferenceException and ReSharper’s “possible ‘System.NullReferenceException'” warning. This post was inspired by a question on SO: ReSharper: Null check is always false warning ReSharper and optimistic analysis Here’s a really simple example (VS 2013 / R# 8.2) demonstrating the feature. In both cases, a string is initialized to null »