Refactor XAML SourceGen TypeConverters#31467
Merged
StephaneDelcroix merged 13 commits intonet10.0from Sep 14, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
ISGTypeConverterinterface andTypeConverterRegistryfor managing converters - Breaks down the large
KnownTypeConvertersclass 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 |
src/Controls/src/SourceGen/TypeConverters/StrokeShapeConverter.cs
Outdated
Show resolved
Hide resolved
737ab59 to
6d7024d
Compare
Contributor
StephaneDelcroix
left a comment
There was a problem hiding this comment.
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.
6d7024d to
6940bb9
Compare
StephaneDelcroix
approved these changes
Sep 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.