Skip to content

don't optimise AppThemeBinding on XSG: Revert PR #32728: Remove UnsafeAccessor workaround for AppThemeBinding#33101

Merged
PureWeen merged 2 commits intorelease/10.0.1xx-sr2from
copilot/revert-pr-32728
Dec 10, 2025
Merged

don't optimise AppThemeBinding on XSG: Revert PR #32728: Remove UnsafeAccessor workaround for AppThemeBinding#33101
PureWeen merged 2 commits intorelease/10.0.1xx-sr2from
copilot/revert-pr-32728

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

This PR reverts the XSG optimization for AppThemeBinding introduced in PR #32728, and defers making AppThemeBinding public to .NET 11.

Changes:

  1. Reverted PR [XSG] Create AppThemeBinding using [UnsafeAccessor] in .NET 10 #32728 - Removed the UnsafeAccessor workaround for AppThemeBinding in source-generated code
  2. Deferred public API to .NET 11 - Made AppThemeBinding public only for NET11_0_OR_GREATER using a conditional compilation directive
  3. Disabled AppThemeBinding tests for .NET 10 - The source gen unit tests for AppThemeBinding are now wrapped with #if NET11_0_OR_GREATER to skip them until .NET 11

Key files modified:

  • src/Controls/src/Core/AppThemeBinding.cs - Added #if NET11_0_OR_GREATER conditional to make class public only in .NET 11+
  • src/Controls/tests/SourceGen.UnitTests/InitializeComponent/AppThemeBinding.cs - Wrapped entire test class in #if NET11_0_OR_GREATER

Result: For .NET 10, AppThemeBinding remains internal and the XSG optimization is disabled. In .NET 11+, AppThemeBinding will be public and the optimization will be enabled.

Issues Fixed

Reverts #32728 for .NET 10 release branch.

Copilot AI changed the title [WIP] Revert changes from PR #32728 Revert PR #32728: Remove UnsafeAccessor workaround for AppThemeBinding Dec 10, 2025
Copilot AI requested a review from PureWeen December 10, 2025 15:51
@PureWeen PureWeen force-pushed the copilot/revert-pr-32728 branch from 6ad4970 to 67378dc Compare December 10, 2025 16:57
@PureWeen PureWeen marked this pull request as ready for review December 10, 2025 16:57
Copilot AI review requested due to automatic review settings December 10, 2025 16:58
@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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 reverts PR #32728 by removing the UnsafeAccessor workaround and making AppThemeBinding public instead. The change simplifies source-generated code by replacing helper method calls with standard object initializer syntax.

Key changes:

  • Removes 170-line AppThemeBindingHelpers class from source generator
  • Updates KnownMarkups.cs to generate object initializer syntax instead of helper method calls
  • Updates test expectations to match new generated code format

Reviewed changes

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

File Description
src/Controls/src/Core/AppThemeBinding.cs Makes AppThemeBinding class and AppThemeResource constant public (though missing public keyword - see critical issue)
src/Controls/src/SourceGen/XamlGenerator.cs Removes entire AppThemeBindingHelpers helper class generation
src/Controls/src/SourceGen/KnownMarkups.cs Replaces helper method logic with object initializer generation
src/Controls/tests/SourceGen.UnitTests/InitializeComponent/AppThemeBinding.cs Updates test expectations to match new object initializer syntax

@StephaneDelcroix StephaneDelcroix changed the title Revert PR #32728: Remove UnsafeAccessor workaround for AppThemeBinding don't optimise AppThemeBinding on XSG: Revert PR #32728: Remove UnsafeAccessor workaround for AppThemeBinding Dec 10, 2025
@StephaneDelcroix StephaneDelcroix added this to the .NET 10.0 SR2 milestone Dec 10, 2025
@PureWeen
Copy link
Member

  • failing tests are unrelated to this PR and are more related to infra

@PureWeen PureWeen merged commit 775b7f1 into release/10.0.1xx-sr2 Dec 10, 2025
143 of 159 checks passed
@PureWeen PureWeen deleted the copilot/revert-pr-32728 branch December 10, 2025 22:56
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Dec 18, 2025
Copilot AI added a commit that referenced this pull request Dec 18, 2025
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Copilot AI added a commit that referenced this pull request Dec 18, 2025
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
PureWeen added a commit that referenced this pull request Dec 22, 2025
- [x] Apply changes from PR #33101 to AppThemeBinding.cs (make class
public for NET11+, make AppThemeResource public)
- [x] Apply changes from PR #33101 to KnownMarkups.cs (replace helper
methods with object initializers)
- [x] Apply changes from PR #33101 to XamlGenerator.cs (remove
AppThemeBindingHelpers generation)
- [x] Apply changes from PR #33101 to test file (wrap with
NET11_0_OR_GREATER)
- [x] Apply changes from PR #33107 to KnownMarkups.cs (wrap method with
NET11_0_OR_GREATER)
- [x] Apply changes from PR #33107 to NodeSGExtensions.cs (wrap
dictionary entry with NET11_0_OR_GREATER)
- [x] Verify changes compile successfully
- [x] Run relevant tests to ensure functionality (123 SourceGen tests
passed, 34 AppTheme XAML tests passed)
- [x] Code review completed (no issues found)
- [x] Security scan completed (no vulnerabilities found)
- [x] Remove unrelated HybridWebView.js.map file (per review feedback)

<!-- START COPILOT CODING AGENT SUFFIX -->



<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> Please apply the changes from
#33101 and
#33107 to the main branch


</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/dotnet/maui/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
StephaneDelcroix pushed a commit that referenced this pull request Jan 5, 2026
- [x] Apply changes from PR #33101 to AppThemeBinding.cs (make class
public for NET11+, make AppThemeResource public)
- [x] Apply changes from PR #33101 to KnownMarkups.cs (replace helper
methods with object initializers)
- [x] Apply changes from PR #33101 to XamlGenerator.cs (remove
AppThemeBindingHelpers generation)
- [x] Apply changes from PR #33101 to test file (wrap with
NET11_0_OR_GREATER)
- [x] Apply changes from PR #33107 to KnownMarkups.cs (wrap method with
NET11_0_OR_GREATER)
- [x] Apply changes from PR #33107 to NodeSGExtensions.cs (wrap
dictionary entry with NET11_0_OR_GREATER)
- [x] Verify changes compile successfully
- [x] Run relevant tests to ensure functionality (123 SourceGen tests
passed, 34 AppTheme XAML tests passed)
- [x] Code review completed (no issues found)
- [x] Security scan completed (no vulnerabilities found)
- [x] Remove unrelated HybridWebView.js.map file (per review feedback)

<!-- START COPILOT CODING AGENT SUFFIX -->



<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> Please apply the changes from
#33101 and
#33107 to the main branch


</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/dotnet/maui/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2026
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.

4 participants