Skip to content

Roslyn Analyzers (third party)

James Groom edited this page Mar 16, 2023 · 3 revisions

As a reminder, the project files' include graph looks like:

/Common.props
├─ /ExternalProjects/LibCommon.props
│   ├─ /ExternalProjects/FlatBuffers.GenOutput/FlatBuffers.GenOutput.csproj
│   ├─ /ExternalProjects/iso-parser/ISOParser.csproj
│   ├─ /ExternalProjects/NLua/NLua.csproj
│   ├─ /ExternalProjects/PcxFileTypePlugin.HawkQuantizer/PcxFileTypePlugin.HawkQuantizer.csproj
│   └─ /ExternalProjects/AnalyzersCommon.props
│       ├─ /ExternalProjects/BizHawk.Analyzer/BizHawk.Analyzer.csproj
│       └─ /ExternalProjects/BizHawk.SrcGen.ReflectionCache/BizHawk.SrcGen.ReflectionCache.csproj
├─ /src/BizHawk.Version/BizHawk.Version.csproj
├─ /src/MainSlnCommon.props
│   ├─ /src/BizHawk.Common/BizHawk.Common.csproj
│   ├─ ... (other main solution projects, including tests)
│   └─ /src/MainSlnExecutable.props
│       ├─ /src/BizHawk.Bizware.Test/BizHawk.Bizware.Test.csproj
│       ├─ /src/BizHawk.Client.DiscoHawk/BizHawk.Client.DiscoHawk.csproj
│       └─ /src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
└─ /ExternalToolProjects/ExtToolCommon.props
    ├─ /ExternalToolProjects/HelloWorld/HelloWorld.csproj (also imports NET48ExternalToolForm.targets)
    └─ ... (other ext. tools)

/Common.props enables the .NET Analyzers and StyleCop, and imports BizHawk.Analyzer and some third-party Analyzers.

You can tell the assembly references are working if ;; is flagged with "MA0037: Remove empty statement". You can tell the ruleset reference is working if that was flagged but the output isn't flooded with other warnings, such as "MEN002: Line must be no longer than 160 characters". Similarly, you can tell the StyleCop config reference is working if the output isn't flooded with warnings such as "SA1600: Elements should be documented".

Important: /src/MainSlnCommon.props disables Analyzers unless -p:RunAnalyzersDuringBuild=true is passed to dotnet / the build script.