BannedApiAnalyzer Dispose should ban using as well
Suchiman opened this issue · comments
Analyzer
Diagnostic ID: RS0030
Describe the improvement
When you ban the Dispose method like so:
M:System.Net.Http.HttpMessageInvoker.Dispose; Disposing HttpClient leads to socket exhaustion. Don't.
this should not just prevent calling .Dispose();
but also using (httpClient)
as well as using var client = new HttpClient()
Describe suggestions on how to achieve the rule
Expand the existing analysis to consider using
in the analysis as an call to Dispose
and await using
to DisposeAsync
Building up on this:
In fact, I was able to write a small POC, allowing 4 out of 4 cases to detect usings in "Dispose" bans and 3 out of 4 cases to detect usings in "DisposeAsync" cases
Would really love to see this aspect of Dispose banning being covered