Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReSharper generates this file: Annotations.cs. Why?

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.

like image 623
Morten Frederiksen Avatar asked May 06 '13 14:05

Morten Frederiksen


1 Answers

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.

like image 112
Florian Greinacher Avatar answered Nov 09 '22 01:11

Florian Greinacher