{
Type pType = infos[i].ParameterType;
+ Type? argType = args[i]?.GetType();
+
// Checking to see if the Parameter types (from the Event method) match the supplied argument types.
- // Fail if one of two things hold : either the argument type is not equal to the parameter type, or the
- // argument is null and the parameter type is non-nullable.
- if ((args[i] != null && (args[i]!.GetType() != pType)) // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
- || (args[i] == null && (!(pType.IsGenericType && pType.GetGenericTypeDefinition() == typeof(Nullable<>))))
- )
+ // Fail if one of two things hold : either the argument type is not equal or assignable to the parameter type, or the
+ // argument is null and the parameter type is a non-Nullable<T> value type.
+ if ((args[i] != null && !pType.IsAssignableFrom(argType))
+ || (args[i] == null && !((pType.IsGenericType && pType.GetGenericTypeDefinition() == typeof(Nullable<>)) || !pType.IsValueType)))
{
typesMatch = false;
break;