Skip to content

[Mono.Android] Enumify, stabilize API-37.1 - #12418

Merged
jonathanpeppers merged 3 commits into
dotnet:mainfrom
jonpryor:dev/jonpryor/jonp-enumify-api-37.1
Aug 21, 2026
Merged

[Mono.Android] Enumify, stabilize API-37.1#12418
jonathanpeppers merged 3 commits into
dotnet:mainfrom
jonpryor:dev/jonpryor/jonp-enumify-api-37.1

Conversation

@jonpryor

@jonpryor jonpryor commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Stabilizes and enumifies Android API 37.1 using BindingStudio, following the API enumification work in #10005.

  • Marks API 37.1 stable and updates the build configuration to handle dotted API versions correctly.
  • Adds the API 37.1 enum field and method mappings, including normalized Java package and nested-type names so the mappings match API XML.
  • Adds the API 37.0/37.1 manifest elements and metadata while preserving all historical pre-37 manifest introduction levels and metadata entries.
  • Improves unsupported-API diagnostics by listing the supported API levels.
  • Updates the API-level workflow to normalize BindingStudio method-map output once and avoid appending raw JNI-formatted rows.

map.csv formatting

Current dotnet/java-interop output includes a trailing comma on every map.csv row, which would make the generated diff unnecessarily noisy. The trailing commas were removed before applying the API 37.1 changes:

tr -d '\r' < src/Mono.Android/map.csv > src/Mono.Android/new-map.csv
sed 's/,$//' < src/Mono.Android/new-map.csv > src/Mono.Android/map.csv

As a namespace-casing sanity check, enumification should produce no matches for:

git grep '\.[A-Z][a-z]\.' src/Mono.Android/map.csv

Two-letter namespace components must remain uppercase.

Validation

The manifest attribute generator succeeds with the complete Android platform set installed, confirming that the new API 37.0/37.1 entries coexist with the restored historical manifest data.

A future update can replace map.csv with unmodified BindingStudio output after the trailing-comma behavior is corrected upstream.

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-enumify-api-37.1 branch from 7cd9380 to 2ba02cb Compare August 18, 2026 10:56
@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12418

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

⚠️ Needs Changes

Found 1 error and 2 suggestions. The API 37.1 stabilization and dotted-version MSBuild handling are coherent, but the embedded photo-picker constants and their accessor methods currently generate two different managed enum types; that public API inconsistency needs correction before 37.1 is marked stable. I also noted two public enum naming inconsistencies inline.

CI was not green when reviewed: Package Tests macOS > Tests > APKs 2 had failed, and six lanes were still in progress. The available check metadata did not establish that the package-test failure was caused by this diff.

Generated by Android PR Reviewer for #12418 · gpt56 · 167.5 AIC · ⌖ 17.2 AIC · ⊞ 25.6K
Comment /review to run again

Comment thread src/Mono.Android/map.csv Outdated
Comment thread src/Mono.Android/map.csv Outdated
Comment thread src/Mono.Android/map.csv Outdated
@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-enumify-api-37.1 branch 2 times, most recently from c952227 to f384c70 Compare August 18, 2026 15:03
@jonpryor

Copy link
Copy Markdown
Contributor Author

/review

1 similar comment
@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer was cancelled. Please review the logs for details.

Generated by Android PR Reviewer for #12418

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12418

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

❌ Reject

Findings: 1 error, 0 warnings, 0 suggestions.

The API 37.1 enum mappings and version-aware MSBuild conditions look consistent, and all 44 CI checks passed. However, manifest-definition.xml resets historical manifest API levels to 35 and must be regenerated from the complete SDK platform set before merge.

Generated by Android PR Reviewer for #12418 · gpt56 · 174.3 AIC · ⌖ 8.85 AIC · ⊞ 25.6K
Comment /review to run again

Comment thread build-tools/manifest-attribute-codegen/manifest-definition.xml Outdated
@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12418

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

Reviewed all API 37.1 stabilization changes, including the full changed-file context, enum/method mappings, manifest metadata history, dotted API-level MSBuild handling, and the PR’s stated BindingStudio goal. The follow-up commit restores the historical manifest introduction levels, and I found no correctness or compatibility defects in the current revision.

One non-blocking C# formatting suggestion is attached inline. The completed 44-check Azure pipeline is green; one successful macOS emulator lane is currently being rerun, with no failed checks.

Generated by Android PR Reviewer for #12418 · gpt56 · 212.5 AIC · ⌖ 8.9 AIC · ⊞ 25.6K
Comment /review to run again

@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) August 19, 2026 17:42
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Aug 19, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member

@dalexsoto review

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

All 16 new src/Mono.Android/methodmap.csv rows use slash-separated package names (and two use $ for nested types), but ApiTransform inserts those values verbatim into XPath queries against dotted API XML. None of the mappings match, exact-head CI reports BG8A04 for them, and the affected APIs remain int instead of using the new enums. Please normalize package/nested-type names or use dotted syntax, regenerate API 37.1, and verify the warnings disappear and public signatures use the intended enums.

jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Aug 19, 2026
The *existence* of an Android QPR1 API-37.1 release alongside an
Android QPR2 API-37.2 beta release throws us into a new scenario: the
need for (at least?) *three* workload packs:

  * API-37 [stable]
  * API-37.1 [currently unstable, but see dotnet#12418]
  * API-37.2 [unstable]

(It would not surprise @jonpryor if there's a 4th by the time we're
done with API-37.*…)

However, thus far we've only ever expected *two* packages, so the
need for a third is unique.

Add a new `@(AndroidBuildApiLevel)` item group to
`Configuration.props`, which lists all the Android API levels to
build, along with the information required to build them (associated
framework version, platform id, is it *unstable*).

Update `ConfigureWorkload.targets` so that instead of "hardcoding"
`@(_FrameworkListOutputs)` against a specific list of of API levels
(`$(AndroidDefaultTargetDotnetApiLevel)` {?!},
`$(AndroidLatestStableApiLevel)`, `$(AndroidLatestUnstableApiLevel)`),
it uses `@(AndroidBuildApiLevel)`.  However, MSBuild item expansion
*does not like* using multiple item groups, e.g.:

	<_RuntimeListOutputs Include="…%(AndroidAbiAndRuntimeFlavor.AndroidRuntime).%(AndroidBuildApiLevel.Identity)…" />

Work around this problem by using a "cross join" across item groups
by using an intermediate Target + `@(_AndroidBuildInfo)` item group,
allowing use of a *single* item group:

	<_RuntimeListOutputs Include="…%(_AndroidBuildInfo.AndroidRuntime).%(_AndroidBuildInfo.Identity)…" />

Update the `BuildExtraApiLevels` target to build all API levels within
`@(AndroidBuildApiLevel)`, overriding MSBuild properties based on the
`@(AndroidBuildApiLevel)` item metadata.

Update `tests` so that the `_AddMonoAndroidReference` target finds
and uses *stable* bindings.  If it references an *unstable* binding,
we get a bunch of CS0246 errors as *nothing can be found*, as
`-p:EnablePreviewFeatures=true` is required when referencing an
unstable binding…
auto-merge was automatically disabled August 19, 2026 20:04

Head branch was pushed to by a user without write access

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-enumify-api-37.1 branch from e27c176 to 41fb204 Compare August 19, 2026 20:04
Context: http://github.com/jpobst/BindingStudio
Context: dotnet#10005

Use jpobst/BindingStudio to enumify API-37.1.

Note: current dotnet/java-interop emits an "extra" `,` on `map.csv`
output, which would make for a "noisy" diff (every line changed!).
The diff size is reduced by removing trailing commas:

	tr -d '\r' < src/Mono.Android/map.csv > src/Mono.Android/new-map.csv
	sed 's/,$//' < src/Mono.Android/new-map.csv > src/Mono.Android/map.csv

This keeps the diff to a reasonable size.

Sanity check: during enumification, this should have no matches:

	git grep '\.[A-Z][a-z]\.' src/Mono.Android/map.csv

Two-letter namespace parts should be all upper-case.

TODO (lol): update `map.csv` to current BindingStudio output after
this is merged.
@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-enumify-api-37.1 branch from 41fb204 to 4723893 Compare August 19, 2026 20:06
@jonpryor

Copy link
Copy Markdown
Contributor Author

@dalexsoto wrote:

All 16 new src/Mono.Android/methodmap.csv rows use slash-separated package names (and two use $ for nested types)

I was initially confused by this, because every entry in methodmap.csv since API-36.1 was using /, 292 entries including those in API-37.1!

As changing the API-36.1 and API-37 entries would likely break API, I have corrected the API-37.1 entries.

Additionally, I have updated HowToAddNewApiLevel.md to explicitly note this fix.

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

The force-updated head reintroduces the historical manifest corruption in build-tools/manifest-attribute-codegen: 66 existing element and 429 attribute introduction levels are reset to API 35, historical formats/parent data change, six attributes disappear, and four required non-ignored metadata entries are removed. The all-platform generation workflow consequently fails its metadata-accounting check. Please restore every pre-37 definition and metadata entry from the base/restored head while retaining only the verified 37.0/37.1 additions.

Restore the pre-37 manifest definitions and required metadata entries that were lost when API 37.1 was regenerated from an incomplete platform set.

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

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12418

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

⚠️ Needs Changes

Findings: 0 errors, 0 warnings, 1 suggestion.

The current revision resolves the earlier enum-mapping and manifest-history defects, and the API 37.1 mappings, dotted-version MSBuild handling, and restored manifest metadata are coherent. I left one non-blocking inline suggestion to automate validation of newly imported methodmap.csv naming syntax.

The current Azure pipeline rerun has no failures, but its Windows, Linux, and macOS build lanes are still in progress and the aggregate check is queued, so CI completion remains the merge gate.

Generated by Android PR Reviewer for #12418 · gpt56 · 165.4 AIC · ⌖ 8.94 AIC · ⊞ 25.7K
Comment /review to run again

Comment thread Documentation/workflow/HowToAddNewApiLevel.md

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

HowToAddNewApiLevel.md first normalizes BindingStudio method-map package/nested-type names, but the later “Finishing the method map” section exports and copies raw output into methodmap.csv again. Following the document sequentially can append both normalized and raw rows, while following only the final section recreates slash/$ mappings that produce BG8A04 and leave APIs typed as int. Please consolidate the instructions or make the final step append only the normalized new-methodmap2.csv output once.

Clarify that the normalized BindingStudio output is the final method map so contributors do not append the raw JNI-formatted rows a second time.

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

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

The consolidated method-map normalization still leaves BindingStudio interface rows invalid. BindingStudio emits the class column as I:Type, while ApiTransform recognizes only [Interface]; the documented command normalizes / and $ but leaves I: unchanged. Replaying it on an actual interface row matches zero API XML nodes and would produce BG8A04, leaving the managed API typed as int. Please convert I: to [Interface] in the single normalization/export step.

@jonathanpeppers

jonathanpeppers commented Aug 20, 2026

Copy link
Copy Markdown
Member

Regarding #12418 (review): this does not identify a defect in the API 37.1 changes or require changing any previously shipped API level. None of the new API 37.1 method-map rows target interfaces. The concern applies only to the future BindingStudio workflow documented in this PR: an interface row may be exported as I:Type, while methodmap.csv expects [Interface]Type. That would be a useful non-blocking documentation follow-up, but it should not block this API stabilization PR. We'll evaluate merge readiness once CI completes.

@jonathanpeppers

Copy link
Copy Markdown
Member

@dalexsoto stamp

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

Stamping as requested by @jonathanpeppers; no code review performed.

@jonathanpeppers
jonathanpeppers merged commit 90fee6f into dotnet:main Aug 21, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants