Repository navigation
[r8] Validate obfuscation mode only when R8 is enabled - #12753
Conversation
Validate AndroidR8ObfuscationMode only when R8 actually executes, avoiding fragile application-property target conditions while reporting XA1050 for unsupported values. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The change is scoped, test-covered, and the only noted feedback is a non-blocking test robustness suggestion.
Pull request overview
This PR moves validation of $(AndroidR8ObfuscationMode) into the R8 MSBuild task so unsupported values surface as XA1050 only when R8 actually runs, avoiding earlier MSBuild-time validation pitfalls.
Changes:
- Add
XA1050validation insideR8.RunTask()to reject unsupported obfuscation modes at execution time. - Add a unit test asserting an invalid mode fails execution and reports
XA1050. - Add localized resources + message documentation and wire it into the docs index/TOC.
File summaries
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/R8Tests.cs | Adds a regression test for invalid obfuscation-mode validation (XA1050). |
| src/Xamarin.Android.Build.Tasks/Tasks/R8.cs | Validates ObfuscationMode at task execution and logs XA1050 on invalid values. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Adds the localized XA1050 message text. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Adds the generated accessor for XA1050. |
| Documentation/docs-mobile/TOC.yml | Adds XA1050 to the docs TOC. |
| Documentation/docs-mobile/messages/xa1050.md | Introduces the XA1050 error documentation page. |
| Documentation/docs-mobile/messages/index.md | Adds XA1050 to the message index. |
Review details
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
- Files reviewed: 6/7 changed files
- Comments generated: 1
- Review effort level: Lite
Move XA1050 validation to the MSBuild target introduced by the release-branch fix and gate it on AndroidLinkTool=r8, so unrelated builds are unaffected. Co-authored-by: Copilot App <[email protected]>
|
/review |
|
✅ Android PR Reviewer completed successfully! Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "azcliprod.blob.core.windows.net"See Network Configuration for more information.
|
There was a problem hiding this comment.
The XA1050 resource, documentation, and R8-only target condition are consistent with the supported AndroidR8ObfuscationMode values. The remaining issue is regression coverage: the test bypasses the normal build graph, so it does not prove that ordinary R8 builds invoke the new validation target.
CI is not green yet: one macOS emulator check is failing and numerous checks remain in progress. The Azure DevOps failure details were unavailable from this environment, so I could not determine whether that failure is related to this change.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
azcliprod.blob.core.windows.net
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "azcliprod.blob.core.windows.net"See Network Configuration for more information.
Generated by Android PR Reviewer for #12753 · copilot · gpt56 · 66.2 AIC · ⌖ 11.3 AIC · ⊞ 21K
Comment /review to run again
## Summary Backports the complete relevant selective R8 obfuscation/optimization work from #12668 to .NET 10 servicing and incorporates the follow-up validation changes from #12753. - keeps `$(AndroidR8ObfuscationMode)` defaulted to `disabled` on .NET 10, preserving existing behavior - makes `private-members` available as an explicit opt-in, enabling R8 optimization while preserving Java class/interface and public/protected member names - adds `XA1050` validation, English resources, documentation, and message documentation for unsupported values - gates mode validation on `$(AndroidLinkTool) == r8`, so unrelated builds are unaffected - adds task, packaging, incremental-build, invalid-mode, R8-only validation, and device coverage - installs both Android default R8 configuration variants ## Release-branch adaptations The release branch predates main's NativeAOT `R8Mapping` and user-Java-source rooting infrastructure. Device coverage is therefore adapted to MonoVM and CoreCLR, reads `mapping.txt` directly, and supplies the explicit keep rule needed for the Java probe. The release task's existing `string[]` configuration-file shape is retained. No `.apkdesc` baselines are changed: unlike main, the .NET 10 servicing default remains `disabled`, and measured targeted packaging/device coverage did not require release baseline updates. No unrelated Java.Interop version changes are included. ## Validation - built `Xamarin.Android.sln` and configured the repository local Android workload - built `Xamarin.Android.Build.Tests` and `MSBuildDeviceIntegration` - R8 task and packaging matrix: 9/9 passed, covering default, explicit `disabled`, explicit `private-members`, incremental builds, metadata/optimization state, invalid-mode `XA1050`, and validation with R8 enabled/disabled - physical-device R8 coverage: 2/2 passed on MonoVM and CoreCLR - changed XML files parse successfully - `git diff --check` passes - final review reported no findings Backport of #12668; includes #12753. Co-authored-by: Copilot App <[email protected]>
Description
Follow-up to #12668 and review feedback on #12752.
Ports
_ValidateAndroidR8ObfuscationModetomainand gates it on$(AndroidLinkTool) == 'r8'. InvalidAndroidR8ObfuscationModevalues report XA1050 only when R8 is selected, while non-R8 builds remain unaffected. This preserves the behavior andprivate-membersdefault introduced by #12668.Tests
dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -v:minimal --no-restoredotnet-local.cmd test bin\TestDebug\net10.0\Xamarin.Android.Build.Tests.dll --filter "Name~InvalidR8ObfuscationModeIsValidatedOnlyForR8" -v:minimalXamarin.Android.Common.targetsandResources.resxgit diff --check