Detect unused return value
How can I configure the rules to show an error when return values are unused? This is to avoid forgetting to to await or checking results. I have searched the rules in C# settings but can't seem to find any to target this particular case.
client.PostAsync(...); // forgetting await
int.TryParse(s, out int i); // forgetting to check result
Please sign in to leave a comment.
Hello,
For the first option you can try to set the following setting to Error
Settings | Editor | Inspection Settings | Inspection Severity | C# → Async method invocation without await
For the second option, I'm afraid, the only option is to implement a custom Rosly Analyzer.