-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[X] Optionally stop supporting Namescopes #30435
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
Conversation
With Xaml SourceGen, Namescopes are no longer necessary for the XAML infrastructure. Npt generating them will help the JIT and GC This is mostly unused right now - fixes #30434
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 introduces an optional runtime switch to disable XAML namescopes support, improving JIT and GC behavior when namescopes aren’t necessary.
- Adds
AreNamescopesSupportedfeature switch and default inRuntimeFeature.cs - Injects guard clauses throwing if namescopes are disabled across XAML and runtime namescope APIs
- Updates MSBuild targets and documentation for the new switch
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/src/RuntimeFeature.cs | Added SupportNamescopesByDefault and AreNamescopesSupported switch; exposed feature properties publicly |
| src/Controls/src/Xaml/XamlServiceProvider.cs | Guard FindByName calls with AreNamescopesSupported check |
| src/Controls/src/Core/NameScopeExtensions.cs | Added guard in extension and namescope helper overload |
| src/Controls/src/Core/Internals/NameScope.cs | Added guard clauses in INameScope implementations |
| src/Controls/src/Core/Element/Element.cs | Added guard clauses in FindByName, register/unregister, GetNameScope |
| src/Controls/src/Build.Tasks/nuget/.../Microsoft.Maui.Controls.targets | Added MSBuild RuntimeHostConfigurationOption for namescopes |
| docs/design/FeatureSwitches.md | Documented new MauiNamescopesSupported switch; updated feature table |
Comments suppressed due to low confidence (2)
docs/design/FeatureSwitches.md:14
- The switch key in the table ('Microsoft.Maui.RuntimeFeature.XamlCBindingWithSourceCompilationEnabled') is missing the 'Is' prefix present in the code; please align key names with the actual feature switch identifiers.
| MauiEnableXamlCBindingWithSourceCompilation | Microsoft.Maui.RuntimeFeature.XamlCBindingWithSourceCompilationEnabled | When enabled, MAUI will compile all bindings, including those where the `Source` property is used. |
src/Controls/src/Xaml/XamlServiceProvider.cs:177
- New guard clauses are introduced for the namescopes feature; consider adding unit tests or UI tests in TestCases.Shared.Tests and TestCases.HostApp to cover both enabled and disabled scenarios.
if (!RuntimeFeature.AreNamescopesSupported)
|
failures unrelated |
Description of Change
With Xaml SourceGen, Namescopes are no longer necessary for the XAML infrastructure. Npt generating them will help the JIT and GC
This is mostly unused right now
Issues Fixed