-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Disable AppThemeBindingExtension source generation for NET10 #33107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable AppThemeBindingExtension source generation for NET10 #33107
Conversation
There was a problem hiding this 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_GREATERconstant 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.TargetFrameworkinstead 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) |
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
- [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>
- [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>
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_GREATERpreprocessor directives.This ensures the feature is only enabled for .NET 11 and later versions.
Changes
ProvideValueForAppThemeBindingExtensionmethod inKnownMarkups.cswith#if NET11_0_OR_GREATERAppThemeBindingExtensioninNodeSGExtensions.cswith#if NET11_0_OR_GREATER