CA1003 does not take the return value of an event handler into account #7373
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers
False_Positive
A diagnostic is reported for non-problematic case
help wanted
The issue is up-for-grabs, and can be claimed by commenting
Version Used: 17.10.0
Steps to Reproduce:
ResolveEventHandler
event handler (see sample code below).<AnalysisLevel>latest-all</AnalysisLevel>
.Diagnostic Id: CA1003: Change the event 'AssemblyResolve' to replace the type 'System.ResolveEventHandler?' with a generic EventHandler, for example EventHandler, where T is a valid EventArgs
Expected Behavior: CA1003 is not reported, because no generic EventHandler can replace the type 'System.ResolveEventHandler?'.
Actual Behavior: CA1003 is reported.
The definition of
System.ResolveEventHandler
is:This event handler returns a
Assembly?
value, but all variations ofEventHandler
(generic or not) don't return a value and therefore cannot be used.Possible solutions:
EventHandler<TEventArgs, TEventResult>
type to .NET.ResolveEventArgs
to add a new propertypublic Assembly? Result { get; set; }
and the set the return type tovoid
(this is a breaking change).The text was updated successfully, but these errors were encountered: