question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IDISP001 does not take into account factories

See 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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

2reactions
AraHaancommented, Feb 14, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found