Skip to main content

How to Use Roslynator .NET API

Roslynator .NET API extends Roslyn API and it can be used for development of custom analyzers/refactorings.

Packages

PackageVersionExtends
Roslynator.CoreNuGetMicrosoft.CodeAnalysis.Common
Roslynator.Workspaces.CoreNuGetMicrosoft.CodeAnalysis.Workspaces.Common
Roslynator.CSharpNuGetMicrosoft.CodeAnalysis.CSharp
Roslynator.CSharp.WorkspacesNuGetMicrosoft.CodeAnalysis.CSharp.Workspaces

Analyzer Package Configuration

Unfortunately it's not possible to reference any package in the analyzer package. Therefore it's necessary to include dll files themselves:

<file src="bin\$Configuration$\netstandard2.0\Roslynator*.dll" target="analyzers\dotnet\cs" />
Foo.Analyzers.nuspec
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Foo.Analyzers</id>
<version>1.0.0</version>
<authors>Me</authors>
<projectUrl>https://github.com/me/foo-analyzers</projectUrl>
<repository type="git" url="https://github.com/me/foo-analyzers.git" />
<developmentDependency>true</developmentDependency>
</metadata>
<files>
<file src="bin\$Configuration$\netstandard2.0\Foo.Analyzers.dll" target="analyzers\dotnet\cs" />
<file src="bin\$Configuration$\netstandard2.0\Roslynator*.dll" target="analyzers\dotnet\cs" />
<file src="tools\*.ps1" target="tools\" />
</files>
</package>

Package Folder Structure

  • Foo.Analyzers.1.0.0.nupkg
    • analyzers
      • dotnet
        • cs
          • Foo.Analyzers.dll
          • Roslynator.Core.dll
          • Roslynator.CSharp.dll
          • Roslynator.CSharp.Workspaces.dll
          • Roslynator.Workspace.Core.dll