[XSG] Create AppThemeBinding using [UnsafeAccessor] in .NET 10#32728
Merged
StephaneDelcroix merged 3 commits intomainfrom Nov 19, 2025
Merged
Conversation
StephaneDelcroix
previously approved these changes
Nov 19, 2025
Contributor
StephaneDelcroix
left a comment
There was a problem hiding this comment.
let's limit the API surface once we open this
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses build errors in .NET 10 where AppThemeBinding is not public by introducing helper methods that use [UnsafeAccessor] with the new [UnsafeAccessorType] attribute to access the internal class. The solution is conditional and will be mostly reverted in .NET 11 when AppThemeBinding becomes public.
Key changes:
- Added
AppThemeBindingHelpersclass with conditional compilation for .NET 10 vs .NET 11 - Updated source generation code to call helper methods instead of directly instantiating
AppThemeBinding - Made
AppThemeBindingconditionally public in .NET 11
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Controls/src/SourceGen/XamlGenerator.cs |
Generates AppThemeBindingHelpers class with UnsafeAccessor methods for .NET 10 and direct instantiation for .NET 11 |
src/Controls/src/SourceGen/KnownMarkups.cs |
Updates ProvideValueForAppThemeBindingExtension to generate calls to helper methods instead of object initializer syntax |
src/Controls/tests/SourceGen.UnitTests/InitializeComponent/AppThemeBinding.cs |
Updates test expectations to use new helper method calls |
src/Controls/src/Core/AppThemeBinding.cs |
Adds conditional public modifier for .NET 11 with TODO comment |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Stephane Delcroix <stephane@delcroix.org>
StephaneDelcroix
approved these changes
Nov 19, 2025
Member
Author
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Copilot AI
added a commit
that referenced
this pull request
Dec 10, 2025
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Copilot AI
added a commit
that referenced
this pull request
Dec 10, 2025
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
PureWeen
added a commit
that referenced
this pull request
Dec 10, 2025
…eAccessor workaround for AppThemeBinding (#33101) * Revert "[XSG] Create AppThemeBinding using [UnsafeAccessor] in .NET 10 (#32728)" This reverts commit 489c654. * disable appthemebinding --------- Co-authored-by: Shane Neuville <shneuvil@microsoft.com> Co-authored-by: Stephane Delcroix <stephane@delcroix.org>
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
AppThemeBinding class is not public in .NET 10, so the source-generated code that instantiated it was causing build errors. To work around that, we can use
[UnsafeAccessor]with the new .NET 10 feature of[UnsafeAccessorType].In .NET 11, this change should be (mostly) reverted once AppThemeBinding is public (incl. changes to
PublicAPI.txt).Issues Fixed
Fixes #32665
Supersedes #32678