Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

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

Disables the AppThemeBindingExtension source generation for NET10 by wrapping the code with #if NET11_0_OR_GREATER preprocessor directives.

This ensures the feature is only enabled for .NET 11 and later versions.

Changes

  • Wrapped ProvideValueForAppThemeBindingExtension method in KnownMarkups.cs with #if NET11_0_OR_GREATER
  • Wrapped the dictionary entry for AppThemeBindingExtension in NodeSGExtensions.cs with #if NET11_0_OR_GREATER

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 attempts to disable AppThemeBindingExtension source generation for .NET 10 by using #if NET11_0_OR_GREATER preprocessor directives. However, there is a critical flaw in this approach that will cause the feature to be disabled for all target frameworks, including .NET 11 and later.

Key Issues

  • The source generator targets netstandard2.0, which means preprocessor directives are evaluated at the generator's compile-time, not based on the target framework being compiled
  • The NET11_0_OR_GREATER constant will never be defined in a netstandard2.0 project, causing the code to always be excluded
  • The correct approach requires runtime checking of context.ProjectItem.TargetFramework instead of compile-time preprocessor directives

Reviewed changes

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

File Description
src/Controls/src/SourceGen/NodeSGExtensions.cs Wraps the AppThemeBindingExtension dictionary entry with #if NET11_0_OR_GREATER (incorrect approach)
src/Controls/src/SourceGen/KnownMarkups.cs Wraps the ProvideValueForAppThemeBindingExtension method with #if NET11_0_OR_GREATER (incorrect approach)

@rmarinho rmarinho merged commit 434eeb9 into release/10.0.1xx-sr2 Dec 11, 2025
155 of 165 checks passed
@rmarinho rmarinho deleted the fix/disable-appthemebinding-sourcegen-sr2 branch December 11, 2025 13:04
@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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants