Microsoft.Unity.Analyzers
1.26.0
Prefix Reserved
dotnet add package Microsoft.Unity.Analyzers --version 1.26.0
NuGet\Install-Package Microsoft.Unity.Analyzers -Version 1.26.0
<PackageReference Include="Microsoft.Unity.Analyzers" Version="1.26.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Microsoft.Unity.Analyzers" Version="1.26.0" />
<PackageReference Include="Microsoft.Unity.Analyzers"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Microsoft.Unity.Analyzers --version 1.26.0
#r "nuget: Microsoft.Unity.Analyzers, 1.26.0"
#:package Microsoft.Unity.Analyzers@1.26.0
#addin nuget:?package=Microsoft.Unity.Analyzers&version=1.26.0
#tool nuget:?package=Microsoft.Unity.Analyzers&version=1.26.0
Analyzers for Unity
This project provides Visual Studio with a better understanding of Unity projects by adding Unity-specific diagnostics or by removing general C# diagnostics that do not apply to Unity projects.
Check out the list of analyzers and suppressors defined in this project.
Releases
For Visual Studio these analyzers ship in the box (Game development with Unity workload). For Visual Studio Code, please use our official Unity extension here.
We also ship them on NuGet as for people building class librairies for Unity and for other advanced usages.
Suggesting a new Analyzer
If you have an idea for a best practice for Unity developers to follow, please open an issue with the description.
Prerequisites
For building and testing, you'll need .NET 9 (SDK 9.0.201+) and Visual Studio 2022 17.13+, or Visual Studio Code 1.92+.
We are using slnx solution files, so when using Visual Studio, please make sure to enable Solution File Persistence Model in Tools/Options/Preview Features.
This project is using the DiagnosticSuppressor API to conditionally suppress reported compiler/analyzer diagnostics.
On Windows, you'll need the Visual Studio extension development workload installed to build a VSIX to use and debug the project in Visual Studio.
For unit-testing, we require Unity to be installed. We recommend using the latest LTS version for that.
Building and testing
Compiling the solution:
dotnet build .\src\Microsoft.Unity.Analyzers.slnx
Running the unit tests:
dotnet test .\src\Microsoft.Unity.Analyzers.slnx
You can open .\src\Microsoft.Unity.Analyzers.slnx in your favorite IDE to work on the analyzers and run/debug the tests.
Debugging the analyzers on a Unity project
Running and debugging the tests is the easiest way to get started but sometimes you want to work on a real-life Unity project.
On Visual Studio
- Open the
Microsoft.Unity.Analyzers.Vsix.slnxsolution. - Make sure
Microsoft.Unity.Analyzers.Vsixis set as the startup project. - Hit play (Current Instance) to start debugging an experimental instance of Visual Studio 2022.
- Load any Unity project in the Visual Studio experimental instance then put breakpoints in the
Microsoft.Unity.Analyzersproject.
Handling duplicate diagnostics
Starting with Visual Studio Tools for Unity 4.3.2.0, we ship and automatically include this set of analyzers/suppressors in all projects generated by Unity (using <Analyzer Include="..." /> directive).
The downside of this is when trying to debug your own solution is to find yourself with duplicated diagnostics because Visual Studio will load both:
- the project-local analyzer that we release and include automatically, through the
<Analyzer Include="..." />directive. - the VSIX extension you deployed, that will apply analyzers/suppressors to all projects in the IDE.
To disable the project-local analyzer, and keeping a workflow compatible with Unity re-generating project files on all asset changes, you can add the following script in an Editor folder of your Unity project to disable all local analyzers loaded with <Analyzer Include="..." /> directive.
using UnityEditor;
using System.Text.RegularExpressions;
public class DisableLocalAnalyzersPostProcessor : AssetPostprocessor
{
public static string OnGeneratedCSProject(string path, string content)
{
return Regex.Replace(content, "(\\<Analyzer)\\s+(Include=\".*Microsoft\\.Unity\\.Analyzers\\.dll\")", "$1 Condition=\"false\" $2");
}
}
Creating a new analyzer
To easily create a new analyzer, you can use the following command:
dotnet run --project .\src\new-analyzer
This will automatically create source files for the analyzer, associated tests and add resource entries. If your new analyzer's name contains the word suppressor, the tool will create a new suppressor. By default the tool will create a regular analyzer and codefix.
Example for creating CustomAnalyzer, CustomCodeFix and CustomTests classes :
dotnet run --project .\src\new-analyzer Custom
Example for creating CustomSuppressor and CustomSuppressorTests classes :
dotnet run --project .\src\new-analyzer CustomSuppressor
Contributing
This project welcomes contributions and suggestions. Please have a look at our Guidelines for contributing.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (15)
Showing the top 15 popular GitHub repositories that depend on Microsoft.Unity.Analyzers:
| Repository | Stars |
|---|---|
|
dotnet/sdk
Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
|
|
|
homuler/MediaPipeUnityPlugin
Unity plugin to run MediaPipe
|
|
|
NebulaModTeam/nebula
A multiplayer mod for the game Dyson Sphere Program
|
|
|
sailro/EscapeFromTarkov-Trainer
Escape from Tarkov (EFT) Trainer - Internal
|
|
|
CitiesSkylinesMods/TMPE
Cities: Skylines Traffic Manager: President Edition
|
|
|
IllusionMods/KK_Plugins
Various plugins for various Illusion games
|
|
|
IllusionMods/BepisPlugins
A collection of essential BepInEx plugins for games made by Illusion.
|
|
|
IllusionMods/IllusionModdingAPI
Modding API for games made by Illusion (PHAPI / KKAPI / ECAPI / AIAPI / HS2API / KKSAPI)
|
|
|
nicoco007/BeatSaberCustomAvatars
Beat Saber mod that allows the use of custom player avatars for in-game body presence.
|
|
|
ToniMacaroni/SaberFactory
A highly customizable custom saber mod for Beat Saber
|
|
|
IllusionMods/IllusionFixes
A collection of fixes for common issues found in games by Illusion
|
|
|
google/xr-objects
XR-Objects is an open-source prototype that anchors contextual interactions onto analog objects to not only convey information but also to initiate digital actions, such as querying LLMs for details or executing tasks. Creating an early form of Augmented Object Intelligence.
|
|
|
risk-of-thunder/R2API
A modding API for Risk of Rain 2
|
|
|
ManlyMarco/IllusionCheatTools
Trainer for games by Illusion
|
|
|
BepInEx/BepInEx.Debug
Tools for debugging and developing BepInEx plugins (mono)
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.26.0 | 447 | 2/3/2026 |
| 1.25.0 | 10,630 | 8/22/2025 |
| 1.24.0 | 738 | 8/15/2025 |
| 1.23.0 | 1,771 | 6/24/2025 |
| 1.22.0 | 6,630 | 2/14/2025 |
| 1.21.0 | 7,086 | 10/29/2024 |
| 1.20.0 | 2,378 | 8/16/2024 |
| 1.19.0 | 65,442 | 3/18/2024 |
| 1.18.0 | 7,932 | 11/2/2023 |
| 1.17.0 | 56,828 | 5/31/2023 |
| 1.16.1 | 15,484 | 3/16/2023 |
| 1.16.0 | 3,730 | 2/21/2023 |
| 1.15.0 | 5,764 | 11/30/2022 |
| 1.14.0 | 10,249 | 7/15/2022 |
| 1.13.0 | 12,731 | 4/4/2022 |
| 1.12.0 | 6,670 | 1/19/2022 |
| 1.11.2 | 8,234 | 11/25/2021 |
| 1.11.1 | 30,585 | 9/1/2021 |
| 1.11.0 | 19,851 | 6/2/2021 |
| 1.10.2 | 4,380 | 4/29/2021 |
| 1.10.1 | 3,892 | 4/20/2021 |
| 1.10.0 | 6,384 | 2/16/2021 |
| 1.9.1 | 4,487 | 1/5/2021 |
| 1.9.0 | 5,200 | 11/21/2020 |
| 1.8.2 | 4,702 | 9/22/2020 |
| 1.8.1 | 3,897 | 9/2/2020 |
| 1.8.0 | 3,987 | 7/20/2020 |
| 1.7.1 | 4,018 | 6/19/2020 |
| 1.7.0 | 7,000 | 6/9/2020 |