KeyedServiceResolutionAnalyzer
NexusLabs.Needlr.Analyzers¶
NexusLabs.Needlr.Analyzers¶
KeyedServiceResolutionAnalyzer Class¶
Analyzer that validates [FromKeyedServices] usage against discovered [Keyed] registrations. Reports Info-level diagnostic when a key is not found in statically-discovered registrations. Only active when [assembly: GenerateTypeRegistry] is present.
Inheritance Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer 🡒 KeyedServiceResolutionAnalyzer
Remarks¶
This analyzer collects all [Keyed("key")] attributes from types in the compilation and validates that [FromKeyedServices("key")] parameters reference known keys.
Keys registered via plugins at runtime cannot be validated at compile time. Users can suppress this diagnostic for such cases.