This product is not supported for your selected Datadog site. ().
Metadata
ID:csharp-best-practices/task-suppress-throwing
Language: C#
Severity: Notice
Category: Best Practices
Description
This rule prohibits using ConfigureAwaitOptions.SuppressThrowing directly on instances of Task<T>. The SuppressThrowing option is intended to be applied only on non-generic Task objects. Applying it on Task<T> can lead to unexpected behavior or runtime issues because Task<T> handles exceptions differently.
To comply with this rule, explicitly cast Task<T> instances to Task before calling ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing). For example: ((Task)t).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);. This approach ensures the suppress throwing option is applied correctly without affecting the generic task’s exception handling.