No more NREs when disposing/finalizing, fixes #1547#1567
Merged
akiraveliara merged 3 commits intoDSharpPlus:masterfrom Jun 13, 2023
Merged
No more NREs when disposing/finalizing, fixes #1547#1567akiraveliara merged 3 commits intoDSharpPlus:masterfrom
akiraveliara merged 3 commits intoDSharpPlus:masterfrom
Conversation
Contributor
Author
|
This should be ready for merging. If anyone feels like doing their own testing, feel free to do so. |
Member
|
thank you! - my apologies that i didn't get to it in time |
akiraveliara
pushed a commit
that referenced
this pull r
8000
equest
Jun 13, 2023
OoLunar
pushed a commit
that referenced
this pull request
Oct 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes bug #1547
Details
I removed finalizers while adding null guards to Dispose methods. I used ripgrep to find all finalizers in the project (
rg "\~(\S+)\(\)" *) and addressed them one by one. I was concerned about removing the finalizers fromDiscordWebhookClientandDiscordShardedClientbecause they are doing more than just disposing resources and since I didn't want to risk introducing any breaking change, I decided to leave them alone.These changes were tested with the bot in
DSharpPlus.Testand also my personal Discord bot, both having run perfectly fine. The scenario I was encountering does not occur anymore, even after several garbage collections.Changes proposed
Notes
Some classes contain Dispose methods, despite not implementing the
IDisposableinterface. I wrote a comment for those, since I didn't want to change the API of the library in a simple bug fix, but if you want, I can implement the interface before the PR is accepted.