Skip to content
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

Refactor .Result to .GetAwaiter().GetResult() to preserve stacktrace #926

Merged
merged 1 commit into from
Oct 20, 2015
Merged

Refactor .Result to .GetAwaiter().GetResult() to preserve stacktrace #926

merged 1 commit into from
Oct 20, 2015

Conversation

veikkoeeva
Copy link
Contributor

The rational is explained at aspnet/Security#59.

"One last remark: you should avoid using Task.Result and Task.Wait as
much as possible as they always encapsulate the inner exception in an
AggregateException and replace the message by a generic one (One or
more errors occurred), which makes debugging harder. Even if the
synchronous version shouldn't be used that often, you should strongly
consider using Task.GetAwaiter().GetResult() instead."

This leaves aside another possibility to refactor, namely that of
making the interface method asynchronous.

The rational is explained at aspnet/Security#59.

"One last remark: you should avoid using Task.Result and Task.Wait as
much as possible as they always encapsulate the inner exception in an
AggregateException and replace the message by a generic one (One or
more errors occurred), which makes debugging harder. Even if the
synchronous version shouldn't be used that often, you should strongly
consider using Task.GetAwaiter().GetResult() instead."

This leaves aside another possibility to refactor, namely that of
making the interface method asynchronous.
sergeybykov added a commit that referenced this pull request Oct 20, 2015
Refactor .Result to .GetAwaiter().GetResult() to preserve stacktrace
@sergeybykov sergeybykov merged commit f223164 into dotnet:master Oct 20, 2015
@sergeybykov
Copy link
Contributor

Thank you, @veikkoeeva! This was an easy one. :-)

@veikkoeeva
Copy link
Contributor Author

@sergeybykov Yeah, and @dVakulen already rolled over that too. :) The #929 is a nice catch, I have even a faint memory of it being discussed in the beginning the era of Github. :)

@veikkoeeva veikkoeeva deleted the taskstacktracewithawaiter branch February 23, 2016 19:04
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants