Skip to content

[API Proposal]: Implement ISpanParsable on System.Version #125026

Description

@Rob-Hague

Background and motivation

System.Version implements IUtf8SpanParsable, but not ISpanParsable (nor IParsable). It seems reasonable to add (explicit) implementations.

API Proposal

namespace System;

public class Version :
    ICloneable,
    IComparable,
    IComparable<Version?>,
    IEquatable<Version?>,
    ISpanFormattable,
    IUtf8SpanFormattable,
    IUtf8SpanParsable<Version>,
+   ISpanParsable<Version>
{
    public static Version Parse(string input);
+   static Version IParsable.Parse(string s, IFormatProvider? provider);

    public static Version Parse(ReadOnlySpan<char> input);
+   static Version ISpanParsable.Parse(ReadOnlySpan<char> s, IFormatProvider? provider);

    public static Version Parse(ReadOnlySpan<byte> utf8Text);
    static Version IUtf8SpanParsable<Version>.Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider);

    public static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out Version? result);
+   static bool IParsable.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [NotNullWhen(true)] out Version? result);

    public static bool TryParse(ReadOnlySpan<char> input, [NotNullWhen(true)] out Version? result);
+   static bool ISpanParsable.TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [NotNullWhen(true)] out Version? result);

    public static bool TryParse(ReadOnlySpan<byte> utf8Text, [NotNullWhen(true)] out Version? result);
    static bool IUtf8SpanParsable<Version>.TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, [NotNullWhen(true)] out Version? result);
}

API Usage

Alternative Designs

No response

Risks

No response

Activity

  1. added
    api-suggestion
    on Mar 1, 2026
  2. added
    untriaged
    on Mar 1, 2026
  3. dotnet-policy-service commented on Mar 1, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-memory
    See info in area-owners.md if you want to be subscribed.

  4. added this to the Future milestone on Mar 8, 2026
  5. added
    api-ready-for-review
    and removed
    api-suggestion
    untriaged
    on Mar 21, 2026
  6. self-assigned this
    on Mar 23, 2026
  7. removed their assignment
    on Apr 27, 2026
  8. bartonjs commented on Sep 1, 2026

    @bartonjs
    Member

    Video

    Looks good as proposed

    namespace System;
    
    public class Version :
        ICloneable,
        IComparable,
        IComparable<Version?>,
        IEquatable<Version?>,
        ISpanFormattable,
        IUtf8SpanFormattable,
        IUtf8SpanParsable<Version>,
    +   ISpanParsable<Version>
    {
        public static Version Parse(string input);
    +   static Version IParsable.Parse(string s, IFormatProvider? provider);
    
        public static Version Parse(ReadOnlySpan<char> input);
    +   static Version ISpanParsable.Parse(ReadOnlySpan<char> s, IFormatProvider? provider);
    
        public static Version Parse(ReadOnlySpan<byte> utf8Text);
        static Version IUtf8SpanParsable<Version>.Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider);
    
        public static bool TryParse([NotNullWhen(true)] string? input, [NotNullWhen(true)] out Version? result);
    +   static bool IParsable.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [NotNullWhen(true)] out Version? result);
    
        public static bool TryParse(ReadOnlySpan<char> input, [NotNullWhen(true)] out Version? result);
    +   static bool ISpanParsable.TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, [NotNullWhen(true)] out Version? result);
    
        public static bool TryParse(ReadOnlySpan<byte> utf8Text, [NotNullWhen(true)] out Version? result);
        static bool IUtf8SpanParsable<Version>.TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, [NotNullWhen(true)] out Version? result);
    }
  9. added
    api-approved
    and removed
    api-ready-for-review
    on Sep 1, 2026
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

    api-approvedarea-System.Memory

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions