Do not use ConfigureAwaitOptions.SuppressThrowing with Task

このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください

Metadata

ID: csharp-best-practices/suppressthrowing

Language: C#

Severity: Notice

Category: Best Practices

Description

The SuppressThrowing option in ConfigureAwaitOptions can’t be used with Task<TResult>, as it may cause an invalid TResult to be returned. This rule detects such cases to ensure the issue is caught during compilation rather than during execution.

Non-Compliant Code Examples

Task<int> t = new Task<int>(() => 1);
t.ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);

Compliant Code Examples

Task<int> t = new Task<int>(() => 1);
((Task)t).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security

PREVIEWING: aleksandr.pasechnik/svls-6807-lambda-fips