-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix up boilerplate text for Dispose/Finalize #8474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #8333. Notes that
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
| ## Remarks | ||
| This method is called by the public `Dispose()` method and the <xref:System.Object.Finalize%2A> method. `Dispose()` invokes the protected `Dispose(Boolean)` method with the `disposing` parameter set to `true`. <xref:System.Object.Finalize%2A> invokes `Dispose` with `disposing` set to `false`. | ||
| ## Remarks | ||
| This method is called by the public `Dispose()` method and the <xref:System.Object.Finalize> method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This remark isn't generic boilerplate but is actually the text on the TempFileCollection page. We know whether TempFileCollection implements a finalizer (it does). Seems like it would make sense to specialize this with that knowledge? Same for the rest of the occurrences here where we know whether it does or doesn't implement a finalizer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you mean specializing this general text in both cases? (when finalizer is overridden VS when it's missing)
What if we change the implementation (delete or add a finalizer)? Are we sure we have the processes, the awareness and the capacity to always ensure the necessary documentation change? Also, I would find a specialized text confusing, in case the finalizer is missing. Dispose(false) is never invoked from the built-in hierarchy, that case only makes sense if a subclass overrides the finalizer. We would need to properly explain this in the text.
IMO the boilerplate text is a safer option if we are not sure if we can (or want to) address these concerns.
Fixes #8333.
Notes that
Dispose(Boolean)is only called byFinalizeif it's been overridden.