Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with CC0091 (static method) and event handling methods #934

Open
giggio opened this issue Jun 13, 2017 · 1 comment
Open

Deal with CC0091 (static method) and event handling methods #934

giggio opened this issue Jun 13, 2017 · 1 comment

Comments

@giggio
Copy link
Member

giggio commented Jun 13, 2017

Discussion started on #916.

If we have this in UWP and XAML:

<Button Click="ButtonBase_OnClick" />

And in the code behind:

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
}

We cannot make this method static, or the event handling will fail. We should not report CC0091 in this scenario.

The way to fix this is alter the analyzer, which already checks method declarations, to ignore them if a signature with two parameters is found, where the first is of type object, and the second is a class that inherits from EventArgs, and the return is void or Task (or a descendant of Task).

@Thieum
Copy link
Contributor

Thieum commented Oct 11, 2017

Same goes for Winforms - the code will compile with static methods, but everytime you go in the designer, the lines of designer codes using the static methods will be deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants