Skip to content

Skip code-fix assemblies when configuring Roslyn analyzers - #761

Draft
ZhaoMCX wants to merge 1 commit into
GlitchEnzo:masterfrom
ZhaoMCX:fix/skip-code-fix-analyzers
Draft

Skip code-fix assemblies when configuring Roslyn analyzers#761
ZhaoMCX wants to merge 1 commit into
GlitchEnzo:masterfrom
ZhaoMCX:fix/skip-code-fix-analyzers

Conversation

@ZhaoMCX

@ZhaoMCX ZhaoMCX commented Jul 29, 2026

Copy link
Copy Markdown

What changed

  • Skip assemblies whose file names end with .CodeFixes.dll when deciding whether to add Unity's RoslynAnalyzer label.
  • Add regression coverage for the suffix and case-insensitive matching.

Why

NuGet analyzer packages can contain both compiler analyzers/source generators and IDE-only code-fix assemblies in the analyzers directory. NuGetForUnity currently labels every compatible DLL in that directory as a Roslyn analyzer.

For example, MessagePackAnalyzer 3.1.3 contains MessagePack.SourceGenerator.dll and MessagePack.Analyzers.CodeFixes.dll. Unity then attempts to load the code-fix assembly and reports unresolved references to Microsoft.CodeAnalysis.Workspaces and System.Composition.AttributedModel.

Code-fix assemblies are IDE tooling and should not be passed to Unity's compiler as analyzers. They remain installed but are excluded from Editor/platform loading by the existing importer behavior.

Validation

  • Added Edit Mode regression cases for normal and mixed-case .CodeFixes.dll suffixes.
  • Installed this commit as a Git UPM dependency in a Unity 6000.5.5f1 project.
  • Restored MessagePackAnalyzer 3.1.3 from scratch and confirmed:
    • MessagePack.Analyzers.CodeFixes.dll remains installed without the RoslynAnalyzer label.
    • MessagePack.SourceGenerator.dll retains the RoslynAnalyzer label.
    • Unity recompilation completes without the code-fix dependency errors.
  • Downstream project tests: 35/35 Edit Mode and 16/16 Play Mode passed.

Upstream CI note

The PR's pull_request_target jobs currently stop before running any tests because the repository's custom checkout action does not opt in to checking out fork code under GitHub's current security policy. The failure is limited to the Checkout step and is unrelated to this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants