This product is not supported for your selected Datadog site. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

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: heston/DOCS-10466