I have a Private Repo in Github and get a violations for the Rule
Generic event handlers should be used (csharpsquid:S3908)
- Languages .net 7
EmptyEventArgs derives from EventArgs.
Why this Violation occurs?
I have a Private Repo in Github and get a violations for the Rule
Generic event handlers should be used (csharpsquid:S3908)
Why this Violation occurs?
Hi @V-Kling, welcome to the community and thanks for reporting this issue.
I have been trying to reproduce locally this issue with a minimal but complete example, using the latest version of the scanner. However, I couldn’t raise the violation.
Following your example, I have defined an empty class EmtpyEventArgs
and used it like so:
class Repro_S3908
{
event EventHandler<EmptyEventArgs> NewConfigurationsLoaded; // <- This doesn't raise the issue
class EmptyEventArgs : EventArgs { }
}
What version of the Scanner for .NET are you using?
Would you confirm that you are running against SonarCloud?
If you are running against a SonarQube instance, what is the version of SonarQube?
Would you confirm that the EventHandler
class in your code correctly refers to System.EventHandler<TEventArgs>
?
Thanks,
Antonio
Thank you for the response:
we use SonarCloud with the SonarScanner 5.13.0
I can confirm that the Eventhandler
refers to class System.EventHandler<TEventArgs>
Hi @V-Kling
Apologies for the delay.
Thanks for the information provided. Unfortunately, I am still not able to reproduce the issue.
In order to make progress on the investigation, could you please either provide a compact self-contained reproducer for the issue?
Alternatively, could you please try the example I have given in my comment above, and tell me whether an issue is raised?
class Repro_S3908
{
event EventHandler<EmptyEventArgs> NewConfigurationsLoaded; // <- Does this line raise an issue?
class EmptyEventArgs : EventArgs { }
}
Thanks
Antonio