Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

A few improvement/discussion points of the PSMethod -> Delegate conversion work #5618

Copy link
Copy link
@daxian-dbw

Description

@daxian-dbw
Issue body actions

This is about #5287

  • 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)
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.