Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
Microsoft docsDescription
The System.Threading.Tasks.ConfigureAwaitOptions.SuppressThrowing option isn't supported by the generic System.Threading.Tasks.Task1, since that might lead to returning an invalid TResult. This rule flags the use of System.Threading.Tasks.ConfigureAwaitOptions.SuppressThrowing with System.Threading.Tasks.Task1 to surface the error at build time rather than runtime.
Cause
A value of System.Threading.Tasks.ConfigureAwaitOptions.SuppressThrowing is passed to System.Threading.Tasks.Task`1.ConfigureAwait(System.Threading.Tasks.ConfigureAwaitOptions).
How to fix violations
Cast the System.Threading.Tasks.Task1 to a non-generic System.Threading.Tasks.Task before calling System.Threading.Tasks.Task1.ConfigureAwait(System.Threading.Tasks.ConfigureAwaitOptions).
Example
Task<int> t = new Task<int>(() => 1);
t.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
Task<int> t = new Task<int>(() => 1);
((Task)t).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);When to suppress
You shouldn't suppress warnings from this rule. If the task is faulted or canceled, TResult will be invalid and cause runtime errors.