Repository navigation
Conversation
### Description of Change `Shell.FlyoutBackgroundColor` set from a `Style`, implicit or explicit, was ignored. Only a value set directly on the `Shell` worked, and `FlyoutBackground` worked from a `Style`. **Root cause** The `Shell` constructor binds `FlyoutBackgroundColor` to an `AppThemeBinding` for the default white/black colors. It uses the public `SetBinding`, which applies the binding with `SetterSpecificity.FromBinding`, and a binding outranks every `Style` setter; only a value set directly on the element is higher. So the default always won over a `Style`. **Fix** The default binding is applied with the lowest specificity, `new SetterSpecificity()`, through the same internal overload `Setter` uses for bindings in styles. A `Style` setter or a value set directly on the `Shell` now wins over it, and when nothing else sets the property the theme colors still apply, including when the theme changes. The Material 3 path on Android, which doesn't create this binding, is unchanged. **Tests** In `AppThemeTests`: - `StyleSetsShellFlyoutBackgroundColor`: an implicit `Shell` style sets the color, and it stays after a theme change. - `ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle`: without a style the default is still white in light and black in dark. | | Without fix | With fix | |---|---|---| | `main` (4c74701) | First test fails: White instead of Red | Both pass; Controls.Core.UnitTests 6735 passed | ### Issues Fixed Fixes #9736 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Namespace global usings (handwritten and MSBuild/SDK-generated) now add current-assembly types to the implicit global XAML namespace. Aliases, extern-alias imports, using static, and other generators' output are excluded. Fixes #29708 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40170Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40170" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the global-using XAML namespace mapping changes.
No open issues 🎉
What changed in this PR
Addresses #29708 by generating implicit global XAML namespace mappings from C# namespace global using directives. This lets XAML elements and markup extensions resolve current-assembly types without explicit namespace declarations.
Changes:
- Collects, normalizes, and emits global-using mappings, with same-pass SourceGen resolution and cache invalidation when imports change.
- Corrects XamlC’s namespace guard so CLR namespaces beginning with
httpremain resolvable. - Adds coverage for import boundaries, exclusions, ambiguity, incremental updates, and all three XAML inflators, plus documentation.
| File | Description |
|---|---|
src/Controls/tests/Xaml.UnitTests/Issues/Maui29708External.rt.xaml |
Adds a referenced-assembly rejection fixture. |
src/Controls/tests/Xaml.UnitTests/Issues/Maui29708.xaml.cs |
Tests imported controls, markup extensions, and assembly boundaries. |
src/Controls/tests/Xaml.UnitTests/Issues/Maui29708.xaml |
Exercises imported types without explicit namespace declarations. |
src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj |
Adds an MSBuild-generated global using for testing. |
src/Controls/tests/SourceGen.UnitTests/GlobalUsingTests.cs |
Covers generation, resolution, exclusions, and incremental behavior. |
src/Controls/src/SourceGen/XmlTypeExtensions.cs |
Resolves globally imported types from the current assembly. |
src/Controls/src/SourceGen/XamlGenerator.cs |
Collects global imports, emits mappings, and updates cache invalidation. |
src/Controls/src/SourceGen/GeneratorHelpers.cs |
Passes imported namespaces into assembly metadata. |
src/Controls/src/SourceGen/AssemblyAttributes.cs |
Stores global-using namespaces for type resolution. |
src/Controls/src/Build.Tasks/XmlTypeExtensions.cs |
Restricts the aggregated-namespace guard to HTTP/HTTPS schemes. |
docs/specs/XamlCSharpExpressions.md |
Documents global-using mappings and their scope. |
Review effort: Balanced
The runtime XamlParser cached xmlns definitions process-wide, filtered by the first assembly that gathered them, so global mappings from one assembly could leak into another's type resolution. Keep each definition's source assembly and filter global mappings per current assembly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Source-loaded classless ResourceDictionary instances resolve types against the framework assembly rather than RootAssembly, dropping application global mappings and causing imported application types to fail resolution.
1 open issue
Review effort: Balanced
|
|
||
| var types = xmlType.GetTypeReferences( | ||
| s_xmlnsDefinitions, | ||
| s_xmlnsDefinitions.For(currentAssembly), |
|
/rebase |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence. 🧪 Unit tests
📄 XAML unit tests
Execution log excerptsWithout fix With fix Without fix With fix PR head: cc271744. Without-fix baseline: 9291bfb2. |
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change Revert #39839 on `main` as requested. This restores the previous behavior: a `Style` cannot override the default `Shell.FlyoutBackgroundColor` binding until the candidate fix is forwarded to `main`. The identical implementation and regression tests are already on `candidate/11.0.1xx-sr2`, where they were included in #40170 (commit `706b461e9296fd30f7ff3c057dacf2025d60a698`). A separate candidate PR for the same patch would be empty, so this PR changes only `main`. ### Validation - Verified the commit is the exact inverse of `9291bfb20edde2cc822b8e2a110f63d2b3425e09`; both changed files match their pre-fix blobs. - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --verbosity quiet` — passed. - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~AppThemeTests' --verbosity quiet` — passed: 15 tests before the revert and 13 after removal of the two reverted tests. - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-build --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests' --verbosity quiet` — passed: 147 tests. - With the two original regression tests temporarily retained against the reverted implementation, `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~StyleSetsShellFlyoutBackgroundColor|FullyQualifiedName~ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle' --logger 'console;verbosity=normal'` — expected failure: the style test received white instead of red; the default-theme test passed. The temporarily retained tests were removed again before committing. - The combined selection `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~AppThemeTests|FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests' --verbosity quiet` failed `CorrectDefaultRadioButtonThemeColorsInLightAndDarkModes` (159 passed, 1 failed). The same failure occurred with the original patch restored on the unmodified `main` baseline (161 passed, 1 failed); the isolated selections above pass. - `dotnet format Microsoft.Maui.sln --no-restore --verify-no-changes --include src/Controls/src/Core/Shell/Shell.cs src/Controls/tests/Core.UnitTests/AppThemeTests.cs --exclude Templates/src --exclude-diagnostics CA1822 --verbosity quiet` — passed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Related to #9736; this revert intentionally restores the issue on `main`. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change Revert dotnet#39839 on `main` as requested. This restores the previous behavior: a `Style` cannot override the default `Shell.FlyoutBackgroundColor` binding until the candidate fix is forwarded to `main`. The identical implementation and regression tests are already on `candidate/11.0.1xx-sr2`, where they were included in dotnet#40170 (commit `706b461e9296fd30f7ff3c057dacf2025d60a698`). A separate candidate PR for the same patch would be empty, so this PR changes only `main`. ### Validation - Verified the commit is the exact inverse of `9291bfb20edde2cc822b8e2a110f63d2b3425e09`; both changed files match their pre-fix blobs. - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --verbosity quiet` — passed. - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~AppThemeTests' --verbosity quiet` — passed: 15 tests before the revert and 13 after removal of the two reverted tests. - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-build --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests' --verbosity quiet` — passed: 147 tests. - With the two original regression tests temporarily retained against the reverted implementation, `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~StyleSetsShellFlyoutBackgroundColor|FullyQualifiedName~ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle' --logger 'console;verbosity=normal'` — expected failure: the style test received white instead of red; the default-theme test passed. The temporarily retained tests were removed again before committing. - The combined selection `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~AppThemeTests|FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests' --verbosity quiet` failed `CorrectDefaultRadioButtonThemeColorsInLightAndDarkModes` (159 passed, 1 failed). The same failure occurred with the original patch restored on the unmodified `main` baseline (161 passed, 1 failed); the isolated selections above pass. - `dotnet format Microsoft.Maui.sln --no-restore --verify-no-changes --include src/Controls/src/Core/Shell/Shell.cs src/Controls/tests/Core.UnitTests/AppThemeTests.cs --exclude Templates/src --exclude-diagnostics CA1822 --verbosity quiet` — passed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Related to dotnet#9736; this revert intentionally restores the issue on `main`. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes #29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
<!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change Revert dotnet#39839 on `main` as requested. This restores the previous behavior: a `Style` cannot override the default `Shell.FlyoutBackgroundColor` binding until the candidate fix is forwarded to `main`. The identical implementation and regression tests are already on `candidate/11.0.1xx-sr2`, where they were included in dotnet#40170 (commit `706b461e9296fd30f7ff3c057dacf2025d60a698`). A separate candidate PR for the same patch would be empty, so this PR changes only `main`. ### Validation - Verified the commit is the exact inverse of `9291bfb20edde2cc822b8e2a110f63d2b3425e09`; both changed files match their pre-fix blobs. - `dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --verbosity quiet` — passed. - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~AppThemeTests' --verbosity quiet` — passed: 15 tests before the revert and 13 after removal of the two reverted tests. - `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-build --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests' --verbosity quiet` — passed: 147 tests. - With the two original regression tests temporarily retained against the reverted implementation, `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~StyleSetsShellFlyoutBackgroundColor|FullyQualifiedName~ShellFlyoutBackgroundColorFollowsTheThemeWithoutAStyle' --logger 'console;verbosity=normal'` — expected failure: the style test received white instead of red; the default-theme test passed. The temporarily retained tests were removed again before committing. - The combined selection `dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -c Debug -p:IncludeIosTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -p:IncludeTizenTargetFrameworks=false -p:TreatWarningsAsErrors=false --filter 'FullyQualifiedName~AppThemeTests|FullyQualifiedName~ShellTests|FullyQualifiedName~StyleTests' --verbosity quiet` failed `CorrectDefaultRadioButtonThemeColorsInLightAndDarkModes` (159 passed, 1 failed). The same failure occurred with the original patch restored on the unmodified `main` baseline (161 passed, 1 failed); the isolated selections above pass. - `dotnet format Microsoft.Maui.sln --no-restore --verify-no-changes --include src/Controls/src/Core/Shell/Shell.cs src/Controls/tests/Core.UnitTests/AppThemeTests.cs --exclude Templates/src --exclude-diagnostics CA1822 --verbosity quiet` — passed. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Related to dotnet#9736; this revert intentionally restores the issue on `main`. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…0170) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change C# namespace `global using` directives now add **current-assembly** types to the implicit global XAML namespace (`http://schemas.microsoft.com/dotnet/maui/global`, used when `xmlns` is omitted). **Included:** handwritten global usings and MSBuild/SDK-generated ones (`<Using Include="..." />`). **Excluded:** namespace/type aliases, extern-alias-qualified imports, `global using static`, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicit `XmlnsDefinition` mappings can still expose them). Explicit default namespaces such as `http://schemas.microsoft.com/dotnet/2021/maui` are unchanged. Implementation: - `XamlGenerator`: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. Emits `Global.Usings.Xmlns.cs` with `[assembly: XmlnsDefinition(global, ns)]` (no `AssemblyName`, so Runtime and XamlC resolve against the current assembly only). - Same-pass SourceGen resolution: imports flow into `AssemblyAttributes.GlobalUsingNamespaces` and resolve only through `compilation.Assembly`. Existing ambiguity diagnostics are preserved. - Incrementality: the compilation provider is combined with the namespace set, so editing usings invalidates the namespace and type caches. Method-body edits remain cached. - XamlC: the aggregated-xmlns guard now matches `http:`/`https:` instead of any CLR namespace starting with `http`, so namespaces such as `http29708.Controls` resolve. - Runtime `XamlParser`: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view. - Docs: `docs/specs/XamlCSharpExpressions.md`. ### Tests - `SourceGen.UnitTests/GlobalUsingTests.cs`: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators. - `Xaml.UnitTests/Issues/Maui29708`: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild `<Using>`. A referenced-assembly type is rejected in Runtime and XamlC. `RuntimeGlobalMappingsDoNotLeakToOtherAssemblies` fails without the runtime cache fix. Validation (macOS, platform TFMs disabled due to a local workload mismatch): - `dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj` full suite: **passed** — 641 passed, 40 skipped. It was run from a copied output path because `XTypeMultiFileHotReloadTests` fail when the path contains `~`, independent of this change. - `dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns"`: **passed** — 42 passed. - Full `Controls.Xaml.UnitTests`: 2185 passed, 8 skipped, 2 failed (`TwoWayDecimalBinding_*`, locale-dependent on the `en_BE` test machine and unrelated to this change). ### Issues Fixed Fixes dotnet#29708 --------- Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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!
Target Branch
mainnet11, for reviewFor .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
C# namespace
global usingdirectives now add current-assembly types to the implicit global XAML namespace (http://schemas.microsoft.com/dotnet/maui/global, used whenxmlnsis omitted).Included: handwritten global usings and MSBuild/SDK-generated ones (
<Using Include="..." />).Excluded: namespace/type aliases, extern-alias-qualified imports,
global using static, ordinary output of other source generators in the same pass, and referenced-assembly types (existing explicitXmlnsDefinitionmappings can still expose them). Explicit default namespaces such ashttp://schemas.microsoft.com/dotnet/2021/mauiare unchanged.Implementation:
XamlGenerator: semantic incremental provider collects active namespace global usings, normalizes, sorts, and deduplicates them. EmitsGlobal.Usings.Xmlns.cswith[assembly: XmlnsDefinition(global, ns)](noAssemblyName, so Runtime and XamlC resolve against the current assembly only).AssemblyAttributes.GlobalUsingNamespacesand resolve only throughcompilation.Assembly. Existing ambiguity diagnostics are preserved.http:/https:instead of any CLR namespace starting withhttp, so namespaces such ashttp29708.Controlsresolve.XamlParser: the process-wide xmlns cache was filtered by the first assembly that gathered it, so one assembly's global mappings could resolve types for another (pre-existing, but more likely now). Definitions now keep their declaring assembly, and global mappings are filtered per current assembly in a cached view.docs/specs/XamlCSharpExpressions.md.Tests
SourceGen.UnitTests/GlobalUsingTests.cs: same-pass generation, escaped names, exclusions, current-assembly boundary with and without explicit mappings, extern alias, explicit MAUI default, ambiguity, edits/rebinding invalidation, deterministic ordering, and no import from other generators.Xaml.UnitTests/Issues/Maui29708: Runtime, XamlC, and SourceGen inflation of a type and markup extension imported through a handwritten global using plus an MSBuild<Using>. A referenced-assembly type is rejected in Runtime and XamlC.RuntimeGlobalMappingsDoNotLeakToOtherAssembliesfails without the runtime cache fix.Validation (macOS, platform TFMs disabled due to a local workload mismatch):
dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csprojfull suite: passed — 641 passed, 40 skipped. It was run from a copied output path becauseXTypeMultiFileHotReloadTestsfail when the path contains~, independent of this change.dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj --filter "FullyQualifiedName~Maui29708|FullyQualifiedName~Xmlns": passed — 42 passed.Controls.Xaml.UnitTests: 2185 passed, 8 skipped, 2 failed (TwoWayDecimalBinding_*, locale-dependent on theen_BEtest machine and unrelated to this change).Issues Fixed
Fixes #29708