JetBrains Rider
 
2021.3
Get JetBrains Rider
You are viewing the documentation for an earlier version of JetBrains Rider.

Code Inspection: Missing '.ConfigureAwait(false)' in library code

Last modified: 07 April 2022

This inspection suggests adding ConfigureAwait(false) calls to awaitables in the scope where ConfigureAwait analysis is enabled in the Library mode.

The way ConfigureAwait() calls work and their usage scenarios are explained in detail in this Microsoft .NET Blog article as well as in many other posts that you can find on the Internet, but the usage advice for ConfigureAwait() boils down to the following:

  • To improve performance and avoid potential deadlocks, use ConfigureAwait(false) in any non-UI code.

  • ConfigureAwait(true) corresponds to the default behavior and does nothing meaningful, therefore such calls can be safely omitted.

To analyze usages of ConfigureAwait(), JetBrains Rider needs to know whether it is application-level code or general-purpose library code. By default, the ConfigureAwait analysis is disabled and you need to enable the analysis in each project choosing one of the two modes:

  • Library mode — JetBrains Rider will suggest adding ConfigureAwait(false) calls to awaitables.

  • UI mode — JetBrains Rider will report ConfigureAwait(true) calls as redundant.