dotnet / roslynator

Roslynator is a set of code analysis tools for C#, powered by Roslyn.

Home Page:https://josefpihrt.github.io/docs/roslynator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RCS1159 should not be reported for WPF routed events

nvmkpk opened this issue · comments

Product and Version Used:

Steps to Reproduce:

Have the below code in a WPF project:

using System.Windows;
using System.Windows.Controls;

namespace WpfApp1

public class Control1 : Control
{
    public static readonly RoutedEvent MyRoutedEvent = EventManager.RegisterRoutedEvent("MyRouted", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Control1));

    protected void OnMyRoutedEvent()
    {
        this.RaiseEvent(new(MyRoutedEvent, this));
    }

    public event RoutedEventHandler MyRouted // <-- RCS1159 is reported
    {
        add => this.AddHandler(MyRoutedEvent, value);
        remove => this.RemoveHandler(MyRoutedEvent, value);
    }
}

Actual Behavior:
RCS1159 is reported in above indicated line and changes RoutedEventHandler to EventHandler<RoutedEventArgs>.

Expected Behavior:
RCS1159 is not reported.

This is also reported in interface implementations. Specifically INotifyCollectionChanged.

@nvmkpk Please file a new issue.