Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Wrong warning for static events #28

Open
tom-englert opened this issue Mar 17, 2015 · 0 comments
Open

Wrong warning for static events #28

tom-englert opened this issue Mar 17, 2015 · 0 comments

Comments

@tom-englert
Copy link
Contributor

public class Test5
{
    public static event EventHandler SomeEvent;

    public static void RaiseTheEvent(object sender)
    {
        var eventHandler = SomeEvent;
        if (eventHandler != null)
        {
            eventHandler(sender, EventArgs.Empty);
        }
    }
}

Here we get this warning:
The Boolean condition eventHandler != null always evaluates to a constant value. If it (or its negation) appear in the source code....

If no event handler is attached to SomeEvent, it is null.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant