Events should be invoked

SonarQube 8.8, csharpsquid:S3264 Events should be invoked
Bubbling a event is raising a false-positive

Failing example

    public class MiddleClass
    {
        public event EventHandler Logging;

        public void RunTest()
        {
            EventTestBase eventTestBase = new EventTestBase();
            eventTestBase.Logging += Logging;
            eventTestBase.RunSomethingThatSendAnEvent();
        }
    }

Not failing alternative

    public class MiddleClass
    {
        public event EventHandler Logging;

        public void RunTest()
        {
            EventTestBase eventTestBase = new EventTestBase();
            eventTestBase.Logging += (s, e) => Logging(s, e);
            eventTestBase.RunSomethingThatSendAnEvent();
        }
    }
1 Like

Hi @mmu69,

thanks for your feedback. I’ve created an issue on sonar-dotnet and you can follow the progress here: Rule S3264: FP when using += · Issue #4276 · SonarSource/sonar-dotnet · GitHub

Best,
Costin

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.