Skip to content

In from-string conversions, also honor IParsable<T> interface implementations, not just public static Parse methods #28222

Open

Description

Summary of the new feature / enhancement

A type that implements IParsable<TSelf> signals that an instance of it can be constructed from a string, by way of the interface's static Parse (or TryParse) method.

Currently, PowerShell seemingly only looks for a publicParse method directly on a type, irrespective of any interface implementations.

Thus:

  • if a type implements IParsable<TSelf> implicitly, it by definition has a public Parse method and PowerShell will use it.
  • However, it will not honor an explicitly implemented IParsable<TSelf>, due to the absence of a public Parse method directly on the type.

PowerShell should always honor the IParsable<TSelf> interface, given the express purpose of the interface, irrespective of whether a given type implements said interface implicitly or explicitly.


For instance, starting in .NET 11 System.Text.Rune implements IParsable<Rune> (as well as ISpanParsable<Rune>, but spans can't be used in PowerShell), but does so explicitly, i.e. the static Parse method isn't directly available on the type.

If PowerShell supported such implicit IParsable<TSelf> implementations, then the following, as requested in

# Currently FAILS, but would work in .NET 11+,
# once PowerShell also supports *explicit* IParsable<TSelf> implementations
[System.Text.Rune] '👍'

Proposed technical implementation details (optional)

No response

Activity

  1. changed the title [-]In from-string conversions, also honor explicitly implemented `IParsable<T>` interface implementation, not just public static `Parse` methods[/-] [+]In from-string conversions, also honor explicitly implemented `IParsable<T>` interface implementations, not just public static `Parse` methods[/+] on Oct 16, 2026
  2. GeeLaw commented on Oct 16, 2026

    @GeeLaw
  3. mklement0 commented on Oct 16, 2026

    @mklement0
    Author
  4. changed the title [-]In from-string conversions, also honor explicitly implemented `IParsable<T>` interface implementations, not just public static `Parse` methods[/-] [+]In from-string conversions, also honor explicit `IParsable<T>` interface implementations, not just public static `Parse` methods[/+] on Oct 16, 2026
  5. GeeLaw commented on Oct 16, 2026

    @GeeLaw
  6. changed the title [-]In from-string conversions, also honor explicit `IParsable<T>` interface implementations, not just public static `Parse` methods[/-] [+]In from-string conversions, also honor `IParsable<T>` interface implementations, not just public static `Parse` methods[/+] on Oct 16, 2026
  7. mklement0 commented on Oct 16, 2026

    @mklement0
    Author
  8. GeeLaw commented on Oct 16, 2026

    @GeeLaw
  9. mklement0 commented on Oct 16, 2026

    @mklement0
    Author
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

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-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