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 Dec 10, 2025
Conversation
Copilot
AI
changed the title
[WIP] Revert changes from PR #32728
Revert PR #32728: Remove UnsafeAccessor workaround for AppThemeBinding
Dec 10, 2025
6ad4970 to
67378dc
Compare
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
There was a problem hiding this comment.
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
AppThemeBindingHelpersclass from source generator - Updates
KnownMarkups.csto 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
approved these changes
Dec 10, 2025
Member
|
11 tasks
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>
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.
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
AppThemeBindingintroduced in PR #32728, and defers makingAppThemeBindingpublic to .NET 11.Changes:
UnsafeAccessorworkaround forAppThemeBindingin source-generated codeAppThemeBindingpublic only forNET11_0_OR_GREATERusing a conditional compilation directiveAppThemeBindingare now wrapped with#if NET11_0_OR_GREATERto skip them until .NET 11Key files modified:
src/Controls/src/Core/AppThemeBinding.cs- Added#if NET11_0_OR_GREATERconditional 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_GREATERResult: For .NET 10,
AppThemeBindingremains internal and the XSG optimization is disabled. In .NET 11+,AppThemeBindingwill be public and the optimization will be enabled.Issues Fixed
Reverts #32728 for .NET 10 release branch.