DisposableCaptiveDependencyAnalyzer
NexusLabs.Needlr.Analyzers¶
NexusLabs.Needlr.Analyzers¶
DisposableCaptiveDependencyAnalyzer Class¶
Analyzer that detects when a longer-lived service holds a reference to a shorter-lived IDisposable. This is a more severe form of captive dependency because the disposed object will still be referenced.
Inheritance Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer 🡒 DisposableCaptiveDependencyAnalyzer
Remarks¶
This analyzer is conservative to avoid false positives: - Only fires when both consumer and dependency have explicit lifetime attributes - Only fires when the dependency type itself (not just interface) implements IDisposable/IAsyncDisposable - Does not fire for factory patterns (Func\<T>, Lazy\<T>, IServiceScopeFactory)