Altinn / app-template-dotnet

Altinn Studio application template
BSD 3-Clause "New" or "Revised" License
2 stars 8 forks source link

Disable warning for no awaits in async method #175

Open ivarne opened 1 year ago

ivarne commented 1 year ago

The warning CS1988 is confusing when you implement an interface that requires a Task return value as in IDataProcessor. The message and suggestion to make the method synchronous or use await Task.Run(...) is just plain wrong (for the case when you implement an interface that requires a Task return value).

image

The solution typically is to write await Task.CompletedTask; just to "await something" to ignore the warning, or remove the async keyword and return Task.FromResult(true). None of these "solutions" to the warning is actually improves performance or readability.

This PR proposes to disable this warning for apps, so that app developers can have warning free apps and consistent code whether they call an async api in their events or not.

Verification

Documentation