How to set up a project and its moving parts
The C# compiler, powered by the Roslyn framework (https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/), provides a mechanism to load and use custom extensions in the form of analyzer and code fix providers. These extensions can be packaged as NuGet packages or included as project references, and they are loaded into the compilation process to analyze or modify the source code being compiled.
When the C# compiler encounters a project that includes a reference to a Roslyn extension, it uses .NET’s AssemblyLoadContext to load the extension’s assembly into the compilation process. This allows the extension’s code to be executed during the compilation process and participate in the analysis and transformation of the source code.
The Roslyn extensions are loaded into the compiler as analyzers, or source generators. Analyzers are responsible for examining the source code and reporting diagnostics, which are warnings...