Skip to content

tretyakov-d/playground-roslyn-analyzers

Repository files navigation

Roslyn analyzer/fixer sample project

Detailed guide is here -> https://dennistretyakov.com/writing-first-roslyn-analyzer-and-codefix-provider

./src/PlaygroundAnalyzers

ExceptionNameAnalyzer.cs - shows warning when exception class name does not end with Exception

ExceptionNameFix.cs - suggests (and does) add Exception postfix to a class name

PlaygroundAnalyzers.nuspec - analyzer nuget package spec.

./tests/PlaygroundAnalyzers.Tests

Tests project requires packages Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.∗
which by some reason are not on public nuget.

roslyn analyzer nuget repository https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json added to NuGet.Config in a solution root.

./examples/ExampleAssembly

An example assembly to see it's really working. Should work out of the box in any IDE that supports roslyn analyzers (eg. Visual Studio, JetBrains Rider and VS Code).

It users package PlaygroundAnalyzers from local folder ./packages/

Therefore ./packages/ added as a source to a NuGet.Config in solution root.

Trying some changes

After code modifications are done, increment version in ./src/PlaygroundAnalyzers/PlaygroundAnalyzers.nuspec and run ./make.sh/ (or make.bat on windows) to make a new package.

Update package reference in ExampleAssembly to a new one. To see the change effect, restart IDE/editor, at least if you using Rider, Visual Studio or VS Code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages