Skip to content

Bind stripped SolidColor(long) constructor in Compose UI.Graphics#1471

Merged
jonathanpeppers merged 3 commits into
mainfrom
copilot/compose-ui-solidcolor-fix
Jun 12, 2026
Merged

Bind stripped SolidColor(long) constructor in Compose UI.Graphics#1471
jonathanpeppers merged 3 commits into
mainfrom
copilot/compose-ui-solidcolor-fix

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

androidx.compose.ui.graphics.SolidColor's primary Kotlin constructor takes the @JvmInline value class Color, so the binder drops the constructor even though the JVM bytecode signature is the plain primitive <init>(J)V. The bound type ships with only the internal ACW ctor, forcing consumers to hand-roll JNI to instantiate it (constructor-side sibling of dotnet/java-interop#1440).

Changes

  • ui-graphics-android/Transforms/Metadata.xml: Re-introduce the public ctor via <add-node> + <constructor jni-signature="(J)V">, projecting the value-class param as its underlying long. This mirrors how the existing value-class-param members (getValue-0d7_KjU()J, applyTo-Pq9zytI(...)) are already bound.
  • ui-graphics-android/PublicAPI/PublicAPI.Unshipped.txt: Add SolidColor.SolidColor(long value) -> void.
  • config.json: Bump nugetVersion 1.11.2.11.11.2.2 for ui-graphics and ui-graphics-android.
<add-node path="/api/package[@name='androidx.compose.ui.graphics']/class[@name='SolidColor']">
  <constructor deprecated="not deprecated" final="false" name="SolidColor"
      static="false" visibility="public" bridge="false" synthetic="false"
      jni-signature="(J)V">
    <parameter name="value" type="long" jni-type="J" />
  </constructor>
</add-node>

The generator now emits [Register(".ctor", "(J)V", "")] public unsafe SolidColor(long value), letting downstream code drop its JNI fallback. The <add-node> recipe is confirmed as the accepted workaround for value-class-param constructors and applies to the other affected Compose types (Path, Outline.Rectangle, Painter shapes, Color) pending the generator fix.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix stripped constructor for SolidColor in Compose UI.Graphics Bind stripped SolidColor(long) constructor in Compose UI.Graphics Jun 11, 2026
Copilot AI requested a review from jonathanpeppers June 11, 2026 18:28
The auto-regenerated PublicAPI.Unshipped.txt baseline came from a build
environment missing some Kotlin-related transitive dependencies, which
caused 17 unrelated public APIs to be dropped from the file alongside
the intended SolidColor(long) addition:

  - 5 Brush.Companion gradient overloads taking Kotlin.Pair[] colorStops
  - CanvasHolder.DrawInto(Canvas, IFunction1)
  - Colorspace.Rgb.Eotf/Oetf getters and 2 ctors taking IFunction1 oetf/eotf
  - 3 IntervalTree.{Contains,FindFirstOverlap,FindOverlaps}(IClosedFloatingPointRange)
  - GraphicsLayer.ToImageBitmap(IContinuation)
  - CanvasKt.WithSave(ICanvas, IFunction0)
  - ColorKt.TakeOrElse(long, IFunction0)
  - Colorspace.ConnectorKt.Connectors getter
  - PathDirection.Entries / PathSegment.Type.Entries getters

All confirmed present in the shipping
Xamarin.AndroidX.Compose.UI.Graphics.Android.dll 1.11.2.1 via ilspycmd.
Resetting the file to main and re-applying only the intended one-line
addition for SolidColor.SolidColor(long value) -> void.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers jonathanpeppers marked this pull request as ready for review June 11, 2026 22:08
Copilot AI review requested due to automatic review settings June 11, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the AndroidX Compose UI Graphics bindings to re-expose the androidx.compose.ui.graphics.SolidColor public constructor that is currently stripped due to its Kotlin @JvmInline value class Color parameter, by explicitly re-adding the JVM (J)V constructor signature in metadata. This aligns the binding surface with existing value-class-param members that already project Color as its underlying long, and bumps the NuGet revision to ship the binding-only API change.

Changes:

  • Re-introduce SolidColor(long value) via Transforms/Metadata.xml using <add-node> + <constructor jni-signature="(J)V">.
  • Add the new constructor signature to PublicAPI.Unshipped.txt.
  • Bump nugetVersion for ui-graphics and ui-graphics-android from 1.11.2.1 to 1.11.2.2.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
source/androidx.compose.ui/ui-graphics-android/Transforms/Metadata.xml Adds an explicit (J)V constructor node so SolidColor(long) is generated and usable from C#.
source/androidx.compose.ui/ui-graphics-android/PublicAPI/PublicAPI.Unshipped.txt Records the new public constructor in the API baseline.
config.json Bumps NuGet revision to ship the binding-only API addition without changing Maven versions.

@jonathanpeppers jonathanpeppers merged commit 8964fd7 into main Jun 12, 2026
3 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/compose-ui-solidcolor-fix branch June 12, 2026 20:13
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.

4 participants