[Build] Skip XamlC when no XAML files need XamlC processing#34972
[Build] Skip XamlC when no XAML files need XamlC processing#34972davidnguyen-tech wants to merge 11 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34972Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34972" |
b38cbcf to
00912c6
Compare
28daf7d to
921a0c2
Compare
Replace the single-line header comment with a block that makes explicit the contract the surviving tests protect: SourceGen is the net11.0 default and the XamlC target must not run on default builds. Addresses reviewer feedback on dotnet#34972 that future contributors had no in-file guidance that these are negative tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/review -b feature/refactor-copilot-yml |
|
|
AI code review for net11.0 targetVerdict: Needs changes (also still a Draft) Adds a condition so the legacy Key findings (description ↔ implementation mismatches)
CI note: Confidence: Medium-high on the description/implementation mismatches; the AOT failures need confirmation. This is an automated, non-approval review comment, not a GitHub approval/request-changes. A human must make the merge decision. |
AI code review refresh for net11.0 targetHead reviewed: 710be9ba7fca7cd8f9ff2d3cf5a4496e73ebf946 (this resolves to the current PR head Verdict: Needs changes — the newly added test is failing in CI for a PR-caused reason. This round-two pass focuses on the new commit since the previous fleet review: "Add positive test: XamlC runs when XamlC inflator is used" (which added Blocking finding
Production change assessment (non-blocking)
CI noteRequired Confidence: High on the failing-test root cause (deterministic This is an automated, non-approval review comment — not a GitHub approval or request-changes. A human must make the merge decision. |
XamlC's validate-only pass (Debug default) is the only build-time XAML validation for files using the Runtime or XamlC inflators. SourceGen-only files are validated by XSG itself, so XamlC is redundant for them. Gate the XamlC target on '@(_MauiXaml_XC)' != '' OR '@(_MauiXaml_RT)' != '' (equivalent to '@(_MauiXaml_AsEmbeddedResource)' != ''). Projects using SourceGen exclusively — the default in net11.0 — now skip XamlC entirely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests that don't care about XamlC now lock in the SourceGen default: they assert the build still succeeds and XamlC.stamp is absent. Tests whose subject is the XamlC target itself (incrementality, Clean, DesignTimeBuild contrast, AddNewFile) opt in via -p:MauiXamlInflator=XamlC -p:NoWarn=MAUI1001 so the existing contract is verifiable. Plan originally called for the SourceGen,XamlC combo, but for these synthesised projects the source generator emits a duplicate InitializeComponent (CS0111) when both inflators are active, so the bare XamlC form with NoWarn=MAUI1001 is used instead to silence the deprecation warning under the repo-wide TreatWarningsAsErrors setting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extract XamlC opt-in args + rationale to a single const so the 'why bare XamlC, not SourceGen,XamlC' explanation lives in one place. Apply the same opt-in to TouchXamlFile's body for future-proofing. Reword the misleading inline comment on the DesignTimeBuild precondition. Note: the prior commit message's TreatWarningsAsErrors rationale for NoWarn=MAUI1001 is slightly inaccurate — the synthesized projects under tempDirectory write a fresh Directory.Build.props that does not chain in the repo-root TWAE setting. NoWarn is kept anyway for noise reduction and to be robust if the chain ever changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The XamlC target is gated to SourceGen-default-empty projects in this PR's targets change. Tests that simulated XamlC running on the synthesised single-project scaffold (TargetsShouldSkip, Clean, DesignTimeBuild, AddNewFile, TouchXamlFile) were exercising a code path that no longer executes by default. Delete them along with the XamlCOptIn constant. The contract that XamlC does not run by default is already locked in by BuildAProject, LinkedFile, RandomXml, RandomEmbeddedResource (AssertDoesNotExist on XamlC.stamp), and by NoXamlFiles (log-scrape that the target isn't scheduled). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the single-line header comment with a block that makes explicit the contract the surviving tests protect: SourceGen is the net11.0 default and the XamlC target must not run on default builds. Addresses reviewer feedback on dotnet#34972 that future contributors had no in-file guidance that these are negative tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds XamlCRunsWhenXamlCInflatorUsed to verify the condition gate correctly activates XamlC when _MauiXaml_XC is populated via -p:MauiXamlInflator=XamlC. This is the positive counterpart to BuildAProject which proves XamlC is skipped under SourceGen. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The positive test passed '-warnaserror-:MAUI1001' to opt out of treating the XamlC-deprecation warning as an error. The '/warnaserror-:CODE' negation form is rejected by the rolled-forward .NET 11 preview.5 MSBuild (MSB1001: Unknown switch), failing the synthesized build before XamlC could run. Replace it with the valid '-p:WarningsNotAsErrors=MAUI1001' property, which expresses the same defensive intent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AI code review refresh for net11.0 targetHead reviewed: 2f56ee5 · Target: Verdict: LGTM (CI caveat, not merge-ready while required checks are red). Findings
CI note
Confidence: medium-high. This is a code-review comment only; it is not a GitHub approval and does not override the draft state or required CI failures. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
The skip implementation itself should be good. |
AI code review refresh for net11.0 targetHead reviewed: 4f04377 Verdict: LGTM (CI caveat: not merge-ready while required checks remain red). Findings
CI note
Confidence: medium-high for the code/test review; medium on CI causality because the failing integration jobs are unmatched by Build Analysis. Not an approval. This is an AI review comment only; human maintainers own approval and merge decisions. |
Test Failure Review
✅ Test Failure Review —
|
| Failure | Verdict | Evidence |
|---|---|---|
Build Analysis / parent maui-pr check |
Likely unrelated | The parent check points to build 1447892, whose failed records are the integration-test jobs below; no independent Build Analysis finding tied the failure to src/Controls/src/Build.Tasks/.../Microsoft.Maui.Controls.targets or src/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs. |
maui-pr (Run Integration Tests AOT macOS) |
Likely unrelated | Build 1447892 failed AOT macOS / Run Integration Tests - AOT; log excerpts show AOTTemplateTest.PublishNativeAOTRootAllMauiAssemblies failures with ILC : AOT analysis warning IL3050 and HybridWebView uses dynamic System.Text.Json serialization features, plus IL2009 in apply-preserve-attribute.xml, not XamlC. Base build 1446270 had the same AOT macOS failure and HybridWebView AOT messages. |
maui-pr (Run Integration Tests RunOniOS_MauiRelease ARM64) |
Likely unrelated | Build 1447892 failed AppleTemplateTests.RunOniOS_MauiReleaseTrimFull and _CoreCLR with Project ... failed to build; the root excerpts are ILLink : Trim analysis error IL2026 for Microsoft.Maui.Handlers.HybridWebViewHandler... on net11.0-ios. Base build 1446270 failed the same RunOniOS tests and log 1033 contains the same IL2026/HybridWebView messages. |
maui-pr (Run Integration Tests RunOniOS_MauiReleaseTrimFull ARM64) |
Likely unrelated | Same build 1447892 failed repeated RunOniOS_MauiReleaseTrimFull runs with IL2026 HybridWebView trim errors. The PR scope is XamlC target skipping, and recent base builds 1446270 and 1443637 list the same failed records. |
maui-pr (Run Integration Tests RunOniOS_MauiReleaseTrimFull_CoreCLR ARM64) |
Likely unrelated | Same failure signature as above: _CoreCLR iOS template builds fail on HybridWebView RequiresUnreferencedCodeAttribute trim analysis, not changed XamlC targets/tests. The same failed record appears on recent net11.0 base builds. |
| Authenticated AzDO test-results-only Roslyn/CoreCLR/JIT/crossgen/GC failures | Likely unrelated | The optional authenticated test-run API returned 23 additional distinct failures from run names such as coreclr ... jitstress, Test Windows CoreClr Debug Single Machine, and Roslyn Microsoft.CodeAnalysis...; these are not present in the public maui-pr failed timeline records and do not overlap the PR's changed XamlC files. |
Recommended action
Do not block this XamlC PR on these failures; wait for the existing net11.0 HybridWebView trim/AOT integration-test failures to clear, then rerun maui-pr if a fresh signal is needed.
Evidence details
- PR scope: 2 changed files, both in XamlC/build-test scope:
src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targetssrc/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs
- PR head:
4f04377e6c9f9c1c6ded157ba91d78ac6e91769e; analyzed build 1447892 ran onrefs/pull/34972/mergeat source versionb72964d954650db045f96e818750010ad243d499. - Failed timeline records in build 1447892:
AOT macOS,RunOniOS_MauiRelease ARM64,RunOniOS_MauiReleaseTrimFull ARM64,RunOniOS_MauiReleaseTrimFull_CoreCLR ARM64, and theirRun Integration Tests - ...tasks. - AOT excerpts:
Microsoft.Maui.IntegrationTests.AOTTemplateTest.PublishNativeAOTRootAllMauiAssemblies(...) [FAIL]; messages includeILC : AOT analysis warning IL3050 ... HybridWebView uses dynamic System.Text.Json serialization featuresandIL2009: Could not find method 'System.Void Activated(T)' ... apply-preserve-attribute.xml. - RunOniOS excerpts:
Microsoft.Maui.IntegrationTests.AppleTemplateTests.RunOniOS_MauiReleaseTrimFulland_CoreCLRfailed withProject Test....csproj failed to build; root messages includeILLink : Trim analysis error IL2026 ... Microsoft.Maui.Handlers.HybridWebViewHandler...forTargetFramework=net11.0-ios. - Base comparison from gathered context: the five recent
net11.0base builds included for the same definition were all failed: 1446270, 1443637, 1431279, 1428358, and 1427815. The two newest base timelines list the same failed records as this PR build. Public log search on base build 1446270 also found the same AOT and RunOniOS HybridWebViewIL3050/IL2026messages. - Optional authenticated AzDO test results were available only because local gathering used an Azure CLI token. They include 25 deduplicated entries in context: 2 MAUI log-derived RunOniOS failures plus 23 non-MAUI Roslyn/CoreCLR/JIT/crossgen/GC failures. Because gh-aw normally relies on public build/timeline/log APIs unless
AZDO_TOKENis present, those authenticated test-run rows are treated as local-only enrichment rather than the primary failure signal. - Limitation: data is partial because the context notes authenticated AzDO access used an Azure CLI bearer token locally; the workflow normally relies on public build/timeline/log APIs unless the runner provides
AZDO_TOKEN. - Device-test hidden failures: no
maui-pr-devicetestsbuild/check was present in the gathered context, so XHarness hidden device failures were not applicable to these results.
simonrozsival
left a comment
There was a problem hiding this comment.
LGMT. I was wondering if we're not missing some XSG test coverage - we're switching the default but we're focusing testing on the legacy part still, but we have dedicated test coverage for XSG incrementality, so these changes are good to go I think.
AI code review refresh for net11.0 targetHead reviewed: 4f04377 Verdict: LGTM (CI caveat: not merge-ready while required checks remain red). Findings
CI note
Confidence: medium-high on code/test review; medium on CI causality because required integration checks are red. Not an approval. This is an AI review comment only; human maintainers own approval and merge decisions. |
✅ LGTM — no blocking issues foundLGTM — unanimous across all four review models (4/4), no code-level findings. This is a clean build optimization: it skips the XamlC MSBuild step when no XAML files actually need XamlC processing, avoiding unnecessary work. The change is well-scoped and correct.
Multi-model review (gpt-5.5 · opus-4.8 · opus-4.6 · gemini-3.1-pro). Comments only — not a formal approval. |
|
@StephaneDelcroix hello, could you please check if the test coverage looks good? |
Summary
Skip the XamlC MSBuild target when no XAML files use the XamlC or Runtime inflator — i.e., when all XAML uses the default SourceGen inflator.
Motivation
With SourceGen as the default inflator in .NET 11, the XamlC MSBuild target has nothing to do on a default build: there are no
_MauiXaml_XCor_MauiXaml_RTitems to process. Previously XamlC still ran (inValidateOnly=Truemode for Debug), loading the assembly via Cecil, parsing XAML, validating, and discarding results — all redundant because the Source Generator already validates XAML at compile time.Changes
Microsoft.Maui.Controls.targets(1 line): AddedAND ('@(_MauiXaml_XC)' != '' OR '@(_MauiXaml_RT)' != '')to the XamlC targetCondition, so it only runs when there are files that actually need XamlC processing.MSBuildTests.cs:BuildAProject,LinkedFile,RandomXml,RandomEmbeddedResource,NoXamlFiles) assertXamlC.stampdoes NOT exist under the default SourceGen inflator.XamlCRunsWhenDeprecatedInflatorUsed— a[Theory]covering bothMauiXamlInflator=XamlCand=Runtime, asserting XamlC still runs (covers both branches of the newORcondition).TargetsShouldSkip,Clean,DesignTimeBuild,AddNewFile;TouchXamlFilekept[Skip]), adapted to explicitly opt into the XamlC inflator via the newXamlCOptInconstant.Target Ordering
_MauiXamlComputeInflator(which populates_MauiXaml_XC/_MauiXaml_RT) runs before Compile viaPrepareResourcesDependsOn. XamlC runsAfterTargets="AfterCompile", so the condition is evaluated after the item groups are fully populated.Impact
MauiXamlInflator=XamlCorMauiXamlInflator=Runtimebuilds continue to work unchanged.