Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements OnPlatform simplification in the XAML source generator (XSG) when the target platform is known at build time. The change removes OnPlatform markup extensions and replaces them with the appropriate platform-specific values during compilation, which should resolve most remaining issues with XSG and OnPlatform handling.
- Extracts XmlType class to its own file and adds IsOfAnyType helper method
- Adds SimplifyOnPlatformVisitor to the source generation pipeline to replace OnPlatform with platform-specific values
- Updates test infrastructure to support target framework specification for testing platform-specific scenarios
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SourceGenXamlInitializeComponentTests.cs | Adds targetFramework parameter to RunGenerator method for testing platform-specific code generation |
| src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SimplifyOnPlatform.cs | New test file validating OnPlatform simplification behavior for Android target |
| src/Controls/src/Xaml/XmlType.cs | Extracted XmlType class with added IsOfAnyType helper method for type checking |
| src/Controls/src/Xaml/XamlNode.cs | Removes XmlType class definition (moved to separate file) |
| src/Controls/src/Xaml/SimplifyOnPlatformVisitor.cs | Updates visitor to use string literals instead of reflection and improves property matching |
| src/Controls/src/SourceGen/SourceGenContext.cs | Adds TargetPlatform property and modernizes collection initialization |
| src/Controls/src/SourceGen/NodeSGExtensions.cs | Removes duplicate IsOfAnyType method and uses XmlType.IsOfAnyType instead |
| src/Controls/src/SourceGen/InitializeComponentCodeWriter.cs | Integrates SimplifyOnPlatformVisitor into the source generation pipeline |
| src/Controls/src/SourceGen/Controls.SourceGen.csproj | Adds references to SimplifyOnPlatformVisitor and XmlType files |
| src/Controls/src/Build.Tasks/CompiledConverters/BindablePropertyConverter.cs | Updates to use XmlType.IsOfAnyType method and improves variable declarations |
src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SimplifyOnPlatform.cs
Show resolved
Hide resolved
c4249ac to
02da791
Compare
02da791 to
48f3134
Compare
PureWeen
approved these changes
Sep 1, 2025
mattleibow
approved these changes
Sep 1, 2025
jfversluis
approved these changes
Sep 2, 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.
Description of Change
when the target platform is known at build time (always, unless you use net standard), remove the OnPlatform by the actual value.
Issues Fixed
this should fix most of the remaining issues with XSG and OnPlat, but unfortunately we test that on netstandard. so an additional fix is required