Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix commented Aug 31, 2025

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

Copilot AI review requested due to automatic review settings August 31, 2025 19:12
@StephaneDelcroix StephaneDelcroix requested a review from a team as a code owner August 31, 2025 19:12
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 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

@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/xsg/simplifyonplat branch from c4249ac to 02da791 Compare September 1, 2025 08:56
simonrozsival
simonrozsival previously approved these changes Sep 1, 2025
Copy link
Member

@simonrozsival simonrozsival left a comment

Choose a reason for hiding this comment

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

LGTM

@StephaneDelcroix StephaneDelcroix merged commit de13255 into net10.0 Sep 2, 2025
148 checks passed
@StephaneDelcroix StephaneDelcroix deleted the dev/stdelc/xsg/simplifyonplat branch September 2, 2025 11:15
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants