Support MAUI global XAML namespaces with an MSBuild opt-out - #3433
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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> |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 👍 / 👎.
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.Xamlretains canonical prefixed usage because its publicTabbedPagehelper conflicts with MAUI's control. Unprefixed MAUITabbedPage,{Parameter ...},{ShowDialog ...}, andViewModelLocatorwork alongside{prism:NavigateTo ...},{prism:GoBack}, andprism:TabbedPage.Title. Existinghttp://prismlibrary.commappings and all target frameworks are preserved.Coverage lives in the existing MAUI test project and demo app. The existing
ParameterExtensionFixtureverifies compiled global and canonical markup, MAUITabbedPage, 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:
PrismMauiGlobalXmlns=false: 323 tests passed on each framework; generated assembly metadata contains no Prism global mappings.ParameterExtensionFixturewith XamlC: both tests passed on each of .NET 10 and .NET 11.2b0ca3e744e57df9217ad338de77d4c1265e7ce7. Both CodeQL analyses passed. Automated review completed on that head with no new findings.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 tofalse).Behavioral Changes
Prism's nonconflicting mapped namespaces become available without prefixes in pages using MAUI's global namespace.
Prism.Navigation.Xamlretains canonical prefixed usage to preserve MAUI'sTabbedPagecontrol. 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 requiresGenerateAssemblyInfo=true; implicit root namespace declarations remain a separate MAUI feature.PR Checklist