ReSharper External Annotations

ReSharper performs some statistical analysis of your code, and displays a blue squiggly error indicator over anything it thinks will be a problem. One great example is possible System.NullReferenceExceptions – using an object which may be null.


In this example, ReSharper is missing some information - the fact that Assert.NotNull will terminate the flow of the function if the value is null. In other words, this warning us about something that will never happen.

ReSharper can look for various special attributes to get hints about situations like these, but adding special attributes to your code can be a bit intrusive, and doesn't help with third party assemblies.

So ReSharper also supports External Annotations, which is an xml file that describes the attributes that you would assign to methods if you were going to make changes to the source.

There are a number of attributes for assertion methods, such as's Assert.NotNull or Assert.True.

The file xunit.xml in the release contains these attributes, and provides the correct hints to ReSharper so that these spurious warnings are not displayed.

Important! Please copy this file!

ReSharper also uses the External Annotation file to know that a class or method marked with a given attribute is a unit test element. This supplements and short-circuits the code based analysis in the plugin, reducing the work the test provider plugin has to do. Please install this file - consider it a small performance optimisation.


Simply drop the xunit.xml file into C:\Program Files\JetBrains\ReSharper\v5.0\bin\External Annotations and restart Visual Studio.

Last edited Jun 13, 2010 at 9:32 PM by mattellis, version 3