Unity Analyzer test/dev package.
The included solution is setup to copy the dll to the package on build time
- Analyzers are dlls in Unity
- They apply globally if they are outside of an asmdef (can be inside a package) or locally when inside a package
- Dll settings: turn everything off (Auto Reference, Validate References, Any Platform, Editor, Standalone) and add an AssetTag named "RoslynAnalyzer" (the tags ui is not visible inside packages...)
- Open
analyzers/UnityAnalyzers.sln
- Build
UnityAnalyzers.csproj
- The dll is copied to the
package
folder on build and Unity reimports the dll. Done.
- https://docs.unity3d.com/2021.2/Documentation/Manual/roslyn-analyzers.html
- NOTE: to add the necessary AssetLabel
RoslynAnalyzer
the dll must be copied to the Assets folder to show the UI (and can then go to the package)
There are also two more labels mentiondSourceGenerator
andRunOnlyOnAssembliesWithReference
Alternativelly you can edit the dll meta manually to add the label:guid: ... labels: - RoslynAnalyzer PluginImporter: ...
- Debugging SourceGenerators
#if DEBUG
if (!Debugger.IsAttached)
{
Debugger.Launch();
}
#endif
When using Rider set Rider as the default JIT debugger in Settings/Debugger and clicking the Set As Default Debugger
button