Skip to content

Support MAUI global XAML namespaces with an MSBuild opt-out - #3433

Merged
dansiegel merged 6 commits into
masterfrom
ds/maui-global-xaml-3432
Oct 4, 2026
Merged

dansiegel merged 6 commits into
masterfrom
ds/maui-global-xaml-3432

Conversation

@dansiegel

@dansiegel dansiegel commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Description of Change

MAUI reads global XAML mappings from the consuming assembly. Generate consumer assembly metadata for Prism.Maui's nine nonconflicting XAML namespaces in MAUI .NET 10+ projects. Support is enabled by default and can be disabled with PrismMauiGlobalXmlns=false.

Prism.Navigation.Xaml retains canonical prefixed usage because its public TabbedPage helper conflicts with MAUI's control. Unprefixed MAUI TabbedPage, {Parameter ...}, {ShowDialog ...}, and ViewModelLocator work alongside {prism:NavigateTo ...}, {prism:GoBack}, and prism:TabbedPage.Title. Existing http://prismlibrary.com mappings and all target frameworks are preserved.

Coverage lives in the existing MAUI test project and demo app. The existing ParameterExtensionFixture verifies compiled global and canonical markup, MAUI TabbedPage, Prism attached properties, navigation commands, dialog markup, and behaviors. The demo adds a navigable page showing global and canonical usage. No new projects or scripts are introduced.

Validation:

  • Existing Release suite with SourceGen: 324 tests passed on each of .NET 10 and .NET 11.
  • Existing Release suite with PrismMauiGlobalXmlns=false: 323 tests passed on each framework; generated assembly metadata contains no Prism global mappings.
  • Existing ParameterExtensionFixture with XamlC: both tests passed on each of .NET 10 and .NET 11.
  • MAUI CI passed on head 2b0ca3e744e57df9217ad338de77d4c1265e7ce7. Both CodeQL analyses passed. Automated review completed on that head with no new findings.
  • The local Windows demo build stops in the existing module projects' WinUI compiler; the same failure reproduces unchanged on master. The Android Release demo build passed. No device deployment or NativeAOT publication was performed.

References: MAUI global namespace documentation, MAUI compiler source.

Bugs Fixed

API Changes

No public C# API changes. Added consumer MSBuild property: PrismMauiGlobalXmlns (enabled unless explicitly set to false).

Behavioral Changes

Prism's nonconflicting mapped namespaces become available without prefixes in pages using MAUI's global namespace. Prism.Navigation.Xaml retains canonical prefixed usage to preserve MAUI's TabbedPage control. Applications can disambiguate other conflicting types with explicit namespace prefixes or disable the generated mappings. Applications declaring their own equivalent mappings should disable the package-generated mappings. This requires GenerateAssemblyInfo=true; implicit root namespace declarations remain a separate MAUI feature.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T21:15:20.525046Z 2b0ca3e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d602f198c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<ItemGroup Condition=" '$(UseMaui)' == 'true' AND '$(PrismMauiGlobalXmlns)' != 'false' AND '$(TargetFramework)' != '' AND $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '10.0')) ">
<AssemblyAttribute Include="Microsoft.Maui.Controls.XmlnsDefinitionAttribute">
<_Parameter1>http://schemas.microsoft.com/dotnet/maui/global</_Parameter1>
<_Parameter2>http://prismlibrary.com</_Parameter2>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid globally aggregating the colliding TabbedPage type

When a .NET 10+ consumer uses the global namespace and declares an unprefixed <TabbedPage>, this aggregation merges Prism's canonical schema with MAUI's built-in schema. That canonical schema already exports the public Prism.Navigation.Xaml.TabbedPage attached-property type (Properties/AssemblyInfo.cs:9 and Navigation/Xaml/TabbedPage.cs:6), so it collides with Microsoft.Maui.Controls.TabbedPage and makes otherwise valid XAML ambiguous—the same failure mode asserted by the new collision-negative test. Referencing or upgrading Prism can therefore break existing global-namespace pages; avoid enabling the whole canonical schema by default or exclude/rename this colliding Prism type before aggregation.

Useful? React with 👍 / 👎.

$arguments = @(
$project, '-c', 'Release', '-f', $framework, '--verbosity', 'quiet',
"-p:TargetFrameworks=$framework", "-p:PrismMauiPackageVersion=$PackageVersion",
"-p:RestoreAdditionalProjectSources=$packagePath", "-p:MauiXamlInflator=$inflator",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Isolate restores from the global package cache

When this regression script is rerun after repacking the same $PackageVersion, adding the supplied directory as another source does not ensure that its package is used: NuGet checks the global packages folder first and skips source lookup when that exact ID/version is already cached, as described in NuGet's cache documentation. The matrix can therefore test a stale prior build and report success even when the newly supplied .nupkg is broken; use an isolated RestorePackagesPath (and ensure the Prism IDs resolve from the supplied feed) for each run.

Useful? React with 👍 / 👎.

@dansiegel
dansiegel merged commit f5d6f80 into master Oct 4, 2026
6 checks passed
@dansiegel
dansiegel deleted the ds/maui-global-xaml-3432 branch October 4, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support MAUI global XAML namespaces

1 participant