AsyncFixer icon indicating copy to clipboard operation
AsyncFixer copied to clipboard

AsyncFixer03 raise errors with generic EventArgs

Open csharpmao opened this issue 11 months ago • 0 comments

We have an event

event EventHandler<CurrentItemChangedEventArgs<T>> CurrentItemChanged

and when registering an async void on this event, AsyncFixer03 raise an error.

I looked at your code and I found this method

public static bool HasEventArgsParameter(this MethodDeclarationSyntax method)
        {
            return method.ParameterList != null &&
                   method.ParameterList.Parameters.Any(param => param.Type.ToString().EndsWith("EventArgs", StringComparison.OrdinalIgnoreCase));
        }

Proposed fix

public static bool HasEventArgsParameter(this MethodDeclarationSyntax method)
        {
            return method.ParameterList != null &&
                   method.ParameterList.Parameters.Any(param => typeof(EventArgs).IsAssignableFrom(param.Type));
        }

csharpmao avatar Nov 20 '24 08:11 csharpmao