DeferToContainerInGeneratedCodeAnalyzer
NexusLabs.Needlr.Analyzers¶
NexusLabs.Needlr.Analyzers¶
DeferToContainerInGeneratedCodeAnalyzer Class¶
Analyzer that detects [DeferToContainer] attributes placed in generated code.
Inheritance Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer 🡒 DeferToContainerInGeneratedCodeAnalyzer
Remarks¶
Source generators run in isolation and cannot see output from other generators. If another generator adds [DeferToContainer] to a partial class, Needlr's TypeRegistryGenerator will not see it and will generate incorrect factory code.
This analyzer runs after all generators complete and can detect this scenario, warning users to move the attribute to their original source file.