BUG: GC.SuppressFinalize within any block (CC0029)
See original GitHub issuepublic override void Dispose() { try { if (MyConnection != null) (MyConnection.Dispose(); } finally { GC.SuppressFinalize(this); } }
When you add a GC.SuppressFinalize (this)
in a finally block the codecrack suggests the addition of SuppressFinalize
method. I believe this is a small bug, or not?
Should work with any block too:
This should not raise a diagnostic:
public void Dispose()
{
if (condition)
GC.SuppressFinalize(this);
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Is it harmless to call GC.SuppressFinalize within the finalizer?
The call to SuppressFinalize is actually quite trivial, it just sets a flag in the object to prevent it being added to the...
Read more >CA1816: Call GC.SuppressFinalize correctly (code analysis)
In an unsealed class, a method that's an implementation of IDisposable.Dispose and doesn't call GC.SuppressFinalize.
Read more >code-cracker/CHANGELOG.md at master
An analyzer library for C# and VB that uses Roslyn to produce refactorings, ... SuppressFinalize within any block (CC0029) #776; BUG: CC0052 (Make...
Read more >C# static code analysis: "GC.SuppressFinalize" should not ...
GC.SuppressFinalize requests that the system not call the finalizer for the specified object. This should only be done when implementing Dispose as part...
Read more >Can GC.SuppressFinalize cause performance problems?
SuppressFinalize(this) when your Dispose method has run. Otherwise the instance will not be garbage-collected easily, it will be queued on a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@giggio @raphaelm22 May I work on this issue?
Closed on #819.