roslynator
roslynator copied to clipboard
IMPORTANT: Remove analyzers from Visual Studio/VS Code extensions
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.propsfile which is located at the root of your repository.
- Add package reference to your
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.
Do you not need to include Roslynator.CodeAnalysis.Analyzers ?
Analyzer from package Roslynator.CodeAnalysis.Analyzers were never included in the VS extension. These analyzers are relevant only for projects that reference Roslyn packages (Microsoft.CodeAnalysis*)
https://josefpihrt.github.io/docs/roslynator/analyzers#groups
While I understand the decision, just wanted to say that this is going to be a big downside for anyone who uses Roslynator with Unity projects, as unity basically has no native way to install nuget packages, and you have to go and manually download DLLs and then often use special scripts that auto-edit unity-generated project files
@orels1 The extension with analyzers will be still available as GH artifact as it can be seen here. Would that do?
@josefpihrt If a line could be thrown into the readme, pointing that out as an option - I think that would be at least much better than not having it at all
@orels1 It will be documented, no doubt about it.
Roslynator has been immensely useful for contributing to OSS and work projects alike for helping rewrite various code patterns to a more performant version without forcing the projects to add them explicitly which would require much more involved approach (because people are opinionated on what goes in, and it needs more configuration effort). This extension has been consistently making VS Code have better code fixes defaults than Rider. Would be sad to see it go.
Roslynator has been immensely useful for contributing to OSS and work projects alike for helping rewrite various code patterns to a more performant version without forcing the projects to add them explicitly which would require much more involved approach (because people are opinionated on what goes in, and it needs more configuration effort). This extension has been consistently making VS Code have better code fixes defaults than Rider. Would be sad to see it go.
Agreed. I'm also sad to hear it will no longer be an IDE extension for similar reasons
We have started adding the deps into the Directory.build.props file, but this is dramatically harder to implement and maintain (and keep updated) across multiple solutions, rather than having a single VS or VS Code extension installed.