Closed ryanachten closed 1 month ago
Hey there,
I am afraid this is not possible.
The problem is that it is virtually impossible to separate non-event handling OnXXX
methods to event-handler ones.
To do that, we would need to traverse the call graph with our Symbolic Execution engine which would really affect performance.
For now we only go method by method.
We made the choice to exclude OnXXX
methods, as they are usually event handler callbacks, and False Negatives are better (less noisy/annoying) than False Positives.
Description
We've found that the current rule for S3168 doesn't reliably report issues for async/void usage. This appears to be due to excluding method names that start with "On" on the assumption that these refer to event handler delegates as per Microsoft guidance.
The issue is, there are many scenarios where "On" is used as a prefix in methods unrelated to event delegates, and in these scenarios the SonarQube rule fails to report such code issues. To this end, I have the following questions:
Repro steps
Create an async void method with an "On" prefix. See Actual behavior below for an example.
Expected behavior
Given a method unrelated to an event handler delegate, an S3168 rule violation should be raised:
Actual behavior
Given a method unrelated to an event handler delegate, an S3168 rule violation is not raised:
Known workarounds
Related information