Skip to content

Add Version Span-based APIs #22815

@stephentoub

Description

@stephentoub

Separated out of https://github.com/dotnet/corefx/issues/21281 for tracking purposes.

  • Implement in System.Private.CoreLib in coreclr (corert shares the same files)
  • Expose from System.Runtime contract in corefx
  • Add tests to System.Runtime tests in corefx
namespace System
{
    public class Version
    {
        public static Version Parse(ReadOnlySpan<char> input);
        public static bool TryParse(ReadOnlySpan<char> input, out Version result);
        public bool TryFormat(Span<char> destination, out int charsWritten, int fieldCount = 4);}
}

EDIT 8/17/2017:
We'd approved:

public bool TryFormat(Span<char> destination, out int charsWritten, int fieldCount = 4);

as a way to avoid needing to add two TryFormat overloads based on whether it takes a fieldCount or not, but it turns out that deviates from the ToString()/ToString(fieldCount) behavior, where the former doesn't always use fieldCount == 4 but rather dynamically determines the value based on the instance, so we should add both:

public bool TryFormat(Span<char> destination, out int charsWritten);
public bool TryFormat(Span<char> destination, int fieldCount, out int charsWritten);

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions