Bind stripped SolidColor(long) constructor in Compose UI.Graphics#1471
Merged
Conversation
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
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>
There was a problem hiding this comment.
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)viaTransforms/Metadata.xmlusing<add-node>+<constructor jni-signature="(J)V">. - Add the new constructor signature to
PublicAPI.Unshipped.txt. - Bump
nugetVersionforui-graphicsandui-graphics-androidfrom1.11.2.1to1.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
approved these changes
Jun 12, 2026
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.
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 underlyinglong. 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: AddSolidColor.SolidColor(long value) -> void.config.json: BumpnugetVersion1.11.2.1→1.11.2.2forui-graphicsandui-graphics-android.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.