You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Async implementations of non-async interface methods are not properly reported as an issue.
Repro steps
Minimal reproduction code:
publicinterfaceITestReproduction{voidTestMethod();}publicclassTestReproduction:ITestReproduction{asyncvoidTestMethod()// FN: Not reported as an issue.{await Task.Delay(1000);}}
Expected behavior
The above code should report an issue with the async void implementation of the interface.
Actual behavior
Nothing is reported.
Known workarounds
Nothing.
Related information
C# 12
.NET 8.0
Rider 2024.3 with SonarLint 10.12.0.79769
Operating System Linux
The text was updated successfully, but these errors were encountered:
Hi @qhris!
This case is excluded because it cannot be fixed without changing the interface or making the method non-async. I will update rspec to clarify this.
Let me know if you need more clarification.
Seems a bit strange to me, the fix is pretty clear to me: make the method synchronous. @Tim-Pohlmann
The entire async void really needs to be reported regardless in my opinion.
It is a pretty nasty footgun which can bring down the entire application (and did in our case, by a segfault).
Async void methods have different error-handling semantics. When an exception is thrown out of an async Task or async Task method, that exception is captured and placed on the Task object. With async void methods, there is no Task object, so any exceptions thrown out of an async void method will be raised directly on the SynchronizationContext that was active when the async void method started.
Should this be a separate rule then? Catching stuff like this is what we want to use the sonar scanner for in the first place.
Description
Async implementations of non-async interface methods are not properly reported as an issue.
Repro steps
Minimal reproduction code:
Expected behavior
The above code should report an issue with the async void implementation of the interface.
Actual behavior
Nothing is reported.
Known workarounds
Nothing.
Related information
The text was updated successfully, but these errors were encountered: