- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.9k
Refactor XAML SourceGen TypeConverters #31467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 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
  
    There was a problem hiding this 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.
6d7024d    to
    6940bb9      
    Compare
  
    
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.