Skip to content

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

Description

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)

Activity

  1. daxian-dbw commented on Dec 4, 2017

    @daxian-dbw
    MemberAuthor

    Staffan Gustafsson (@powercode) I captured some discussion points from #5287 here. Hope we can continue the discussion when you have time.

  2. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  3. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  4. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

  6. powercode commented on Mar 22, 2024

    @powercode
    Collaborator

    Keep alive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions