Is there a Lint Rule or Some way to indicate something implements IDisposable #78123
-
public class MailMessage : IDisposable It's not always immediately clear that something implements IDisposable. This can cause memory issues, and I would like for a way to detect if an instance of a class is made without a using on something that implements IDisposable |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000 However, this rule is very unreliable. It doesn't properly track ownership transferring (storing values to fields), which is a very complex problem. Moreover, fail to call |
Beta Was this translation helpful? Give feedback.
https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2000
However, this rule is very unreliable. It doesn't properly track ownership transferring (storing values to fields), which is a very complex problem.
Moreover, fail to call
Dispose
on usual objects do not cause memory issue, because there is finalizer. It's usually a performance issue instead.