JetBrains Fleet 1.37 Help

Annotations in C# source code

The easiest way to benefit from JetBrains Fleet's code annotations is to add the annotation attributes to symbols of your source code and make JetBrains Fleet analyze your solution with greater accuracy and insight.

By default, all annotation attribute classes are marked with [Conditional("JETBRAINS_ANNOTATIONS")] attribute so the compiler will ignore the attribute usages in your code, which means that no binary reference to the 'JetBrains.Annotations.dll' assembly will be produced. However, you can define 'JETBRAINS_ANNOTATIONS' conditional compilation symbol in your projects to preserve the attributes in the metadata.

Enable code annotations support in your project

To make use of the annotation attributes in your project, you should reference them in your project:

  1. Select View | Terminal from the main menu or press ⌃ ⇧ ` to open the Terminal view.

  2. In the command line, switch to the directory that contains the .csproj file of the target project.

  3. Type the following command:

    dotnet add package JetBrains.Annotations

    For more information about the dotnet CLI, refer to the Microsoft Docs.

  4. Add the following using directive in the file where you are going to use annotations:

    using JetBrains.Annotations;

If the JetBrains.Annotations is referenced or attribute declarations are embedded in any of the projects within your solution, you can type the desired annotation attribute and press ⌥ ⏎ to invoke the quick-fix that will reference this module in the current project and add the missing using directive:

Quick-fix for adding reference to the JetBrains.Annotations module
Last modified: 11 February 2024