-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Update AggregateException.xml #10396
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/area-system-runtime |
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: Genevieve Warren <[email protected]>
Learn Build status updates of commit 4f513d6: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
<summary>Returns the <see cref="T:System.Exception"/> that is the root cause of this exception. This exception is either the root exception or the first <see cref="T:System.AggregateException"/> that contains either multiple inner exceptions or no inner exceptions at all.</summary> | ||
<returns>The <see cref="T:System.Exception" /> that is the root cause of this exception.</returns> |
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.
<summary>Returns the <see cref="T:System.Exception"/> that is the root cause of this exception. This exception is either the root exception or the first <see cref="T:System.AggregateException"/> that contains either multiple inner exceptions or no inner exceptions at all.</summary> | |
<returns>The <see cref="T:System.Exception" /> that is the root cause of this exception.</returns> | |
<summary>Returns the <see cref="T:System.AggregateException"/> that is the root cause of this exception. This exception is either the current exception or the first <see cref="T:System.AggregateException"/> that contains either multiple inner exceptions or no inner exceptions at all.</summary> | |
<returns>The <see cref="T:System.AggregateException" /> that is the root cause of this exception.</returns> |
https://learn.microsoft.com/en-us/dotnet/api/system.exception.getbaseexception and other docs use "current exception" for this.
Also, I think the original docs were better in highlighting that the returned instance is always AggregateException.
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.
The original docs were wrong, hence my fixes. The code will return the plain Exception
which was thrown up the chain (what's now called the current exception), and only if there are multiple exceptions wrapped in an AggregateException
will it return an aggregate exception. That's the whole point of this pull request.
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.
Ah ok, I have misread how the implementation behaves.
I agree with you that the return type in the docs is wrong.
I am not sure whether it makes sense to try to describe the exact algorithm used by this method in the docs. The current implementation of Exception.GetBaseException
and AggregateException.GetBaseException
methods are in conflict with the contract for these methods described in the docs.
https://learn.microsoft.com/en-us/dotnet/api/system.exception.getbaseexception?view=net-8.0 says "For all exceptions in a chain of exceptions, the GetBaseException method must return the same object (the base exception).". For example, this invariant does not seem to hold for
TargetInvocationException
-> AggregateException
-> ArgumentException
-> ArgumentException
GetBaseException()
called on TargetInvocationException
returns first ArgumentException
for , but GetBaseException()
called on AggregateException
returns the same AggregateException
.
We may want to fix the implementation and/or docs to make this more sensible.
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, practically, are you @jkotas addressing this in the documentation?
Related to dotnet/runtime#107743
Summary
Fixes an incorrect description of what method
GetBaseException()
does.