{"id":22025140,"url":"https://github.com/microsoft/microsoft.unity.analyzers","last_synced_at":"2025-05-14T03:10:44.868Z","repository":{"id":37100249,"uuid":"225717164","full_name":"microsoft/Microsoft.Unity.Analyzers","owner":"microsoft","description":"Roslyn analyzers for Unity game developers","archived":false,"fork":false,"pushed_at":"2025-05-07T17:53:45.000Z","size":921,"stargazers_count":726,"open_issues_count":13,"forks_count":78,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-07T18:41:31.299Z","etag":null,"topics":["analyzers","csharp","unity3d"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-03T21:14:29.000Z","updated_at":"2025-05-07T17:53:45.000Z","dependencies_parsed_at":"2023-10-19T16:23:22.975Z","dependency_job_id":"211c6610-73cc-4d60-b3b5-d78585a615f0","html_url":"https://github.com/microsoft/Microsoft.Unity.Analyzers","commit_stats":{"total_commits":222,"total_committers":13,"mean_commits":"17.076923076923077","dds":"0.13963963963963966","last_synced_commit":"5c22e1a17b0985bcedd179f8c4073a3a29cdf1b6"},"previous_names":[],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FMicrosoft.Unity.Analyzers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FMicrosoft.Unity.Analyzers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FMicrosoft.Unity.Analyzers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2FMicrosoft.Unity.Analyzers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/Microsoft.Unity.Analyzers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059513,"owners_count":22007769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analyzers","csharp","unity3d"],"created_at":"2024-11-30T07:14:16.071Z","updated_at":"2025-05-14T03:10:39.858Z","avatar_url":"https://github.com/microsoft.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Analyzers for Unity\r\n\r\n[![Build status](https://github.com/microsoft/Microsoft.Unity.Analyzers/workflows/CI/badge.svg)](https://github.com/microsoft/Microsoft.Unity.Analyzers/actions?query=workflow%3ACI)\r\n[![NuGet](https://img.shields.io/nuget/v/Microsoft.Unity.Analyzers.svg)](https://nuget.org/packages/Microsoft.Unity.Analyzers)\r\n\r\nThis 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.\r\n\r\nCheck out the [list of analyzers and suppressors](doc/index.md) defined in this project.\r\n\r\n# Releases\r\n\r\nFor Visual Studio these analyzers **ship in the box** (_Game development with Unity_ workload). For Visual Studio Code, please use our official Unity extension [here](https://marketplace.visualstudio.com/items?itemName=VisualStudioToolsForUnity.vstuc).\r\n\r\nWe also ship them on [NuGet](https://nuget.org/packages/Microsoft.Unity.Analyzers) as for people building class librairies for Unity and for other advanced usages.\r\n\r\n# Suggesting a new Analyzer\r\n\r\nIf you have an idea for a best practice for Unity developers to follow, please open an [issue](https://github.com/microsoft/Microsoft.Unity.Analyzers/issues/new?template=Feature_request.md) with the description.\r\n\r\n# Prerequisites\r\n\r\nFor building and testing, you'll need **.NET 9 (SDK 9.0.201+) and Visual Studio 2022 17.13+, or Visual Studio Code 1.92+**.\r\n\r\nWe are using `slnx` solution files, so when using Visual Studio, please make sure to enable `Solution File Persistence Model` in `Tools/Options/Preview Features`.\r\n\r\nThis project binaries are targeting **Visual Studio 2019 16.4+** and **Visual Studio Code 1.76+**.\r\n\r\nThis project is using the `DiagnosticSuppressor` API to conditionally suppress reported compiler/analyzer diagnostics.\r\n\r\nOn Windows, you'll need the _Visual Studio extension development_ workload installed to build a VSIX to use and debug the project in Visual Studio.\r\n\r\nFor unit-testing, we require Unity to be installed. We recommend using the latest LTS version for that.\r\n\r\n# Building and testing\r\n\r\nCompiling the solution:\r\n`dotnet build .\\src\\Microsoft.Unity.Analyzers.slnx`\r\n\r\nRunning the unit tests:\r\n`dotnet test .\\src\\Microsoft.Unity.Analyzers.slnx`\r\n\r\nYou can open `.\\src\\Microsoft.Unity.Analyzers.slnx` in your favorite IDE to work on the analyzers and run/debug the tests.\r\n\r\n# Debugging the analyzers on a Unity project\r\n\r\nRunning and debugging the tests is the easiest way to get started but sometimes you want to work on a real-life Unity project.\r\n\r\n## On Visual Studio\r\n\r\n- Open the `Microsoft.Unity.Analyzers.Vsix.slnx` solution.\r\n- Make sure `Microsoft.Unity.Analyzers.Vsix` is set as the startup project.\r\n- Hit play (Current Instance) to start debugging an experimental instance of Visual Studio 2022.\r\n- Load any Unity project in the Visual Studio experimental instance then put breakpoints in the `Microsoft.Unity.Analyzers` project.\r\n\r\n# Handling duplicate diagnostics \r\n\r\nStarting 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 `\u003cAnalyzer Include=\"...\" /\u003e` directive).\r\n\r\nThe downside of this is when trying to debug your own solution is to find yourself with duplicated diagnostics because Visual Studio will load both:\r\n- the project-local analyzer that we release and include automatically, through the `\u003cAnalyzer Include=\"...\" /\u003e` directive. \r\n- the VSIX extension you deployed, that will apply analyzers/suppressors to all projects in the IDE.\r\n\r\nTo 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 `\u003cAnalyzer Include=\"...\" /\u003e` directive.\r\n\r\n```csharp\r\nusing UnityEditor;\r\nusing System.Text.RegularExpressions;\r\n\r\npublic class DisableLocalAnalyzersPostProcessor : AssetPostprocessor\r\n{\r\n\tpublic static string OnGeneratedCSProject(string path, string content)\r\n\t{\r\n\t\treturn Regex.Replace(content, \"(\\\\\u003cAnalyzer)\\\\s+(Include=\\\".*Microsoft\\\\.Unity\\\\.Analyzers\\\\.dll\\\")\", \"$1 Condition=\\\"false\\\" $2\");\r\n\t}\r\n}\r\n```\r\n\r\n# Creating a new analyzer \r\n\r\nTo easily create a new analyzer, you can use the following command:\r\n\r\n`dotnet run --project .\\src\\new-analyzer`\r\n\r\nThis 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.\r\n\r\nExample for creating `CustomAnalyzer`, `CustomCodeFix` and `CustomTests` classes :\r\n\r\n`dotnet run --project .\\src\\new-analyzer Custom`\r\n\r\nExample for creating `CustomSuppressor` and `CustomSuppressorTests` classes :\r\n\r\n`dotnet run --project .\\src\\new-analyzer CustomSuppressor`\r\n\r\n# Contributing\r\n\r\nThis project welcomes contributions and suggestions.\r\nPlease have a look at our [Guidelines](CONTRIBUTING.md) for contributing.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fmicrosoft.unity.analyzers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fmicrosoft.unity.analyzers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fmicrosoft.unity.analyzers/lists"}