Skip to content

All analyzers: GeneratedCodeAnalysisFlags.None should be ReportDiagnostics #447

Description

@dnyw4l3n13

Problem

Every DiagnosticAnalyzer in this repo calls:

context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.None);

GeneratedCodeAnalysisFlags.None has value 0, so Analyze | None is bitwise-identical to Analyze alone. The intended flags were:

context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);

Impact

With the current flags, each analyzer runs on generated code but silently suppresses its diagnostics on generated code. Any violation in source-generated classes (wrong visibility, prohibited type usage, etc.) produces no diagnostic.

Files affected

All *DiagnosticsAnalyzer.cs files in src/FunFair.CodeAnalysis/ — they all share the same Initialize pattern.

Fix

Replace GeneratedCodeAnalysisFlags.None with GeneratedCodeAnalysisFlags.ReportDiagnostics in the ConfigureGeneratedCodeAnalysis call in every analyzer.

Discovery

Found during code review of PR #446 (ClassVisibilityDiagnosticsAnalyzer.cs was the touched file that surfaced this).

Metadata

Metadata

Assignees

Labels

AI-WorkWork for an AI AgentBlockedBlocked by a dependency or external factor

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions