You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Diagnostic ID: CA2000: Call System.IDisposable.Dispose on object created by '...' before all references to it are out of scope (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)
usingSystem.Data;namespaceCA2000;publicstaticclassRepro{publicstaticDataColumn[]FalsePositive()=>[newDataColumn()// <- triggers CA2000];publicstaticDataColumn[]NotTriggered()=>new[]{newDataColumn()// works fine};}
Expected behavior
FalsePositive method shouldn't trigger CA2000.
Actual behavior
1>C:\source\playground\src\Playground\CA2000\Program.cs(8,9,8,25): warning CA2000: Call System.IDisposable.Dispose on object created by 'new DataColumn()' before all references to it are out of scope (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)
Additional context
-
The text was updated successfully, but these errors were encountered:
Analyzer
Diagnostic ID: CA2000:
Call System.IDisposable.Dispose on object created by '...' before all references to it are out of scope (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000)
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: 9.0.101
Describe the bug
Returning a collection expression of
IDisposable
triggers CA2000 even though it shouldn't.Steps To Reproduce
csproj:
code:
Expected behavior
FalsePositive
method shouldn't trigger CA2000.Actual behavior
Additional context
-
The text was updated successfully, but these errors were encountered: