This page is not yet available in Spanish. We are working on its translation.
If you have any questions or feedback about our current translation project, feel free to reach out to us!

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

Integraciones sin problemas. Prueba Datadog Code Security

PREVIEWING: guacbot/translation-pipeline