Skip to content

Support Color in trimmable Export signatures - #13297

Draft
simonrozsival wants to merge 2 commits into
mainfrom
simonrozsival-investigate-issue-11681
Draft

simonrozsival wants to merge 2 commits into
mainfrom
simonrozsival-investigate-issue-11681

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

Context

Android.Graphics.Color is represented as a Java int, but the trimmable typemap did not apply that mapping to [Export] signatures. As a result, generated direct-dispatch wrappers could use the wrong JNI descriptor or lack the conversions between managed Color values and JNI integers. This change brings the trimmable [Export] path in line with the existing Color marshaling behavior.

Fixes

#11681

Changes

The scanner now recognizes Android.Graphics.Color from Mono.Android and maps it to JNI I, including constructors and recursively jagged arrays. Generated dispatch wrappers convert scalar values between JNI integers and Color; runtime array copying handles Color[] with a bulk JNI read. Tests cover generated signatures, scalar and array marshaling, deep jagged arrays with null rows, and rejection of unrelated lookalike types.

Validation

  • make leeroy CONFIGURATION=Release — passed, 0 errors.
  • dotnet test src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Microsoft.Android.Build.Tasks.Tests.csproj -v minimal --filter 'FullyQualifiedName~TrimmableTypeMapColorExportTests' — passed, 9/9.
  • ./dotnet-local.sh build -t:Install -c Release tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj '-p:AdbTarget=-s emulator-5586' -p:IncludeCategories=ColorExport — passed.
  • cd tests/Mono.Android-Tests/Mono.Android-Tests && ../../../dotnet-local.sh test Mono.Android.NET-Tests.csproj --no-build -c Release -p:IncludeCategories=ColorExport --device emulator-5586 --report-trx --results-directory ../../../bin/TestRelease/TestResults — passed, 4/4.

Map Android.Graphics.Color to Java int in [Export] signatures and marshal scalar and jagged array values through JNI. Add scanner and runtime coverage for Color exports.

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

Copilot-Session: b8771eaf-6e1d-4e59-86f8-4f0cb73f59fb
The updated JNI array region helpers require unsafe contexts.  Keep the Color conversion paths compatible with those helpers and document the buffer and element-range guarantees.

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

Copilot-Session: b8771eaf-6e1d-4e59-86f8-4f0cb73f59fb
@simonrozsival
simonrozsival force-pushed the simonrozsival-investigate-issue-11681 branch from 7b22bde to 2c953b1 Compare November 4, 2026 11:52

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.

1 participant