Skip to content

IMPORTANT: Remove analyzers from Visual Studio/VS Code extensions #1172

Open
@josefpihrt

Description

@josefpihrt

Summary

At the beginning it seemed like a good idea to include analyzers in the IDE extensions. Analyzers were available in every project/solution without necessity reference in every project/solution.

The main issue is that the analyzers are "bound" only to the IDE, diagnostics will be displayed in the IDE but not during build, command-line build or CI build.

The desired state is that analyzers are "bound" to the project/solution, regardless of the IDE or extension installed.

Best Practice

  • Install extension to have refactoring and code fixes for compiler diagnostics.
  • Install NuGet package(s) with analyzers.
    • Add package reference to your Directory.Build.props file which is located at the root of your repository.

Directory.Build.props

<ItemGroup>
  <PackageReference Include="roslynator.analyzers" Version="<VERSION>">
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    <PrivateAssets>all</PrivateAssets>
  </PackageReference>
  <PackageReference Include="roslynator.formatting.analyzers" Version="<VERSION>">
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    <PrivateAssets>all</PrivateAssets>
  </PackageReference>
</ItemGroup>

When it will be removed?

Probably the best opportunity would be a moment when a new major version of Visual Studio is released. It usually means that major version of Roslynator is released as well.

Depending on when the next major version of VS will be released, analyzers could be removed from extension earlier, but not at least several months after this announcement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions