rspec/rules/S4586/why-dotnet.adoc
Martin Strecker f95d517a7c
Modify rule S4586: LaYC format (#2155)
Update rule content and descriptions to LaYC format.
https://sonarsource.github.io/rspec/#/rspec/S4586

## Review

A dedicated reviewer checked the rule description successfully for:

- [ ] logical errors and incorrect information
- [ ] information gaps and missing content
- [ ] text style and tone
- [ ] PR summary and labels follow [the
guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
2023-06-15 15:08:57 +02:00

2 lines
504 B
Plaintext

Returning `{keyword_null}` from a non-`{keyword_async}` `Task`/`Task{typeparameter_TResult}` {concept_method} will cause a `NullReferenceException` at runtime if the {concept_method} is awaited. This problem can be avoided by returning https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.completedtask[`Task.CompletedTask`] or https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.fromresult[`Task.FromResult{typeparameter_TResult}({keyword_null})`] respectively.