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
Title: Types that own native resources should be disposable
Description:
Types that allocate unmanaged resources should implement IDisposable to enable callers to release those resources on demand and to shorten the lifetimes of the objects that hold the resources.
Dependency: None
Notes:
The text was updated successfully, but these errors were encountered:
@mavasani I wanted to check the cases where the rule report and where it doesn't but I can't manage to have the legacy rule to ever report. Is there any special configuration or setup to have the legacy rule working?
The biggest issue with this rule is how/when to detect the case where it applies. The result is typically a good/bad list of APIs that allocate "native" resources but that is very fragile. The end result is typically slightly noisy and not terribly obvious how best to address the problem via IDisposable. In fact, the best guidance here would be to instead derive from SafeHandle and use that, but again that becomes noisy.
I would also argue that given the age of the IDisposable pattern and the ubiquity of online discussion around its usage, developers will quickly discover it and be able to read about how/when to use it. This will avoid the inevitable noise for the majority of people that are using an IntPtr or some low-level API, who are experts in the area of interop/manual resource management.
Title: Types that own native resources should be disposable
Description:
Types that allocate unmanaged resources should implement IDisposable to enable callers to release those resources on demand and to shorten the lifetimes of the objects that hold the resources.
Dependency: None
Notes:
The text was updated successfully, but these errors were encountered: