public class TestClass
{
public event EventHandler<TestArgs>? TestEvent;
public void RegisterEventHandler(EventHandler<TestArgs> handler)
{
TestEvent += handler;
}
public TestClass()
{
TestEvent?.Invoke(this, new() {CorrelationId = 3});
}
}
public class TestArgs : EventArgs
{
public int CorrelationId { get; set; }
}
Hello @gabor-kovac,
thanks a lot for reporting this.
Indeed this issue should not be raised as the event is invoked later on in the code.
From my side, I cannot reproduce this.
Could you please tell me which version of MSBuild you use and give me the begin, build and end step commands that you are using?
Most probably the issue comes from automatic analysis, which has less precision than CI-based analysis.
You should be probably getting this warning as well:
Ideally, to get the best results you should set-up CI based analysis (see docs),
We are working continuously on improving automatic analysis, but it is still fairly new, and for now, there is a tradeoff between ease of use and quality of diagnostics.