-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Thanks for the analyzer! 🙂
We've been using the analyzer in several of our projects for a while now. We always disable the AsyncFixer01: "Unnecessary async/await usage" warning, because the fix elides methods from the stack trace when an exception is thrown.
For example:
async Task SaveItemAsync() {
throw new Exception();
}
async Task UpdateAndSaveAsync() {
//...
await SaveItemAsync();
}
Main() {
await UpdateAndSaveAsync();
}In this case the stack track will show like this:
Main()
UpdateAndSaveAsync()
SaveItemAsync()
If we take the AsyncFixer01 suggestion and change the code to this:
async Task SaveItemAsync() {
throw new Exception();
}
Task UpdateAndSaveAsync() {
//...
return SaveItemAsync();
}
Main() {
await UpdateAndSaveAsync();
}Then the stack track will not contain PrintAsync():
Main()
UpdateAndSaveAsync()
To me, this suggests that "unnecessarily" using await isn't an really an antipattern.
Would like to hear your thoughts. Thanks again for the analyzer 🙂
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels