Skip to content

Improve public Parse/ToString APIs of our primitive types #16390

Open
@maxkatz6

Description

@maxkatz6

Is your feature request related to a problem? Please describe.

Primitive types:

  • Color, HslColor, HsvColor
  • CornerRadius, Thickness
  • Point, Size
  • Vector, Vector3D
  • GridLength
  • RelativeScalar, RelativePoint, RelativeRect
  • PixelPoint, PixelSize, PixelRect
  • Cue

Enum-like types that should at least have IParsable only:

  • Easing
  • Cursor
  • TextTrimming
  • TextDecorationCollection
  • ThemeVariant
  • WindowTransparencyLevel

Other:

  • BoxShadow, BoxShadows, Effect
  • Matrix
  • KeySpline?

Not primitives, but can be revisited as well:

  • StreamGeometry, Geometry,
  • TransformOperations, Transform

Describe the solution you'd like

  1. [Must] StringTokenizer needs to use ReadOnlySpan<char> and ideally be a "ref struct" (breaking change? for some reason this class is not internal).
  2. [Must] All primitive types have to implement IParsable and IFormattable.
  3. [Should] Primitive types should implement ISpanParsable and ISpanFormattable.
  4. [Should] All primitive parsting/formatting should respect culture info and culture specific separators. WPF does this already.
  5. [Should] Make devtools use new TryParse methods.
  6. [Optional] Primitive types should have TypeConverter registered on them. WPF and MAUI do that, but we gave up on the half-way - primarily because we don't really use them, and instead parse compile-time everything, which is better by itself.

Describe alternatives you've considered

No response

Additional context

Related #16389

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions