Open prosser opened 4 years ago
We used to skip analysis of code with C# using 8 declarations, as the compiler did not expose an API for analyzing those until recently. If you move to VS2019 16.4, you would see identical behavior regardless of the whether you have a using statement or a using declaration.
The core issue here is new MyDisposable().Chained()
here returns the same object as new MyDisposable()
due to chaining. We are able to analyze this correctly if the type and chaining is in the same project. However, interprocedural analysis across assembly boundaries is not supported, so we do not recognize the chaining and aggressively assume that these are distinct objects. I think the best option for us would be to provide you a configurable option that would not flag any instances of a specific type to avoid false positives. Will that work?
Analyzer package
Microsoft.CodeAnalysis.FxCopAnalyzers
Package Version
v2.9.7 (Latest)
Diagnostic ID
CA2000
Repro steps
See attached minimum repro solution. CATest.zip
namespace CATestLib {
}
namespace CATest { using CATestLib;
}