Meziantou.Analyzer icon indicating copy to clipboard operation
Meziantou.Analyzer copied to clipboard

Interest in a ReturnTaskDirectlyAnalyzer?

Open CollinAlpert opened this issue 2 years ago • 1 comments

Hi, I made an analyzer which detects instances of a Task which can be returned directly: https://github.com/CollinAlpert/ReturnTaskDirectlyAnalyzer

I'd love more people to use it and was wondering if you'd be interested in me opening a PR adding it to this package.

CollinAlpert avatar Sep 22 '22 15:09 CollinAlpert

Hi, you can submit a PR with the rule to remove await when this is not needed.

  • You can add a new id in RuleIdentifiers.cs
  • Don't forget to generate the documentation file using the DocumentationGenerator project

Removing await changes the behavior of methods (exception handling, debugging, and surely other things), but it improves the performance. I think it is ok to set the analyzer level to Info.

meziantou avatar Sep 22 '22 18:09 meziantou

Note that we used to have this rule in our code and have scaled back on it (we still use it in some places).

The problem with this is that it really kills the reconstructed callstack in cases of errors, which makes it close to impossible to track where the code was called for.

ShaharPrishMSFT avatar Nov 17 '22 14:11 ShaharPrishMSFT

That's interesting. I know this pattern changes behavior, however I never had the problem of an unreadable stack trace due to this. There were always plenty of other async methods which did show up.

CollinAlpert avatar Nov 17 '22 14:11 CollinAlpert

That's interesting. I know this pattern changes behavior, however I never had the problem of an unreadable attack trace due to this. There were always plenty of other async methods which did show up.

CollinAlpert avatar Nov 17 '22 14:11 CollinAlpert

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] avatar Sep 20 '23 01:09 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Oct 04 '23 01:10 github-actions[bot]