Skip to content

Adopt Polyfill 9.24.0 span-based TryParse for float and decimal #420

@sliekens

Description

@sliekens

Polyfill 9.24.0 added 14 new polyfill methods for span-based and UTF-8 parsing of float and decimal values (native in .NET 8+, polyfilled for older TFMs).

New APIs

decimal.TryParse new overloads

  • TryParse(string? s, IFormatProvider? provider, out decimal result)
  • TryParse(ReadOnlySpan<char> s, out decimal result)
  • TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out decimal result)
  • TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out decimal result)
  • UTF-8 span variants: TryParse(ReadOnlySpan<byte> utf8Text, ...)

float / Single.TryParse new overloads

Identical set of overloads as decimal.

Relevance

GW2SDK uses float and decimal extensively for coordinates and prices, currently parsed via JSON deserialization. If any future parsing code needs to parse numeric values from spans (e.g., HTTP header values or raw byte buffers), these polyfilled overloads can avoid extra allocations on older TFMs.

Investigate whether any parsing code in the library could benefit from these overloads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions