IDISP001 does not take into account factoriesSee original GitHub issue
Warning IDISP001 Dispose created.
As per this Stack Overflow discussion factories should not keep track of created
IDisposable objects. This disagrees with the explanation for the analyzer rule:
When you create an instance of a type that implements IDisposable you are responsible for disposing it.
Following on from this you can see for rule CA2000:
Do not suppress a warning from this rule unless: The allocating method does not have dispose ownership; that is, the responsibility to dispose the object is transferred to another object or wrapper that’s created in the method and returned to the caller
The reproduction is the code in the original question.
- Created 3 years ago
Top GitHub Comments
It also does not take into account
Form.FindForm() too on winforms and then says “you must wrap this in a using block”, however doing that would close the form instead which is not always intended at all.
I think the analyzer should check and see if it is from a call to
FindForm() on any class that inherits from
Control on Windows Forms and then ignore it and not warn.