ReSharper generates this file: Annotations.cs. Why?
Asked Answered
F

1

16

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.

Fortnight answered 6/5, 2013 at 14:7 Comment(2)
This file supports Resharper annotations (attributes like [NotNull] or [Pure]) that give additional information about the code to help with code analysis. If you don't need it, you can remove it, it shouldn't cause any problem (as long as you don't use these annotations of course).Metastasize
I get this file always if I implement the INotiyPropertyChanged-Interface. If I let create it, then I have intellisense in the PropertyChanged-EventSubordinate
H
23

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.

Herrington answered 6/5, 2013 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.