Skip to content

AsyncFixer03 raise errors with generic EventArgs #39

@csharpmao

Description

@csharpmao

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));
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions