C
C#5mo ago
Anton

✅ How come this gives me no warning in Rider?

var f = File.Open("FDJLK", FileMode.Append);
var f = File.Open("FDJLK", FileMode.Append);
For context, I have this in MSBuild
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>preview</AnalysisLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>preview</AnalysisLevel>
And this in .editorconfig
dotnet_diagnostic.CA1001.severity = error
dotnet_diagnostic.CA1816.severity = error
dotnet_diagnostic.CA1001.severity = error
dotnet_diagnostic.CA1816.severity = error
What else do I have to do to make it work?
23 Replies
Anton
AntonOP5mo ago
Unused variables also don't count as errors. Why does that happen, even with AnalysisLevel preview
canton7
canton75mo ago
What makes you think that you should get a diagnostic there? Neither CA1001 or CA1816 should fire there
Anton
AntonOP5mo ago
No the code I sent should trigger an IDisposable warning
canton7
canton75mo ago
(Note that it's no longer recommended to implement a finalizer in your IDisposable types in almost all cases, and so SuppressFinalize is irrelevant)
Anton
AntonOP5mo ago
Unused variables is a different issue Just related
canton7
canton75mo ago
What makes you think so? CA1001 isn't relevant to that code "own" means the IDisposable member is a field
canton7
canton75mo ago
No description
Anton
AntonOP5mo ago
Ah shit you're right
canton7
canton75mo ago
And it's about implementing IDisposable, not about calling Dispose on variables/fields
Anton
AntonOP5mo ago
Still ignored
canton7
canton75mo ago
Maybe because it's a Stream?
No description
Anton
AntonOP5mo ago
No I tested it on a custom type
ACiDCA7
ACiDCA75mo ago
i dont know about preview but try to set AnalysisLevel to all as in the docs mentioned its not enabled by default...
Anton
AntonOP5mo ago
There's no such thing
canton7
canton75mo ago
Wut?
Anton
AntonOP5mo ago
C:\Program Files\dotnet\sdk\8.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.Analyzers.targets(69,18): error MSB4184: The expres sion "[MSBuild]::VersionGreaterThanOrEquals(all, 5.0)" cannot be evaluated. Version string was not in a correct format.
ACiDCA7
ACiDCA75mo ago
mom
canton7
canton75mo ago
Ah yeah, you're thinking of AnalysisMode
canton7
canton75mo ago
Anton
AntonOP5mo ago
Oh yeah that produced a pile of warnings nice But still none in the ide
canton7
canton75mo ago
Re-run analysis?
ACiDCA7
ACiDCA75mo ago
btw its not enabled by default for a reason.. you are gonna catch quite a few false positives
Want results from more Discord servers?
Add your server