[Microsoft.Android.Build.Tasks] Add typemap rule generators - #12822
Open
simonrozsival wants to merge 1 commit into
Open
simonrozsival wants to merge 1 commit into
simonrozsival wants to merge 1 commit into
Conversation
Establish the shared retained-key contract before adding the runtime extractors and R8 pipeline wiring. Layer 1 of 6 splitting #12821 uses the frozen source at 87bd3f8. Add canonical JNI key helpers and deterministic UTF-8/LF generators for class-only keep rules and all-member rules scoped to retained classes. Reject invalid records before overwriting existing output. Add shared XA4327/XA4328 diagnostics without retiring the active legacy diagnostics, plus isolated production-task unit coverage. No build pipeline behavior changes; activation comes in later layers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The generator mishandles some failure diagnostics and does not consistently follow the task error-state contract.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (3)
What changed in this PR
Adds shared typemap key utilities and ProGuard generator tasks for later runtime-specific adapters.
Changes:
- Generates sorted class-only and member-preserving ProGuard rules.
- Adds canonical key helpers and localized XA4327/XA4328 diagnostics.
- Adds production-task references, tests, and documentation.
| File | Description |
|---|---|
src/Microsoft.Android.Build.Tasks/Tasks/GenerateTypeMapProguardConfiguration.cs |
Core rule generator |
src/Microsoft.Android.Build.Tasks/Tasks/GenerateTypeMapMemberProguardConfiguration.cs |
Member rule variant |
src/Microsoft.Android.Build.Tasks/Utilities/TypeMapClassName.cs |
JNI class-name extraction |
src/Microsoft.Android.Build.Tasks/Utilities/TypeMapKey.cs |
Alias normalization |
src/Xamarin.Android.Build.Tasks/Properties/Resources.resx |
New diagnostics |
src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs |
Generated resource accessors |
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TypeMapTaskBuildEngine.cs |
Minimal test build engine |
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests.csproj |
Production task reference |
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TypeMapProguardTests.cs |
Generator tests |
src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/GenerateTypeMapProguardConfigurationTests.cs |
NUnit coverage |
Documentation/docs-mobile/messages/xa4327.md |
XA4327 documentation |
Documentation/docs-mobile/messages/xa4328.md |
XA4328 documentation |
Documentation/docs-mobile/messages/index.md |
Message index entries |
Documentation/docs-mobile/TOC.yml |
Documentation navigation |
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
| foreach (var name in classes) { | ||
| WriteClassRule (writer, name); | ||
| } | ||
| } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException || ex is DecoderFallbackException) { |
| string currentFile = ""; | ||
| try { | ||
| if (TypeMapKeyFiles.Length == 0) { | ||
| Log.LogCodedError ("XA4328", Properties.Resources.XA4328, "", Properties.Resources.XA4328_NoInputs); |
| try { | ||
| if (TypeMapKeyFiles.Length == 0) { | ||
| Log.LogCodedError ("XA4328", Properties.Resources.XA4328, "", Properties.Resources.XA4328_NoInputs); | ||
| return false; |
simonrozsival
added this pull request to stack #12830
September 18, 2026 19:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Layer 1 of 6 splitting #12821; build activation comes in later layers.
Establish a shared retained-Java-key contract so the runtime-specific extractors can feed the same ProGuard generators without duplicating rule generation. This is a focused slice of the validated source at
87bd3f8a8b512859339e5446c1f86709a6c28c3b, based onmainatd63fe4c9f8cf8def6049c9415bb0abf4269ee0f5.Scope and contract
<GenerateTypeMapProguardConfiguration/>, which unions canonical keys and emits only-keep classrules. Reject invalid names/rule injection and missing inputs before overwriting output; valid empty inputs produce empty output.<GenerateTypeMapMemberProguardConfiguration/>, which keeps all members of retained classes. This is not precise-method inference.No extractors, target imports,
UsingTaskactivation, R8 policy changes, runtime changes, or DGML removal are included. The standaloneTypeMapProguardTestsfixture is intentionally a generator-only subset; later layers add its adapter/target/configuration coverage.Validation
dotnet test tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests.csproj -v minimal --filter 'FullyQualifiedName~TypeMapProguardTests'15 passed, 0 failed, 0 skipped, compiling the actual modern production task project and its source-linked shared resources.
The focused NUnit command was also attempted. Its existing legacy
Xamarin.Android.Build.Tasksproject reference requires the missingbin/BuildDebug/net10.0/xa-prep-tasks.dll(GitBlame/GitCommitHash, MSB4062) in this clean worktree. The unchanged frozen-source fixture is retained; no full SDK/bootstrap build or test-project infrastructure changes were made.git diff --checkpasses. Complete extracted files match the frozen source byte-for-byte; retained standalone test/helper methods match the frozen source. The diff is additive only: 14 files, 546 insertions.