codeanalyzers icon indicating copy to clipboard operation
codeanalyzers copied to clipboard

Inevitable U2U1009

Open wmjordan opened this issue 1 year ago • 0 comments

The following code triggers U2U1009 on ButtonClicked, however it is inevitable since the async method is an event handler.

using System;
using System.Windows.Controls;

class C {
   public C() {
       var b = new Button();
       b.Click += ButtonClicked;
   }

   async void ButtonClicked(object sender, EventArgs args) {
       if (DateTime.Today.Month != 1) {
           return;
       }
       await AnAsyncMethod();
   }
}

wmjordan avatar May 04 '23 01:05 wmjordan