Skip to content

Conversation

@jfversluis
Copy link
Member

@jfversluis jfversluis commented Sep 3, 2025

Moves the known TypeConverters to each their own file and class instead of a big bunch of methods.

Additionally optimizes the ColorTypeConverter to not just call Parse() but first try if we can produce more optimized code and some other minor things.

@jfversluis jfversluis added this to the .NET 10.0-rc2 milestone Sep 3, 2025
@jfversluis jfversluis added the area-xaml XAML, CSS, Triggers, Behaviors label Sep 3, 2025
Copilot AI review requested due to automatic review settings September 3, 2025 13:56
@jfversluis jfversluis requested a review from a team as a code owner September 3, 2025 13:56
@jfversluis jfversluis requested a review from Aguilex September 3, 2025 13:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the XAML source generation type converters by moving from a large monolithic KnownTypeConverters class with static methods to a cleaner, more maintainable architecture with individual converter classes implementing a common interface.

  • Introduces a new ISGTypeConverter interface and TypeConverterRegistry for managing converters
  • Breaks down the large KnownTypeConverters class into individual converter classes for each type
  • Updates the registration system to use the new registry-based approach with better organization

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
TypeConverterRegistry.cs New registry class that manages converter registration and lookup using a dictionary-based approach
ISGTypeConverter.cs New interface defining the contract for source generation type converters
Individual converter files Separate classes for each type converter (Color, Rect, Point, Thickness, etc.) implementing the new interface
SourceGenContextExtensions.cs Extension methods for diagnostic reporting functionality
NodeSGExtensions.cs Updated to use the new registry-based converter system
KnownTypeConverters.cs Removed the large monolithic converter class

@jfversluis jfversluis force-pushed the rework-sg-typeconverters branch from 737ab59 to 6d7024d Compare September 9, 2025 10:27
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to go as soon as it builds (see errors)

Renamed the ITypeConverter interface and its usages to ISGTypeConverter for clarity and consistency in source generator type converters. Updated references in BaseTypeConverter and TypeConverterRegistry accordingly.
@jfversluis jfversluis force-pushed the rework-sg-typeconverters branch from 6d7024d to 6940bb9 Compare September 12, 2025 08:28
@StephaneDelcroix StephaneDelcroix merged commit 782f48f into net10.0 Sep 14, 2025
148 checks passed
@StephaneDelcroix StephaneDelcroix deleted the rework-sg-typeconverters branch September 14, 2025 16:31
@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants