Which version of Roslyn analyzers should I use with Unity?
April 22, 2026 ยท View on GitHub
This repository provides compatibility information for Roslyn analyzers and source generators with different Unity versions.
Unity uses specific versions of Microsoft.CodeAnalysis.CSharp, which means not all analyzer versions work with all Unity versions. This repository helps you find the right analyzer version for your Unity project.
Supported Unity Versions
| Unity Version | Microsoft.CodeAnalysis.CSharp version |
|---|---|
| Unity 6000.0 | 4.3 (stated in Manual: Create and use a source generator) |
| Unity 2022.3.12f1 | 4.3 (backported) |
| Unity 2022.2 | 4.1 |
| Unity 2021.2 | 3.9 (stated "3.8" in Manual: Roslyn analyzers and source generators) |
| Unity 2020.2 | 3.5 |
Note
Microsoft.CodeAnalysis.CSharp version included in the Unity editor is checked using tools/check-unity-roslyn-version.ps1.
Analyzer Compatibility
Check the markdown files in this repository for compatibility information on specific analyzers:
- IDisposableAnalyzers
- Meziantou.Analyzer
- Microsoft.CodeAnalysis.BannedApiAnalyzers
- Microsoft.Unity.Analyzers
- NSubstitute.Analyzers.CSharp
- NUnit.Analyzers
- Roslynator.Analyzers
Want to use an analyzer not listed here?
You can add a new analyzer or update version information by following these steps:
- Fork this repository
- Run the workflow in your fork:
- Go to Actions > Check Roslyn Analyzer Versions
- Click Run workflow
- Enter the NuGet package ID (e.g.,
Microsoft.Unity.Analyzers) - Click Run workflow
- The workflow will push a branch and display a URL. Click the URL to create a Pull Request to this upstream repository.