S3168 error displayed on some events in c#


(Saintoyant) #1

Context: Visual studio 2017, C# up to date install

in a XAML control (Treeview) I define an event : ItemInvoked=“ArbreDesClefs_ItemInvoked”
in code behind I have:
private async void ArbreDesClefs_ItemInvoked(TreeView sender, TreeViewItemInvokedEventArgs args)

SonarLink displays an error suggesting to replace “void” by “Task” … which is not possible


(Valeri Hristov) #2

Hi @Pierresa,

The rule ignores event handlers that have the standard signature void OnEvent(object, EventArgs) but the TreeView.ItemInvoked event has different signature and we do not recognize it as an event handler… We have a ticket that tracks this problem and I added a reference to this thread in it.

To my regret the only advice I could give at this time is to mark the issues from this rule on the TreeView event handlers (and other event handlers on WPF controls that have non-standard signature) as False Positive.

Kind regards,
Valeri