dotnet / roslyn-analyzers

MIT License
1.59k stars 466 forks source link

Performance problems in `DisposeObjectsBeforeLosingScope` #7134

Open nike4613 opened 10 months ago

nike4613 commented 10 months ago

Analyzer

DisposeObjectsBeforeLosingScope

Analyzer source

SDK: Built-in CA analyzers in .NET 8 SDK

Version: SDK 8.0.100

Describe the bug

Compiling some projects (not all) results in this analyzer taking a significant amount of time, significantly slowing the build.

I ran a PerfView trace of the build, and am seeing quite a lot of exceptions thrown from Microsoft.CodeAnalysis.DataFlow.DataFlowOperationVisitor``4.VisitInvocation_LambdaOrDelegateOrLocalFunction, which seem to take quite a lot of time:

Apparently not from the same method, there are also a lot of ArgumentOutOfRangeExceptions which are being thrown, though I cannot get a good idea of where because the stack traces are broken in my trace. There are also several other failed casts, though I am unsure if they are related to this analyzer.

nike4613 commented 10 months ago

This looks to be the same as #6412