Skip to content

Avoid Async Void

Michael Damatov edited this page Dec 31, 2019 · 5 revisions

Show a warning when async void is used inappropriately. The following table summarizes the analysis rules:

where usages found usages not found
public surface methods show warning show warning if not annotated with [UsedImplicitly]
non-public surface methods show warning if any non-direct event handler usage exists
inherited methods* show warning show warning

* overriding or implementing interface member

Quick Fixes

  • Use async Task for async void methods and local functions
  • Remove the async modifier for lambda and anonymous method expressions

Current Limitations

  • indirect event targets are not detected
  • Command pattern with the async "Execute" method is not (yet) detected

💡 The analyzer can be deactivated in the ReSharper Options dialog.