Skip to content

[net10.0][XSG] Suppress CA2252 on generated AllowImplicitXmlnsDeclaration attribute - #40213

Merged
kubaflo merged 61 commits into
release/10.0.1xx-sr14from
stephanedelcroix-issue-40045-implicit-xmlns-ca2252
Nov 13, 2026
Merged

kubaflo merged 61 commits into
release/10.0.1xx-sr14from
stephanedelcroix-issue-40045-implicit-xmlns-ca2252

Conversation

@StephaneDelcroix

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 of Change

On MAUI 10.0.x, when MauiAllowImplicitXmlnsDeclaration is defined, the XAML source generator emits [assembly: AllowImplicitXmlnsDeclaration] into GlobalXmlns.g.cs. That attribute is marked [RequiresPreviewFeatures].

CA2252 is suppressed only if the app assembly carries [assembly: RequiresPreviewFeatures]. The SDK adds that attribute only when EnablePreviewFeatures=true and the project targets the SDK's latest TFM (IsNetCoreAppTargetingLatestTFM). A net10.0 app built with the .NET 11 SDK therefore fails with GlobalXmlns.g.cs(15,12): error CA2252. Visual Studio picked a .NET 10 SDK, which is why the build passed there and failed from the CLI.

Defining MauiAllowImplicitXmlnsDeclaration is already the explicit opt-in, and the runtime, XamlC and SourceGen paths only check that the attribute is present. So the generator now wraps the emitted attribute in #pragma warning disable/restore CA2252. The public attribute is unchanged; user code that applies it by hand still gets CA2252 as before.

Tests: Maui40045Tests runs XamlGenerator with the MauiAllowImplicitXmlnsDeclaration symbol on a compilation that has no [assembly: RequiresPreviewFeatures], then runs the real CA2252 analyzer from Microsoft.CodeAnalysis.NetAnalyzers over the result. The analyzer path comes from the project's resolved @(Analyzer) items.

Validation:

  • dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj --filter FullyQualifiedName~Maui40045: passes with the fix. It fails without the fix with GlobalXmlns.g.cs(15,12): error CA2252.
  • dotnet test src/Controls/tests/SourceGen.UnitTests/SourceGen.UnitTests.csproj: 180 passed, 0 failed.
  • End-to-end: a net10.0 project on the .NET 11 RC2 SDK with Microsoft.Maui.Controls 10.0.130, the define and EnablePreviewFeatures=true fails with CA2252. With the patched Microsoft.Maui.Controls.SourceGen.dll swapped in, it builds.

.NET 11 / main: no change needed. The generator no longer emits the attribute (#33834), and the attribute is [Obsolete] instead of preview-gated. Microsoft.Maui.Controls 11.0.10 builds cleanly with the same settings on both net11.0 (with GenerateRequiresPreviewFeaturesAttribute=false) and net10.0.

Issues Fixed

Fixes #40045

github-actions Bot and others added 30 commits October 29, 2025 11:47
Co-authored-by: Rui Marinho <me@ruimarinho.net>
…030.4 (#32309)

On relative base path root
Microsoft.AspNetCore.Authentication.Facebook , Microsoft.AspNetCore.Authentication.Google , Microsoft.AspNetCore.Authentication.MicrosoftAccount , Microsoft.AspNetCore.Authorization , Microsoft.AspNetCore.Components , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.Components.Forms , Microsoft.AspNetCore.Components.Web , Microsoft.AspNetCore.Components.WebAssembly , Microsoft.AspNetCore.Components.WebAssembly.Server , Microsoft.AspNetCore.Components.WebView , Microsoft.AspNetCore.Metadata , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Logging , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Primitives , Microsoft.JSInterop , Microsoft.NETCore.App.Ref From Version 10.0.0 -> To Version 10.0.0
Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.XUnitExtensions From Version 10.0.0-beta.25523.113 -> To Version 10.0.0-beta.25530.104
Microsoft.NET.Sdk From Version 10.0.100-rtm.25523.113 -> To Version 10.0.100-rtm.25530.104

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
…031.2 (#32328)

On relative base path root
Microsoft.AspNetCore.Authentication.Facebook , Microsoft.AspNetCore.Authentication.Google , Microsoft.AspNetCore.Authentication.MicrosoftAccount , Microsoft.AspNetCore.Authorization , Microsoft.AspNetCore.Components , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.Components.Forms , Microsoft.AspNetCore.Components.Web , Microsoft.AspNetCore.Components.WebAssembly , Microsoft.AspNetCore.Components.WebAssembly.Server , Microsoft.AspNetCore.Components.WebView , Microsoft.AspNetCore.Metadata , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Logging , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Primitives , Microsoft.JSInterop , Microsoft.NETCore.App.Ref From Version 10.0.0 -> To Version 10.0.0
Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.XUnitExtensions From Version 10.0.0-beta.25530.104 -> To Version 10.0.0-beta.25531.102
Microsoft.NET.Sdk From Version 10.0.100-rtm.25530.104 -> To Version 10.0.100-rtm.25531.102

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
* Update dependencies from https://github.com/dotnet/macios build 20251030.6
On relative base path root
Microsoft.iOS.Sdk.net10.0_26.0 , Microsoft.MacCatalyst.Sdk.net10.0_26.0 , Microsoft.macOS.Sdk.net10.0_26.0 , Microsoft.tvOS.Sdk.net10.0_26.0 From Version 26.0.11017 -> To Version 26.0.11018

* Update dependencies from https://github.com/dotnet/macios build 20251031.4
On relative base path root
Microsoft.iOS.Sdk.net10.0_26.0 , Microsoft.MacCatalyst.Sdk.net10.0_26.0 , Microsoft.macOS.Sdk.net10.0_26.0 , Microsoft.tvOS.Sdk.net10.0_26.0 From Version 26.0.11017 -> To Version 26.0.11019

* Update dependencies from https://github.com/dotnet/macios build 20251103.2
On relative base path root
Microsoft.iOS.Sdk.net10.0_26.0 , Microsoft.MacCatalyst.Sdk.net10.0_26.0 , Microsoft.macOS.Sdk.net10.0_26.0 , Microsoft.tvOS.Sdk.net10.0_26.0 From Version 26.0.11017 -> To Version 26.0.11020

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rui Marinho <me@ruimarinho.net>
# Conflicts:
#	NuGet.config
### Description of Change

Update net10.0 with latest from main
# Conflicts:
#	NuGet.config
#	global.json
### Description of Change

Bring latest changes from main to net10.0 branch
* Update dependencies from https://github.com/dotnet/dotnet build 20251203.3
On relative base path root
Microsoft.AspNetCore.Authentication.Facebook , Microsoft.AspNetCore.Authentication.Google , Microsoft.AspNetCore.Authentication.MicrosoftAccount , Microsoft.AspNetCore.Authorization , Microsoft.AspNetCore.Components , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.Components.Forms , Microsoft.AspNetCore.Components.Web , Microsoft.AspNetCore.Components.WebAssembly , Microsoft.AspNetCore.Components.WebAssembly.Server , Microsoft.AspNetCore.Components.WebView , Microsoft.AspNetCore.Metadata , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Logging , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Primitives , Microsoft.JSInterop , Microsoft.NETCore.App.Ref From Version 10.0.1 -> To Version 10.0.2
Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.XUnitExtensions From Version 10.0.0-beta.25562.108 -> To Version 10.0.0-beta.25603.103
Microsoft.NET.Sdk From Version 10.0.101-servicing.25562.108 -> To Version 10.0.102-servicing.25603.103

* Fix global

* Update dependencies from https://github.com/dotnet/dotnet build 20251204.5
On relative base path root
Microsoft.AspNetCore.Authentication.Facebook , Microsoft.AspNetCore.Authentication.Google , Microsoft.AspNetCore.Authentication.MicrosoftAccount , Microsoft.AspNetCore.Authorization , Microsoft.AspNetCore.Components , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.Components.Forms , Microsoft.AspNetCore.Components.Web , Microsoft.AspNetCore.Components.WebAssembly , Microsoft.AspNetCore.Components.WebAssembly.Server , Microsoft.AspNetCore.Components.WebView , Microsoft.AspNetCore.Metadata , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Logging , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Primitives , Microsoft.JSInterop , Microsoft.NETCore.App.Ref From Version 10.0.1 -> To Version 10.0.2
Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.XUnitExtensions From Version 10.0.0-beta.25562.108 -> To Version 10.0.0-beta.25604.105
Microsoft.NET.Sdk From Version 10.0.101-servicing.25562.108 -> To Version 10.0.102-servicing.25604.105

* Update nuget.config with 9.0.12

* REvert changes for internal

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Rui Marinho <me@ruimarinho.net>
* [ci] Update iOS and Android workloads

* Update feeds

* Update MacCatalyst, macOS, iOS, and tvOS SDK versions

* Update versions again

* Add feed

* Aspnetcore 9.0.12 feed

* [tests] Suppress Xcode version check
* Add 8.0.23

* Try fix xcode select

* [ci] Update arcade

* Try specific version

* Try script

* Try fix MicrosoftNETSdkPackageVersion
### Description of Change

Bring latest changes from main to net10.0
> [!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!

Merges main branch changes into net10.0.
### Description of Change

This pull request updates several dependency versions and package
sources to ensure the project uses the latest stable releases of .NET,
macOS/iOS/tvOS/MacCatalyst SDKs, and related libraries. The changes
primarily focus on bumping version numbers and updating SHA references
for consistency and security, as well as modifying NuGet package sources
to match the new dependencies.

Dependency and SDK version updates:

* Updated .NET SDK and related package versions from
`10.0.102-servicing.25604.105` to `10.0.103-servicing.26057.111` in
`eng/Version.Details.xml` and `eng/Versions.props`, including
`Microsoft.NET.Sdk`, `Microsoft.NETCore.App.Ref`, and various
`Microsoft.Extensions.*` libraries.
[[1]](diffhunk://#diff-fb62e94a1d6f29f863e3d0a22aa38269f6cd1d7f03b109dc06e2cbf2548b86d3L3-R9)
[[2]](diffhunk://#diff-1ea18ff65faa2ae6fed570b83747086d0317f5e4bc325064f6c14319a9c4ff67L33-R54)
* Updated previous .NET 9 stable release versions for
`Microsoft.MacCatalyst.Sdk`, `Microsoft.macOS.Sdk`, `Microsoft.iOS.Sdk`,
and `Microsoft.tvOS.Sdk` from `26.0.9779` to `26.0.9784` in both
`eng/Version.Details.xml` and `eng/Versions.props`.
[[1]](diffhunk://#diff-fb62e94a1d6f29f863e3d0a22aa38269f6cd1d7f03b109dc06e2cbf2548b86d3L38-R159)
[[2]](diffhunk://#diff-1ea18ff65faa2ae6fed570b83747086d0317f5e4bc325064f6c14319a9c4ff67L65-R68)

Toolset and build infrastructure updates:

* Bumped toolset dependency versions (such as
`Microsoft.DotNet.Build.Tasks.Feed`, `Microsoft.DotNet.Arcade.Sdk`, and
others) to `10.0.0-beta.26057.111` in `eng/Version.Details.xml`, with
updated SHA references.

NuGet package source changes:

* Updated and added new NuGet package sources in `NuGet.config` to match
the new dependency versions and remove obsolete sources.

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.

🟡 Changes recommended

The new test embeds an absolute build-machine analyzer path that is unavailable on remote Helix workers, causing it to fail before checking CA2252.

1 open issue
What changed in this PR

This PR addresses #40045 by suppressing CA2252 on the implicit XML namespace opt-in attribute emitted by MAUI’s .NET 10 XAML source generator. It targets builds using newer SDKs without changing preview warnings for manually applied attributes.

Changes:

  • Wraps the generated attribute in a narrowly scoped CA2252 suppression.
  • Adds a regression test that runs the CA2252 analyzer without an assembly-level preview opt-in.
  • Records the resolved analyzer path in test assembly metadata.
File Description
src/​Controls/​tests/​SourceGen.UnitTests/​SourceGen.UnitTests.csproj Exposes the analyzer path through assembly metadata.
src/​Controls/​tests/​SourceGen.UnitTests/​Maui40045Tests.cs Tests generated implicit namespace opt-in against CA2252.
src/​Controls/​src/​SourceGen/​XamlGenerator.cs Suppresses CA2252 only around the generated attribute.

Review effort: Balanced

<!-- Used by Maui40045Tests to run the CA2252 analyzer over generated code -->
<Target Name="_AddNetAnalyzersPathMetadata" BeforeTargets="GetAssemblyAttributes" DependsOnTargets="ResolveLockFileAnalyzers">
<ItemGroup>
<AssemblyMetadata Include="NetAnalyzersPath" Value="%(Analyzer.FullPath)" Condition="'%(Analyzer.Filename)' == 'Microsoft.CodeAnalysis.NetAnalyzers'" />
@kubaflo

kubaflo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 13, 2026
@MauiBot

This comment has been minimized.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 13, 2026

@github-actions github-actions Bot 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.

Expert Review — 1 finding

Reviewed commit fc5b2fe.

See inline comments for details.

<!-- Used by Maui40045Tests to run the CA2252 analyzer over generated code -->
<Target Name="_AddNetAnalyzersPathMetadata" BeforeTargets="GetAssemblyAttributes" DependsOnTargets="ResolveLockFileAnalyzers">
<ItemGroup>
<AssemblyMetadata Include="NetAnalyzersPath" Value="%(Analyzer.FullPath)" Condition="'%(Analyzer.Filename)' == 'Microsoft.CodeAnalysis.NetAnalyzers'" />

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.

[moderate] Regression Prevention and Test Coverage - This embeds the build machine's absolute analyzer path in the test assembly. eng/helix.proj includes SourceGen.UnitTests for remote Windows/macOS execution, but its payload does not recreate that absolute location. GetPreviewFeaturesAnalyzers() passes the recorded path unchanged to AnalyzerFileReference and Assembly.LoadFrom, so a worker without the originating package-cache path fails while loading the analyzer, before checking CA2252. Copy both NetAnalyzers DLLs into the test output/payload and resolve their paths relative to the deployed test assembly.

kubaflo added a commit that referenced this pull request Nov 13, 2026
…on backports (#40217)

<!-- 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!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

**Explicit release-target exception:** this PR intentionally targets the
new `release/10.0.1xx-sr14` branch. `main`, `net11` and the inflight
lanes are now .NET 11, so .NET 10 SR14 is cut from the SR13 release head
(`release/10.0.1xx-sr14` was created at `54d76458e0`, the tip of
`release/10.0.1xx-sr13`, which already includes all post-cut SR13 fixes
#39830, #39855, #39879, #39891 and the servicing/stable configuration
from #39774).

This PR brings the .NET 10 changes needed since SR13:

1. **Backport #39887** – `[Windows] Prevent duplicate Shell startup
navigation from stale tab selection events`. Fixes #39859 (regressed in
10.0.120); it was merged only to `main`. Clean `cherry-pick -x`.
2. **Backport #40132** – `Fix custom Shape.PathForBounds dispatch
regression`. Fixes #40129 (regressed in 10.0.130); it was merged only to
`candidate/11.0.1xx-sr2`. The unrelated .NET 11
`eng/release-rollover.json` change from that commit is excluded (file
does not exist on the .NET 10 line).
3. **Version bump** – `PatchVersion` 130 → 140 in `eng/Versions.props`.
Servicing label and `StabilizePackageVersion=true` are inherited from
SR13.

Reviewed and intentionally **not** included:

- #40136 (`net10.0` Publish-Build-Assets cleanup): SR13 has no
`Publish-Build-Assets` references, so nothing to remove.
- #39882 (re-land of the CollectionView2 height fix): SR13 already
carries the revert #39855 that fixed #39847; re-landing is a
fix-forward, not a regression fix.
- #40213 (`[net10.0][XSG]` CA2252 suppression, issue #40045): still
open/unmerged; can be backported once approved.
- Other `regressed-in-10.0.1x0` issues closed since the SR13 cut
(#38622, #39557/#39681, #39722) are already fixed on SR13 or were fixed
outside MAUI.

Keep in draft pending review and CI. This PR does not tag, publish, or
authorize a release; the internal dnceng mirror of
`release/10.0.1xx-sr14` has not been created.

#### Validation

Using the pinned SDK `10.0.113` provisioned by `eng/common/dotnet.sh`:

- `dotnet msbuild eng/Versions.props
-getProperty:PatchVersion,SdkBandVersion,PreReleaseVersionLabel,StabilizePackageVersion,DotNetFinalVersionKind`
→ `140`, `10.0.100`, `servicing`, `true`, `release`. `xmllint --noout
eng/Versions.props` passed.
- `dotnet test
src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -f
net10.0 --filter FullyQualifiedName~StrokeShapeTests` (platform TFMs
disabled): **passed 59/59**. With `Shape.cs` reverted to SR13: **failed
3/59** (the new `CustomShapeReimplementingIShape*` tests); restored:
**passed 59/59**.
- #39887 is Windows-only (`ShellItemHandler.Windows.cs` + Windows device
test) and was not built locally on macOS; it relies on CI.

### Issues Fixed

Fixes #39859
Fixes #40129

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

---------
@kubaflo
kubaflo changed the base branch from net10.0 to release/10.0.1xx-sr14 November 13, 2026 13:20
Preserve the release branch's configuration and the original source generator fix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 13:28

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.

🟡 Changes recommended

The tests embed build-machine analyzer paths unavailable on separate Helix workers, causing analyzer loading to fail unless the DLLs and required dependencies are deployed and resolved relative to the test assembly.

2 open issues

Review effort: Balanced

Comment on lines +39 to +42
var netAnalyzersPath = typeof(Maui40045Tests).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
.First(a => a.Key == "NetAnalyzersPath").Value!;
var loader = new AnalyzerLoader();
var analyzers = new[] { netAnalyzersPath, Path.Combine(Path.GetDirectoryName(netAnalyzersPath)!, "Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll") }
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 13, 2026
@kubaflo

kubaflo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot 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.

Expert Review — 1 finding

Reviewed commit 3ce3fb8.

See inline comments for details.

<!-- Used by Maui40045Tests to run the CA2252 analyzer over generated code -->
<Target Name="_AddNetAnalyzersPathMetadata" BeforeTargets="GetAssemblyAttributes" DependsOnTargets="ResolveLockFileAnalyzers">
<ItemGroup>
<AssemblyMetadata Include="NetAnalyzersPath" Value="%(Analyzer.FullPath)" Condition="'%(Analyzer.Filename)' == 'Microsoft.CodeAnalysis.NetAnalyzers'" />

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.

[moderate] Regression Prevention and Test Coverage - This embeds the build machine's absolute analyzer path in the test assembly. eng/helix.proj includes SourceGen.UnitTests for remote Windows/macOS execution, but its payload does not recreate that absolute location. GetPreviewFeaturesAnalyzers() passes the recorded path unchanged to AnalyzerFileReference and Assembly.LoadFrom, so a worker without the originating package-cache or SDK path fails while loading the analyzer, before checking CA2252. Copy both NetAnalyzers DLLs and required dependencies into the test output/payload and resolve their paths relative to the deployed test assembly.

@MauiBot

MauiBot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@StephaneDelcroix — existing-test verification for commit 3ce3fb86.

Result INCONCLUSIVE Platform Android Commit 3ce3fb86


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

🧪 Unit tests
Test group Without fix With fix
Maui40045Tests ⚠ Build blocked ✅ Passed (21s)
Execution log excerpts

Without fix Maui40045Tests

[xUnit.net 00:00:01.64]       Collection: [Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/GlobalXmlns.g.cs(15,12): error CA2252: Using 'AllowImplicitXmlnsDeclarationAttribute' requires opting into preview features. See https://aka.ms/dotnet-warnings/preview-features for more information.]
Collection: [Microsoft.Maui.Controls.SourceGen/Microsoft.Maui.Controls.SourceGen.XamlGenerator/GlobalXmlns.g.cs(15,12): error CA2252: Using 'AllowImplicitXmlnsDeclarationAttribute' requires opting into preview features. See https://aka.ms/dotnet-warnings/preview-features for more information.]
     at Microsoft.Maui.Controls.Xaml.UnitTests.SourceGen.Maui40045Tests.ImplicitXmlnsOptInDoesNotRequirePreviewFeaturesAssemblyAttribute() in /_/src/Controls/tests/SourceGen.UnitTests/Maui40045Tests.cs:line 34

With fix Maui40045Tests

  Determining projects to restore...
  All projects are up-to-date for restore.
Test run for /home/vsts/work/1/s/artifacts/bin/SourceGen.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.SourceGen.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.2 (x64)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.13)
[xUnit.net 00:00:00.13]   Discovering: Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:00.42]   Discovered:  Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:00.45]   Starting:    Microsoft.Maui.Controls.SourceGen.UnitTests
[xUnit.net 00:00:04.10]   Finished:    Microsoft.Maui.Controls.SourceGen.UnitTests
  Passed Microsoft.Maui.Controls.Xaml.UnitTests.SourceGen.Maui40045Tests.ImplicitXmlnsOptInDoesNotRequirePreviewFeaturesAssemblyAttribute [3 s]
Test Run Successful.
Total tests: 1
     Passed: 1
 Total time: 5.1930 Seconds

PR head: 3ce3fb86.

Without-fix baseline: b474cdfe.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 13, 2026
@kubaflo
kubaflo merged commit 72615b7 into release/10.0.1xx-sr14 Nov 13, 2026
93 of 209 checks passed
@kubaflo
kubaflo deleted the stephanedelcroix-issue-40045-implicit-xmlns-ca2252 branch November 13, 2026 18:39
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.

8 participants