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.

Legacy protected dispose pattern

See original GitHub issue

Does anyone have any information about why the protected dispose pattern is marked as “LEGACY” in this analyzer? It looks to me like using protected virtual Dispose(bool disposing) aligns more closely with the suggested Dispose pattern that can be found on MSDN, so I’m not sure why it’s labeled as “legacy”.

Thanks 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
JohanLarssoncommented, Nov 19, 2020

I think I prefer LEGACY as it indicates that it is not the preferred pattern by this opinionated analyzer.

My thinking is that full could be interpreted as this is what you want if you want to do it properly.

3reactions
sharwellcommented, Nov 18, 2020

@Bosch-Eli-Black the analyzer encourages the use of a newer and much simpler pattern over the pattern originally developed, leveraging best practices information learned in the meantime. I would recommend changing ‘legacy’ to ‘full’, but without question would continue to discourage its use. The only cases where the ‘full’ pattern makes sense are:

  1. A public library which already has an established public API that consistently uses the full pattern (this would include developing new code in the BCL)
  2. Implementing a type which derives from a base class that use the full pattern, e.g. Form
Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement a Dispose method
The dispose pattern is used for objects that implement the IDisposable interface. This pattern is common when interacting with file and pipe ...
Read more >
CA1063 when implementing the dispose pattern for a ...
Follow the Implementing the dispose pattern for a derived class guide and override the Object.Finalize method. using System; class BaseClass : ...
Read more >
The Dispose Pattern - YouTube
The Dispose Pattern is the be-all and end-all of resource deallocation - which is why we almost never use it. Many thanks to...
Read more >
Do I really need to implement Dispose(Boolean)?
It comes with a Dispose(Boolean) and a Dispose() method, while the Finalize() method is commented, suggesting it is the only thing that is ......
Read more >
Using, IDisposable & Finalizers - Elements Docs
The Disposable Pattern, centered around the IDisposable interface, can be used to add deterministic disposal of resources that are not managed by the ......
Read more >

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