-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Update AggregateException.xml #10396
base: main
Are you sure you want to change the base?
Conversation
Tagging subscribers to this area: @dotnet/area-system-runtime |
Learn Build status updates of commit 0d6d7e9:
|
File | Status | Preview URL | Details |
---|---|---|---|
xml/System/AggregateException.xml | View | Details |
xml/System/AggregateException.xml
- Line 0, Column 0: [Warning: xref-not-found - See documentation]
Cross reference not found: 'Exception'.
- Line 0, Column 0: [Warning: xref-not-found - See documentation]
Cross reference not found: 'AggregateException'.
For more details, please refer to the build report.
Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.
For any questions, please:
- Try searching the learn.microsoft.com contributor guides
- Post your question in the Learn support channel
xml/System/AggregateException.xml
Outdated
@@ -682,8 +682,8 @@ | |||
</ReturnValue> | |||
<Parameters /> | |||
<Docs> | |||
<summary>Returns the <see cref="T:System.AggregateException" /> that is the root cause of this exception.</summary> | |||
<returns>The <see cref="T:System.AggregateException" /> that is the root cause of this exception.</returns> | |||
<summary>Returns the <see cref="Exception"/> that is the root cause of this exception. This will either be the root exception, or the first <see cref="AggregateException"/> that contains either multiple inner exceptions or no inner exceptions at all.</summary> |
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.
Same comment as in dotnet/runtime#107743 (comment) : It is not clear what "root exception" means here.
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.
@jkotas how would you make this clearer?
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.
Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
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.
Related to dotnet/runtime#107743
Summary
Fixes an incorrect description of what method
GetBaseException()
does.