You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DelegateArgsComparator.ParameterTypesMatches doesn't consider the Variance in delegate parameter types. A method signature int CallMe(object input) should be able to be converted to Func<string, int>.
PSMethod.MatchesPSMethodProjectedType doesn't handle the case where both targetType and projectedSourceType are the same ByRef type or Pointer type.
I think the 'Unit' type name should be changed to 'VOID'. Use type Unit to represent void is not intuitive and I misread it to uint when first looking at the code.
I don't get the point of having ReplaceGenericTypeArgumentsWithMarkerTypes. After making a generic method using our synthetic reference/value types, the generated MethodInfo signature won't match any real delegates except in one condition -- the original generic method doesn't use the generic type argument for any of its parameters or return type -- I think it's rare for this condition to be met for a generic method.
I agree that we need pseudo types to represent ByRef type (ref/out), Pointer type void type and even TypeReference, but why do we need PSEnum<> to wrap enum types? Remove PSEnum<> and use the enum type directly.
Handle method signatures with Span<T> or ReadOnlySpan<T> as its parameter type or return type. They cannot be used as type argument, and therefore we cannot use them directly to construct a generic type of Func<>. In fact, this is a more general problem with all ref-like types, such as public ref struct Foo { private Span<int> _pointer }. It would be great if we can have a generic solution for all ref-like types, but at least we need to handle Span<T> and ReadOnlySpan<T> as they are getting more and more usage. See the discussion comments: Further improve PSMethod to Delegate conversion #6851 (comment)
This is about #5287
DelegateArgsComparator.ParameterTypesMatchesdoesn't consider the Variance in delegate parameter types. A method signatureint CallMe(object input)should be able to be converted toFunc<string, int>.PSMethod.MatchesPSMethodProjectedTypedoesn't handle the case where bothtargetTypeandprojectedSourceTypeare the sameByReftype orPointertype.Unitto representvoidis not intuitive and I misread it touintwhen first looking at the code.ReplaceGenericTypeArgumentsWithMarkerTypes. After making a generic method using our synthetic reference/value types, the generatedMethodInfosignature won't match any real delegates except in one condition -- the original generic method doesn't use the generic type argument for any of its parameters or return type -- I think it's rare for this condition to be met for a generic method.ByReftype (ref/out),Pointertypevoidtype and evenTypeReference, but why do we needPSEnum<>to wrap enum types? RemovePSEnum<>and use the enum type directly.Span<T>orReadOnlySpan<T>as its parameter type or return type. They cannot be used as type argument, and therefore we cannot use them directly to construct a generic type ofFunc<>. In fact, this is a more general problem with all ref-like types, such aspublic ref struct Foo { private Span<int> _pointer }. It would be great if we can have a generic solution for all ref-like types, but at least we need to handleSpan<T>andReadOnlySpan<T>as they are getting more and more usage. See the discussion comments: Further improve PSMethod to Delegate conversion #6851 (comment)