Question

In a setup with Visual Studio 2012 Update 2 and ReSharper 7.1.1 this file Annotations.cs is generated when creating a new projects. I can not find any article describing why ReSharper does that and if it possible to disable this. I think of ReSharper as an enhancement of the IDE - and I do not expect ReSharper to add files my projects behind my back.

Was it helpful?

Solution

This file contains the definitions for ReSharper Code Annotations.

Code inspections amd many other ReSharper features largely rely on heuristic analysis of the source code to detect issues, suggest possible improvements, and help you in other ways.

However, heuristic analysis cannot detect everything. For example, if a method is designed to never return null and its clients are designed accordingly, no heuristic analysis can help find a possible issue if someone has changed the method to return null.

In this and a lot of other cases, the Annotated Framework is of a great help. By using attributes declared in this framework you can make ReSharper analyze code the way you need it:

[NotNull]
public object Foo()
{
    return null; // Warning: Possible 'null' assignment
}
    

This being the simplest example, there are other helpful attributes with more complex use cases in the Annotated Framework. You can find the full list of these attributes in the Reference.

See http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Code_Annotations.html for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top