Skip to content

[XSG] Make AppThemeBinding class public in net11#32678

Closed
StephaneDelcroix wants to merge 3 commits intomainfrom
fix-appthemebinding-accessibility
Closed

[XSG] Make AppThemeBinding class public in net11#32678
StephaneDelcroix wants to merge 3 commits intomainfrom
fix-appthemebinding-accessibility

Conversation

@StephaneDelcroix
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix commented Nov 17, 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

Makes the AppThemeBinding class public to fix accessibility issues with XamlSourceGenerator.

WARNING: THIS CONTAINS A NEW API in net11

Issues Fixed

Fixes #32665

Background

When XamlSourceGenerator is enabled, it generates code that needs to instantiate AppThemeBinding. However, the class was marked as internal, causing compilation errors:

'AppThemeBinding' is inaccessible due to its protection level

Changes

  • Changed AppThemeBinding class from internal to public
  • Updated all PublicAPI.Unshipped.txt files for all platforms to include the newly public API surface:
    • Class declaration
    • Constructor
    • Properties: Light, Dark, Default
    • Constant: AppThemeResource

Testing

  • Built Controls.Core.csproj successfully with no PublicAPI analyzer errors
  • Verified all PublicAPI.Unshipped.txt files are correctly updated

Copilot AI review requested due to automatic review settings November 17, 2025 16:49
@StephaneDelcroix StephaneDelcroix added area-xaml XAML, CSS, Triggers, Behaviors xsg Xaml sourceGen labels Nov 17, 2025
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 makes the AppThemeBinding class public to resolve XamlSourceGenerator accessibility issues. When XamlSourceGenerator is enabled, it needs to instantiate AppThemeBinding, but the class was marked as internal, causing compilation errors.

Key Changes:

  • Changed AppThemeBinding class access modifier from internal to public
  • Updated PublicAPI.Unshipped.txt files across all platform targets to reflect the newly public API surface

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Controls/src/Core/AppThemeBinding.cs Changed class access modifier from internal to public
src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt Added public API declarations for netstandard target
src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt Added public API declarations for net target
src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt Added public API declarations for net-windows target
src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Added public API declarations for net-tizen target
src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Added public API declarations for net-maccatalyst target
src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt Added public API declarations for net-ios target
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt Added public API declarations for net-android target

Fixes #32665

The AppThemeBinding class needs to be public for XamlSourceGenerator to
access it when generating code. This change makes the class and its
constructor public, along with updating all PublicAPI.Unshipped.txt files.
@StephaneDelcroix StephaneDelcroix force-pushed the fix-appthemebinding-accessibility branch from d8aeb9c to 1b29160 Compare November 18, 2025 11:51
@StephaneDelcroix StephaneDelcroix changed the title Make AppThemeBinding class public [XSG] Make AppThemeBinding class public in net11 Nov 18, 2025
- Move AppThemeBinding from Microsoft.Maui.Controls to Microsoft.Maui.Controls.Internals namespace
- Add conditional visibility: public in NET11+, internal before NET11
- SourceGen only registers AppThemeBindingExtension under NET11_0_OR_GREATER
- Update all internal references to use new namespace
- Clean PublicAPI files (entries will be added when NET11 ships)
- Add comprehensive conditional tests in AppThemeBindingConditionalTests.cs
- Wrap existing AppThemeBinding SourceGen tests in NET11_0_OR_GREATER
- Update namespace references in test expectations

This is a non-breaking change: AppThemeBinding remains internal on NET10,
becomes public API on NET11+.

All tests passing:
- SourceGen.UnitTests: 62 passed
- Xaml.UnitTests: 1713 passed
@StephaneDelcroix StephaneDelcroix force-pushed the fix-appthemebinding-accessibility branch from 1b29160 to 0ffdaec Compare November 18, 2025 12:05
@StephaneDelcroix StephaneDelcroix added this to the .NET 10.0 SR2 milestone Nov 18, 2025
…Binding test

AppThemeBinding is now only public in NET11_0_OR_GREATER, so the test
that directly instantiates it needs to be conditional to avoid build
errors in .NET 10.0.
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors xsg Xaml sourceGen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'AppThemeBinding' is inaccessible due to its protection level with XamlSourceGenerator on Version 10.0.20-ci.main.25566.1

2 participants