Skip to content

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

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

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

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Restore inherited analyzer configuration and make warnings fatal for the selected managed tooling/reference projects instead of relying on CI-only policy.

Production NativeAOT/IL waiver corrections are handled by the merged #13656. This PR contains that work as part of its ancestry but does not duplicate or continue the JavaConvert / SafeArrayFactory / SafeJavaCollectionFactory production diff; those changes belong to #13656 and #13618 remains the focused follow-up for any production waivers still present.

The selected projects' warning policy is now persistent: inherited .editorconfig discovery is restored, strict compiler/MSBuild warning handling remains in those projects, and there is no replacement global suppression layer. It does not migrate frameworks, replace compiler behavior, or change benchmark algorithms.

The warning audit keeps documented historical baselines rather than rewriting valid code for cosmetic diagnostics:

  • Java.Interop retains documented lowercase JNI typedef aliases, including jobject/CS8981.
  • CA1305 keeps its established project/scoped EditorConfig exceptions; provider-only churn was removed.
  • CS0108/CS0114 retain the Mono.Android generated-binding baseline; the broad generator new machinery was removed.
  • CS8632, XML-documentation, obsolete/nullability/Roslyn API, JavaCallableWrappers fixture, and CI package-name warning exceptions retain their prior documented scope.
  • Applicable test IL3050 suppressions were replaced with RequiresDynamicCode plus NativeAOT source exclusion. Production trimming waivers are owned by [Mono.Android] Fix IL3050 in NativeAOT apps and correct trimming waivers #13656/Track remaining Mono.Android trimming/AOT warning waivers #13618, not this warning-policy PR.

This PR keeps the meaningful source/test fixes, including JNI argument names, exact test-shape corrections, source-writer/Java.Interop generator input tracking, and the API-compatibility opt-out being limited to PublicApiAnalyzers. The jobject generated spelling and native signatures are unchanged.

Validation

Measured against current origin/main (c9277ec59f) and the PR head with the same private pinned SDK (12.0.100-alpha.1.26551.101), ordinary checkout, -t:Rebuild, and serial build settings:

for c in Debug Release; do
  "$DOTNET_ROOT/dotnet" build "$solution" -c "$c" -t:Rebuild -m:1 -nr:false -p:UseSharedCompilation=false --disable-build-servers -v:diagnostic "-bl:$logs/$c.binlog"
done

All 16 selected roots are already 0 warnings / 0 errors on current main, and remain 0 warnings / 0 errors on the PR in both configurations. That does not mean the previous policy emitted zero diagnostics: 260 repository EditorConfig downgrades/suppressions hid or demoted diagnostics, and test code also contained project-level NoWarn entries, blanket #pragma warning disable regions, and IL3050 suppressions/pragmas. The PR removes unjustified mechanisms, replaces applicable test IL3050 handling with contracts/exclusion, and restores only documented historical exceptions. The value is therefore persistent strict policy and inherited analyzer execution, not a visible warning-count reduction.

The earlier pre-policy baseline that motivated the null-safety fix produced two CS8602 diagnostics in manifest-attribute-codegen at Extensions/StringExtensions.cs:118 and :135; those are also fixed on current main.

for c in Debug Release; do
  "$DOTNET_ROOT/dotnet" build src/Java.Interop/Java.Interop.csproj -c "$c" --no-restore -m:1 -nr:false -p:UseSharedCompilation=false --disable-build-servers -v:minimal
done

Both Java.Interop builds passed 0 warnings / 0 errors after restoring the documented historical baselines and generated jobject alias.

"$DOTNET_ROOT/dotnet" test tests/generator-Tests/generator-Tests.csproj -c Debug --no-restore -m:1 -nr:false -p:UseSharedCompilation=false --disable-build-servers -v:minimal

489 passed, 0 failed, 0 skipped.

Focused real-source AOT analyzer probes for the NativeAOT-excluded registration fixture and JSON tests build with 0 warnings / 0 errors. The corrected head is currently running Azure build 1697774.

The existing AndroidSdk modern-matrix failure AndroidSdkInfoTests.Constructor_SetValuesFromPath remains reproduced on pre-cleanup published 5d81678bfe; it selects the host-configured JDK instead of the injected PATH and was not hidden. No BenchmarkDotNet or device/emulator benchmark 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 from fb12c02 to ae22a7f Compare November 18, 2026 09:26
simonrozsival and others added 13 commits November 18, 2026 11:29
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Remove per-project EditorConfig discovery bypasses.  Keep formatting and
intentional analyzer errors active, and drop legacy diagnostic disabling
and suggestion-level overrides from all three EditorConfig files.

Co-authored-by: Copilot App <[email protected]>
Honor inherited CA1305 checks instead of disabling their configuration.
Use the current culture for user-facing messages and invariant formatting
for diagnostic identifiers.

Co-authored-by: Copilot App <[email protected]>
Keep assembly names and public key tokens culture-independent, and retain
current-culture formatting for user-facing resolution errors.

Co-authored-by: Copilot App <[email protected]>
Use explicit current-culture diagnostic formatting and remove redundant
format-string parsing around an already formatted package name.

Co-authored-by: Copilot App <[email protected]>
Keep intentional CA1305 checks enabled after removing EditorConfig
suppressions.  Preserve current-culture diagnostic formatting and use
invariant hexadecimal formatting for native handles and identity hashes.
Do not change JNI calls, public contracts, ownership, or unsafe contexts.

Co-authored-by: Copilot App <[email protected]>
Stop disabling globalization checks across whole projects, remove stale
NU1702 demotion from Java.Interop, and drop analyzer exclusions from the
Java callable wrapper tests.  Keep normal SDK warning defaults unchanged.

Co-authored-by: Copilot App <[email protected]>
Remove the need for project-wide globalization exclusions.  Preserve
current-culture messages and registry/XML conversions, while explicitly
using invariant formatting for source code, SDK identifiers, Java version
components, manifest API numbers, and CRC64 package identities.

Co-authored-by: Copilot App <[email protected]>
simonrozsival and others added 15 commits November 21, 2026 08:03
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 <[email protected]>
Put the CA1305 rationale directly above the NoWarn as a single explicit
comment for this test fixture.

Co-authored-by: Copilot App <[email protected]>
Put the CA1305 rationale directly above the NoWarn as a single explicit
comment for generated project and command formatting.

Co-authored-by: Copilot App <[email protected]>
Drop unused CodeDom imports and duplicate globalization imports introduced
while resolving rebase conflicts. No utility behavior changes.

Co-authored-by: Copilot App <[email protected]>
Remove the historical CodeBehind NativeAOT NoWarn block so IL/AOT
analysis warnings are never suppressed by this test fixture.

Co-authored-by: Copilot App <[email protected]>
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 <[email protected]>
Replace the two IL3050 suppressions with RequiresDynamicCode contracts,
including the disposed-peer and empty-registration precondition tests.

Co-authored-by: Copilot App <[email protected]>
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 <[email protected]>
Do not rewrite existing IL waiver history or justifications in this cleanup.
The PR now only replaces dynamic-code suppressions with attributes and
removes an invalid array-type waiver.

Co-authored-by: Copilot App <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Restore XA4218's template-specific message demotion, use MSTest's TestMethod
attribute, and compile NativeAOT-ignored registration tests out before the
MSTest source generator creates its registry. Keep RequiresDynamicCode on
the tests for normal builds and avoid IL suppressions.

Co-authored-by: Copilot App <[email protected]>
Restore the intentional Wear XA4218 demotion, use current MSTest data-row
syntax, and ensure NativeAOT excludes whole dynamic-code fixtures before
source generation while leaving normal test builds unchanged.

Co-authored-by: Copilot App <[email protected]>
@simonrozsival
simonrozsival force-pushed the simonrozsival-benchmark-warning-policy branch from f904fba to 766a5ed Compare November 21, 2026 07:03
simonrozsival and others added 11 commits November 22, 2026 15:30
…vert

ILLink tracks typeof (X<>).MakeGenericType () as X<>, so the
[DynamicallyAccessedMembers (PublicMethods)] parameter of
GetJniHandleConverterForType () already keeps FromJniHandle.
Explain why CoreCLR and PublishAot builds take different paths.

Co-authored-by: Copilot App <[email protected]>
Resolve FromJniHandle on each statically known open collection wrapper, then map its metadata definition onto the closed type. Remove the IL2067 suppression and the PublicMethods requirement without changing the existing dynamic-code guard or MakeGenericType IL2055 rationale.

Add a JavaConvert test category to run the existing conversion fixture independently.

Validation: Release make leeroy and Mono.Android build passed with no IL2067/IL3050 diagnostics from JavaConvert. Full-trim CoreCLR Release and NativeAOT Release app builds passed with TrimmerSingleWarn=false; runtime selection was confirmed from binlogs and APK contents. Device reruns were blocked by boot-time SIGSEGV in both installed emulator versions on an isolated AVD; emulator-5590 was untouched.

Co-authored-by: Copilot App <[email protected]>
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 <[email protected]>
Keep the entire native registration test class inside !NATIVEAOT so the
MSTest source generator cannot register excluded public methods.

Co-authored-by: Copilot App <[email protected]>
Place the !NATIVEAOT endif after the complete registration test class rather
than midway through its methods.

Co-authored-by: Copilot App <[email protected]>
Remove the remaining mid-class endif so the complete test class is excluded
from NativeAOT source generation.

Co-authored-by: Copilot App <[email protected]>
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 <[email protected]>
# Conflicts:
#	src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj
#	src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj
#	tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop-Tests.NET.csproj
#	tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop/JniEnvironmentTests.cs
#	tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop/JniTypeTest.cs
@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
Remove the duplicate test declaration left at the stack merge boundary while
preserving both invalid-reference and local-reference-accounting coverage.

Co-authored-by: Copilot App <[email protected]>

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