Skip to content

Enable implicit xmlns declarations by default - #33834

Merged
StephaneDelcroix merged 6 commits into
net11.0from
feature/implicit-xmlns-default
Mar 12, 2026
Merged

StephaneDelcroix merged 6 commits into
net11.0from
feature/implicit-xmlns-default

Conversation

@StephaneDelcroix

@StephaneDelcroix StephaneDelcroix commented Feb 2, 2026 •

Copy link
Copy Markdown
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

Starting with .NET 11, implicit xmlns declarations are enabled by default. XAML files no longer need to include the standard namespace declarations.

Changes

  • Removed [RequiresPreviewFeatures] from AllowImplicitXmlnsDeclarationAttribute
  • Always emit [assembly: AllowImplicitXmlnsDeclaration] in source generator
  • Updated all MAUI templates to use implicit xmlns
  • Updated Sandbox app MainPage.xaml

What's Implicit

The default implicit namespace is the global MAUI URI:

  • Default namespace: http://schemas.microsoft.com/dotnet/maui/global
  • xmlns:x prefix (via XmlnsPrefix attributes)

Custom namespaces might require explicit declaration.

Copilot AI review requested due to automatic review settings February 2, 2026 12:07
@StephaneDelcroix StephaneDelcroix added this to the .NET 11.0-preview1 milestone Feb 2, 2026
@StephaneDelcroix
StephaneDelcroix changed the base branch from net10.0 to main February 2, 2026 12:10
@StephaneDelcroix

Copy link
Copy Markdown
Contributor Author

FYI @emaf @noiseonwires

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 enables implicit xmlns declarations as a default feature in .NET 11, eliminating the need for standard namespace declarations in XAML files. The core change removes the preview feature requirement and updates all MAUI templates to demonstrate the new simpler XAML syntax.

Changes:

  • Removes [RequiresPreviewFeatures] attribute from AllowImplicitXmlnsDeclarationAttribute to make it a standard feature
  • Updates source generator to always emit the assembly attribute (no longer conditional)
  • Modernizes all MAUI templates to use simplified XAML without explicit xmlns declarations
  • Improves test infrastructure with better diagnostic handling, Helix support for XAML unit tests, and Android device test filtering
  • Updates build and CI pipelines for better efficiency and reliability
  • Includes various quality improvements (localization updates, iOS bug fix, Gradle updates)

Reviewed changes

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

Show a summary per file
File Description
src/Controls/src/Core/AllowImplicitXmlnsDeclarationAttribute.cs Removes [RequiresPreviewFeatures] to make implicit xmlns a standard feature
src/Controls/src/SourceGen/XamlGenerator.cs Always emits [assembly: AllowImplicitXmlnsDeclaration] without conditional compilation
Template XAML files (40+ files) Removes explicit xmlns declarations, demonstrating new simplified syntax
src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml Updates Sandbox to use implicit xmlns
src/TestUtils/src/UITest.NUnit/UITestBase.cs Adds diagnostic file re-attachment for fixture setup failures in Azure DevOps
src/Core/tests/DeviceTests.Shared/DeviceTestSharedHelpers.cs Adds Android support for TestFilter via instrumentation arguments
src/Controls/tests/Xaml.UnitTests/MockSourceGenerator.cs Adds Helix correlation payload support for SourceGen DLL
src/Controls/tests/Xaml.UnitTests/MSBuild/* Adds Helix support for MSBuild tests with conditional path resolution
eng/helix.proj Adds XAML unit test projects and correlation payloads for Helix
eng/Build.props Restructures build to support full solution vs pack-only builds
eng/pipelines/* Updates CI pools, removes OS version constraints, fixes Xcode skip logic
Localization files Updates Chinese, Turkish, Russian, and other language resources for binding/namescope errors
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs Fixes iOS 26+ disabled tab selection via drag gesture
src/Core/AndroidNative/maui/build.gradle Updates to Android SDK 36 and Gradle 8+ base archivesName
Various test files Replaces Thread.Sleep() and Task.Delay() with VerifyScreenshot(retryTimeout:) pattern
Documentation Updates README, development tips, and workload README with clearer build instructions

@rmarinho

rmarinho commented Feb 3, 2026

Copy link
Copy Markdown
Member

/rebase

@github-actions
github-actions Bot force-pushed the feature/implicit-xmlns-default branch from b3daaf9 to 673e869 Compare February 3, 2026 19:09
@StephaneDelcroix
StephaneDelcroix changed the base branch from net11.0 to main February 4, 2026 13:14
@StephaneDelcroix
StephaneDelcroix marked this pull request as draft February 4, 2026 13:16
@StephaneDelcroix
StephaneDelcroix force-pushed the feature/implicit-xmlns-default branch 2 times, most recently from f5f2c4b to fb99e0e Compare February 5, 2026 07:59
@StephaneDelcroix
StephaneDelcroix changed the base branch from main to net11.0 February 5, 2026 08:00
@StephaneDelcroix
StephaneDelcroix marked this pull request as ready for review February 5, 2026 08:00
@StephaneDelcroix
StephaneDelcroix force-pushed the feature/implicit-xmlns-default branch from 23c9af1 to ca212c2 Compare February 7, 2026 16:59
@StephaneDelcroix
StephaneDelcroix marked this pull request as draft February 7, 2026 20:24
@StephaneDelcroix
StephaneDelcroix marked this pull request as ready for review February 25, 2026 09:39
@StephaneDelcroix
StephaneDelcroix force-pushed the feature/implicit-xmlns-default branch from 9739bb6 to cfc86c3 Compare February 27, 2026 15:20
@github-actions

github-actions Bot commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 33834

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 33834"

@StephaneDelcroix
StephaneDelcroix force-pushed the feature/implicit-xmlns-default branch from cfc86c3 to e3a08b0 Compare March 3, 2026 16:50
@StephaneDelcroix

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests, maui-pr-uitests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

- Remove [RequiresPreviewFeatures] from AllowImplicitXmlnsDeclarationAttribute
- Always emit [assembly: AllowImplicitXmlnsDeclaration] in source generator
- Update all templates to use implicit xmlns (remove xmlns= and xmlns:x= declarations)
- Update Sandbox app MainPage.xaml

XAML files can now omit the default xmlns and xmlns:x declarations as they are implicit.
@StephaneDelcroix
StephaneDelcroix force-pushed the feature/implicit-xmlns-default branch from e4e4d28 to 532da44 Compare March 6, 2026 11:58
StephaneDelcroix and others added 2 commits March 6, 2026 13:03
…ored

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@StephaneDelcroix StephaneDelcroix added the do-not-merge Don't merge this PR label Mar 10, 2026
@StephaneDelcroix

Copy link
Copy Markdown
Contributor Author

/azp run maui-pr-devicetests, maui-pr-uitests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@StephaneDelcroix StephaneDelcroix removed the do-not-merge Don't merge this PR label Mar 11, 2026
@StephaneDelcroix

Copy link
Copy Markdown
Contributor Author

XLS support for this has been merged

@StephaneDelcroix
StephaneDelcroix merged commit 06a19c1 into net11.0 Mar 12, 2026
153 of 209 checks passed
@StephaneDelcroix
StephaneDelcroix deleted the feature/implicit-xmlns-default branch March 12, 2026 13:47
davidortinau added a commit to dotnet/docs-maui that referenced this pull request Apr 10, 2026
In .NET 11 (PR dotnet/maui#33834), implicit xmlns declarations are
enabled by default. The compiler automatically injects the standard
MAUI and x: namespace declarations, so XAML files can omit them.

Changes:
- docs/xaml/namespaces/index.md: Add new 'Implicit namespace
  declarations' section with before/after examples, moniker-gated
  for .NET 11 (default) and .NET 10 (preview opt-in).
- docs/xaml/fundamentals/get-started.md: Add .NET 11 note near xmlns
  explanation and split the implicit xmlns content into version-
  specific moniker blocks (.NET 11 default vs .NET 10 opt-in).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants