KEMBAR78
[X] Optionally stop supporting Namescopes by StephaneDelcroix · Pull Request #30435 · dotnet/maui · GitHub
Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

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

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
@Copilot Copilot AI review requested due to automatic review settings July 4, 2025 11:19
@StephaneDelcroix StephaneDelcroix requested a review from a team as a code owner July 4, 2025 11:19
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 introduces an optional runtime switch to disable XAML namescopes support, improving JIT and GC behavior when namescopes aren’t necessary.

  • Adds AreNamescopesSupported feature switch and default in RuntimeFeature.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)

simonrozsival
simonrozsival previously approved these changes Jul 4, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@StephaneDelcroix
Copy link
Contributor Author

failures unrelated

@rmarinho rmarinho merged commit 3c862aa into net10.0 Jul 22, 2025
126 of 130 checks passed
@rmarinho rmarinho deleted the dev/stdelc/unsupportNamescopes branch July 22, 2025 10:45
@rmarinho rmarinho added this to the .NET 10.0-preview7 milestone Jul 22, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2025
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Aug 22, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants