Skip to content

[build] Enforce strict warning policy for managed tooling - #13428

Open
simonrozsival wants to merge 114 commits into
mainfrom
simonrozsival-benchmark-warning-policy
Open

simonrozsival wants to merge 114 commits into
mainfrom
simonrozsival-benchmark-warning-policy

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: dffa99844f9ba34c0abc8ba1159fbd70a69f85aa

Dimension Assessment Rationale
Change confidence 9/10 ↑ Warning escalation is defined once in root Directory.Build.props; all 16 affected roots evaluate both properties as true without local declarations.
↑ 32 Debug/Release standalone builds, 883 focused MSTest passes, 41 MTP task passes, and normal/AOT-guarded Android test builds passed.
↓ A clean Mono.Android Release rebuild hits an unrelated JDK 25 javac source/target issue unless those flags are cleared; no device run.

Restore inherited analyzer configuration and make compiler and MSBuild warnings fatal globally instead of relying on CI-only policy or duplicating the properties across projects.

Directory.Build.props now sets <TreatWarningsAsErrors>true</TreatWarningsAsErrors> and <MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors> for repository projects. The 16 project-local copies are removed, as is the now-redundant Mono.Android.csproj declaration.

The nested build files were audited: build-tools/create-packs/Directory.Build.props imports the root file, while the remaining nested props intentionally isolate standalone/file-based cases or external Arcade infrastructure (tests/TrimmingTests/Cases, tools/workload-dependencies, and eng/common/internal). No rogue import was preventing the affected roots from receiving the global policy.

Production NativeAOT/IL waiver corrections are owned by merged #13656. This PR no longer overlaps JavaConvert, SafeArrayFactory, SafeJavaCollectionFactory, or their production test. Generated-member warning handling is owned by merged #13771 and obsolete/Finalize handling by #13773; their changes are preserved rather than duplicated.

The audit keeps only documented historical baselines; it does not alter benchmark algorithms or add a replacement global suppression layer. Relevant retained changes include JNI argument validation, exact test-shape corrections, API-compatibility analyzer scoping, and the generated jobject JNI alias. NativeAOT-incompatible registration tests are excluded from the MSTest source-generated registry where required.

Validation

Merged current origin/main at 5e84e52c53b7e5a468ec21c11cc0f44bdc32f9c8. git diff --check passes and GitHub reports MERGEABLE.

All 16 originally opted-in roots plus Mono.Android evaluate both global properties as true with no project-local warning-escalation declarations. The 16 standalone roots were built in Debug and Release (32/32 builds passed) with:

for project in <16 affected projects>; do
  dotnet build "$project" -c Debug -m:1 -nr:false -p:UseSharedCompilation=false \
    -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false -v:minimal
  dotnet build "$project" -c Release -m:1 -nr:false -p:UseSharedCompilation=false \
    -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false -v:minimal
done

Mono.Android passed in Debug under the global policy. Its clean Release run reached an unrelated JDK 25 javac error (location of system modules is not set for the existing -source 17 -target 17 invocation); Release compilation then passed with only JavacSourceVersion/JavacTargetVersion cleared on the command line. A full local build attempt separately reached a SourceLink-only Repository has no commit worktree error.

dotnet test tests/Xamarin.SourceWriter-Tests/Xamarin.SourceWriter-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
dotnet test tests/Java.Interop.Tools.JavaSource-Tests/Java.Interop.Tools.JavaSource-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
dotnet test tests/Java.Interop.Tools.JavaTypeSystem-Tests/Java.Interop.Tools.JavaTypeSystem-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
dotnet test tests/Java.Interop.Tools.Maven-Tests/Java.Interop.Tools.Maven-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
dotnet test tests/Xamarin.Android.Tools.ApiXmlAdjuster-Tests/Xamarin.Android.Tools.ApiXmlAdjuster-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
dotnet test tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
dotnet test tests/generator-Tests/generator-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false
dotnet test --project tests/Microsoft.Android.Build.BaseTasks-Tests/Microsoft.Android.Build.BaseTasks-Tests.csproj -v minimal -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false

All migrated MSTest suites passed: 883 passed, 4 skipped.

./dotnet-local.sh test --test-modules bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll \
  --filter 'FullyQualifiedName~MonoAndroidHelperTests|FullyQualifiedName~ResolveSdksTaskTests'

Passed 41 tests, 3 skipped through the migrated MTP module runner.

./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj \
  -c Debug -p:IncludeCategories=JniRegistrationSafety
./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj \
  -c Debug -p:PublishAot=true -p:IncludeCategories=JniRegistrationSafety

Both Android test projects compiled with 0 errors. No device or BenchmarkDotNet execution was run.

Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:46

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.

🟢 Approval recommended

No active review issues are reported for the project-local benchmark warning-policy change.

No open issues 🎉

What changed in this PR

This PR makes the benchmark project’s warning policy independent of CI settings, without changing benchmark behavior or repository-wide configuration.

Changes:

  • Treats compiler and MSBuild warnings as errors in every configuration.
  • Disables .editorconfig discovery for this project so analyzer defaults apply instead of inherited severity overrides, while retaining SDK/package analyzers and SDK global analyzer configuration.
File Description
tests/​Xamarin.Android.Tools.Benchmarks/​Xamarin.Android.Tools.Benchmarks.csproj Adds project-local warnings-as-errors settings and disables .editorconfig discovery.

Review effort: Balanced

@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13428

@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.

Code assessment: no blocking findings; CI pending. 0 ❌ errors, 0 ⚠️ warnings, 1 💡 non-blocking inline suggestion.

The change is appropriately scoped to the benchmark project: compiler and MSBuild warnings become errors for local configurations as well as CI, and automatic EditorConfig discovery is disabled without removing analyzer references or changing benchmark algorithms. I reviewed the full project, benchmark sources, referenced project configuration, repository warning policy, and relevant EditorConfig settings. The Debug/Release builds and negative probes reported in the description provide useful evidence, but I could not independently reproduce them here.

CI: GitHub reported 41 checks: 6 successful, 34 in progress, and 1 queued, with no failures reported at inspection time. These include the still-running Azure DevOps build 1671055; this is not yet a green-CI verdict. Direct Azure build/timeline retrieval was blocked by CLI initialization/authentication errors. The local dotnet build tests/Xamarin.Android.Tools.Benchmarks/Xamarin.Android.Tools.Benchmarks.csproj --no-restore -c Release --nologo attempt failed during .NET first-use initialization (NuGet-Migrations mutex), before project evaluation or compilation. The worktree remains unchanged.

Generated by Android PR Reviewer for #13428 · copilot · gpt61 · 21.9 AIC · ⌖ 7.56 AIC · ⊞ 19.4K
Comment /review to run again

@simonrozsival simonrozsival changed the title [tests] Enforce benchmark warning policy [build] Enforce project-local warning policies Nov 9, 2026
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Android PR Reviewer for #13428

@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.

Code assessment: no blocking findings — 0 ❌ errors, 0 ⚠️ warnings, 1 💡 optional inline suggestion.

Reviewed all 17 changed files at 5d81678bfe8e9975172b5ca9d56ed0eb82d4c56d, their shared build configuration, and the manifest helpers’ implementation and callers. The warning-policy additions are consistent across the 16 projects, without changing their target frameworks, references, signing, or reference-only output. The explicit null guards preserve the helpers’ existing behavior. The switch to SDK analyzer defaults is an intentional policy replacement, rather than a guarantee that every previously enabled repository diagnostic remains enabled.

CI: All 40 GitHub checks report completed/success, including the aggregate dotnet-android check for Azure build 1672500. Independent Azure build/timeline verification was blocked because az devops invoke requires authentication in this environment, so full CI verification remains incomplete. This was a static review; the description’s local build/test results were not independently rerun.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • 169.254.169.254

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "169.254.169.254"

See Network Configuration for more information.

Generated by Android PR Reviewer for #13428 · copilot · gpt61 · 32.3 AIC · ⌖ 4.44 AIC · ⊞ 20.2K
Comment /review to run again

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 13, 2026
@simonrozsival simonrozsival changed the title [build] Enforce project-local warning policies [build] Honor inherited analyzers and remove blanket warning waivers Nov 13, 2026
@simonrozsival simonrozsival removed the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 14, 2026
@simonrozsival
simonrozsival force-pushed the simonrozsival-benchmark-warning-policy branch 2 times, most recently from ae22a7f to 77298f7 Compare November 18, 2026 10:36
@simonrozsival simonrozsival changed the title [build] Honor inherited analyzers and remove blanket warning waivers [build] Enforce strict warning policy for managed tooling Nov 18, 2026
@simonrozsival
simonrozsival force-pushed the simonrozsival-benchmark-warning-policy branch from f904fba to 766a5ed Compare November 21, 2026 07:03
@simonrozsival
simonrozsival changed the base branch from main to dev/simonrozsival/trimming-waivers November 24, 2026 11:04
Base automatically changed from dev/simonrozsival/trimming-waivers to main November 24, 2026 15:12
simonrozsival and others added 6 commits November 27, 2026 16:44
Benchmark builds rely on CI-only warnings-as-errors and inherit legacy
analyzer severity overrides from the repository editorconfig.

Treat compiler and MSBuild warnings as errors in every configuration.
Disable editorconfig discovery for this project so installed analyzer
defaults apply, while SDK/package analyzers and global configs remain
active.  Leave benchmark sources and shared configuration unchanged.

Fresh Debug and Release builds pass without warnings.  Temporary compiler,
MSBuild, and default analyzer warning probes fail in both configurations;
the analyzer control confirms the inherited exclusion is no longer used.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Opt five additional host/reference projects into the warning policy used
by the desktop benchmarks.  Treat compiler and MSBuild warnings as errors
and use installed analyzer defaults instead of inherited legacy severity
overrides.

Keep the current frameworks, reference-only output, extended analyzer
rules, package references, and source sets unchanged.  No editorconfig or
shared build policy is added.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the compiler, analyzer, and MSBuild warning probes repeatable without
adding permanent benchmark sources.  Verify specific error codes and a
failing exit status in Debug and Release, reject unrelated failures, and
remove temporary inputs before checking clean builds again.

Document the standalone PowerShell check in the test catalog.  The helper
does not execute benchmarks or change warning severity on the command
line.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Apply the project-local warning policy to nine additional Java.Interop
libraries/tests and the manifest attribute generator.  Preserve their
frameworks, signing, generation targets, references, and analyzer defaults.

Check null explicitly before the manifest generator's HasValue guards so
nullable flow analysis can prove subsequent string accesses are safe.
Keep null, empty, whitespace, and delimiter behavior unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Do not interpret the literal #warning text inside a CS1030 error message
as another diagnostic.  Anchor parsing to the diagnostic line prefix while
still rejecting unexpected codes, warning severities, and unrelated
uncoded errors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the benchmark warning-policy script at the user's request and drop
its test catalog entry.  Leave all project-local warning policies and
production sources unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival and others added 17 commits November 27, 2026 17:09
The warning-policy cleanup does not need to change null handling in the
SupportedOSPlatformVersion helper. Restore main's behavior and remove the
test that only covered that incidental change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Put the CA1305 rationale directly above the NoWarn as a single explicit
comment for this test fixture.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Put the CA1305 rationale directly above the NoWarn as a single explicit
comment for generated project and command formatting.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Drop unused CodeDom imports and duplicate globalization imports introduced
while resolving rebase conflicts. No utility behavior changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the historical CodeBehind NativeAOT NoWarn block so IL/AOT
analysis warnings are never suppressed by this test fixture.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace blanket AOT suppressions with RequiresDynamicCode contracts on all
registration tests and their helper methods. Runtime feature guards remain
for test execution, and the strict AOT analyzer compile stays clean.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Annotate both reflection-based JSON tests with RequiresDynamicCode in
addition to their trimming contract. Use MSTest's Inconclusive marker when
the runtime cannot generate code.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Normalize C# compiler warning codes to CS#### in Java.Interop, Mono.Android,
and Xamarin.Android.Build.Tasks, including the matching inline rationales.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove runtime dynamic-code branches from registration tests. The fixture's
NativeAOTIgnore category excludes these cases, while RequiresDynamicCode
provides the compile-time contract.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The referenced manifest attribute types moved out of the build task test
assembly on main, so this test no longer describes a callable path. Remove
only the stale test that caused CS0246 on all host build jobs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move the NATIVEAOT conditional around the complete test class so MSTest never
parses public test methods outside a type under the excluded configuration.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the entire native registration test class inside !NATIVEAOT so the
MSTest source generator cannot register excluded public methods.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Place the !NATIVEAOT endif after the complete registration test class rather
than midway through its methods.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the remaining mid-class endif so the complete test class is excluded
from NativeAOT source generation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Place #endif after the final class/namespace braces, not between test
methods. This excludes the whole fixture from NativeAOT source generation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep nullable public metadata shapes and remove the redundant source-writer test after rebasing onto main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival force-pushed the simonrozsival-benchmark-warning-policy branch from 4c5af9d to 6b36b9d Compare November 27, 2026 16:43
Resolve the Mono.Android warning baseline by preserving the latest main configuration.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival and others added 2 commits November 30, 2026 19:28
Preserve the JNI registration test exclusions and annotate the newly-added registration validation test for dynamic code.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers

Copy link
Copy Markdown
Member

/azp run Xamarin.Android-PR

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@jonathanpeppers

Copy link
Copy Markdown
Member

Internal Xamarin.Android-PR build 16171135 failed. I reviewed the failures, and none of them appear to be caused by this PR. They can be ignored:

Failure Why it can be ignored
Task: PoliCheck English / Run PoliCheck Post Analysis Fails on every main build. #13838 fixes it.
Task: Windows > Build & Smoke Test / Ensure no modified/untracked files Untracked .sarif file left by the Guardian tools. Fails on every main build.
Test: BuildTest2.BuildReleaseArm64 (True,CoreCLR,True) Also fails on unrelated PRs (for example #13388, #13428, #13651, #13852).
Test: BuildTest2.BuildInParallel (CoreCLR) Also fails on unrelated PRs (for example #13388, #13428, #13651, #13852).
Test: BuildTest2.BuildProguardEnabledProject ("",NativeAOT) Network error in the log: Failed to download package.
Test: BuildTest2.BuildProguardEnabledProject ("android-arm64",CoreCLR) Network error in the log: Failed to download package.
Test: BuildTest2.BuildProguardEnabledProject ("android-arm64",NativeAOT) Network error in the log: Failed to download package.
Test: IncrementalBuildTest.AppProjectTargetsDoNotBreak (CoreCLR) Network error in the log: Failed to download package.
Test: NuGetPackageVersionFinderTests.ShortTaskNameResolvesWithNuGetMetadataInFullMSBuild Fails on every main build.

The public CI (dnceng-public) is offline, so this internal build is the only CI result.

@jonathanpeppers jonathanpeppers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is setting properties in a lot of projects, and I think we should fix the global setting instead.

simonrozsival and others added 2 commits December 1, 2026 23:31
Enable compiler and MSBuild warnings-as-errors from the root build props and remove redundant per-project declarations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

3 participants