Find non-awaited async method calls

前端 未结 5 1428
无人及你
无人及你 2020-12-24 11:36

I\'ve just stumbled across a rather dangerous scenario while migrating an ASP.NET application to the async/await model.

The situation is that I made a method async:

5条回答
  •  再見小時候
    2020-12-24 12:19

    You can add a specific warning in VS Project properties as one that throws a compilation error, like described here

    You can add a semi-colon separated list of warning codes e.g. CS4014, and the compiler will fail to compile if you're not awaiting an async method.

    Here's a screenshot with VS2017: VS2017 configuration to throw compiler errors for warning CS4014

提交回复
热议问题