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 »

ReSharper 8 - Formatting Specifier Completion

Took advantage of a nice feature in ReSharper 8 today. I wanted to grab the current DateTime and display the time only, in 12-hour format with seconds and AM/PM. But I don’t do it often and couldn’t remember the exact format off the top of my head. So I typed DateTime.Now.ToString(" and paused for a moment to think… And lo’ and behold, ReSharper came to the rescue. I totally forgot about a new feature called “formatting specifier completion”. You get an intellisense-format drop-down, with applicable format strings (in this case, formats that could be applied »