Ship real bindings for Xamarin.AndroidX.Compose.UI.Graphics#1438
Conversation
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
|
@copilot do you need to update the namespaces file with cake target? Also increment version of relevant packages by 0.0.0.1 |
There was a problem hiding this comment.
Pull request overview
This pull request changes the androidx.compose.ui:ui-graphics-android binding from “Java-library-only” to shipping real C# bindings, so Compose consumers can use the graphics API surface (e.g., Brush, Path, ImageBitmap, Outline, Matrix, BlendMode, etc.) via the Xamarin.AndroidX.Compose.UI.Graphics(.Android) NuGets rather than relying on hand-rolled equivalents.
Changes:
- Enabled binding generation for
ui-graphics-androidby removing the blanket package strip and adding explicit namespace (managedName) mappings to preserveUIcasing. - Removed two known generator blockers by stripping the
androidx.compose.ui.graphics.shadowpackage and thePathIteratorinterface. - Updated packaging/template behavior and regenerated
PublicAPI.Unshipped.txtto reflect the newly surfaced API.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| source/AndroidXProject.cshtml | Marks the two UI Graphics NuGets as “real bindings” packages so the “C# bindings are not provided” note is not appended. |
| source/androidx.compose.ui/ui-graphics-android/Transforms/Metadata.xml | Stops stripping the entire API surface; enforces AndroidX.Compose.UI.Graphics* namespaces and removes specific generation blockers. |
| source/androidx.compose.ui/ui-graphics-android/PublicAPI/PublicAPI.Unshipped.txt | Regenerated unshipped public API to include the newly exposed binding surface. |
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Done in commit
|
|
@copilot list of errors: |
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Fixed in 3c3aadb. The 24 errors were all in
Verified |
|
@copilot update the namespaces: Also check if we need to increment version of any new packages by 0.0.0.1. do any PublicApi*.txt files need updated? |
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
... Done.
|
Mirrors #1438 (which un-stripped `ui-graphics-android`) for the remaining Compose styling packages. `ui-text-android` and `ui-unit-android` previously shipped with `<remove-node path="/api/package" />` and exported **zero** public types, forcing managed callers to hand-roll JNI lookups for `FontWeight.Bold`, `Dp.Hairline`, `TextUnit.Unspecified`, etc. ### Metadata transforms - **`ui-text-android/Transforms/Metadata.xml`** — drop the package strip; add `UI`-cased `managedName` for every `androidx.compose.ui.text.*` package. Binding fixes: drop `Comparable` on `FontWeight`; drop `Collection`/`List`/`CharSequence`/`Appendable` on `LocaleList`/`FontListFontFamily`/`AnnotatedString`/`AnnotatedString.Builder`; rename the colliding `append(String)` overload; remove two members leaking the package-private `PlatformLocaleDelegate` and an unreferenced `kotlinx.coroutines.CoroutineDispatcher`. - **`ui-unit-android/Transforms/Metadata.xml`** — drop the strip; add `UI`-cased `managedName`; drop `Comparable` on `Dp`; rename inline-class operator/extension overloads that lower to identical primitive signatures (`Div2`/`Constrain2`/`Minus2`/`Plus2`/`IntRect2`/`Lerp2`/`IsSpecified2`/`IsUnspecified2`/`TakeOrElse2`). Inline value-class types still surface as raw primitives at JNI (e.g. `Dp`→`float`), consistent with the #1438 lowering policy; their companions and constants now bind. ### Packaging / surface - **`AndroidXProject.cshtml`** — add `Xamarin.AndroidX.Compose.UI.Text(.Android)` and `…UI.Unit(.Android)` to `ComposePackagesWithBindings` (suppresses the "C# bindings are not provided" note). - **`published-namespaces.txt`** — add the 13 newly-exposed namespaces. - **`PublicAPI.Unshipped.txt`** — regenerated for both packages. - **`config.json`** — bump `nugetVersion` `1.11.2` → `1.11.2.1` for ui-text, ui-text-android, ui-unit, ui-unit-android. This exposes real C# classes such as `AndroidX.Compose.UI.Text.Font.FontWeight`, `…Text.Style.TextDecoration`, `…Text.TextStyle`, `…Unit.Dp.Companion`, and `…Unit.TextUnit.Companion`. ### foundation-layout-android collisions Once `Dp` becomes resolvable, `foundation-layout-android` surfaces new Dp-based inline-class method collisions (`CS0111`) — anticipated in the issue's foundation note. These are now fixed: - **`foundation-layout-android/Transforms/Metadata.xml`** — add `managedName` renames for the mangled inline value-class overloads that lower to the same primitive signature as their un-mangled siblings: `FlexConfigScope.basis-0680j_4` → `Basis2`; `GridConfigurationScope.column-0680j_4`/`column-XZblgos` → `Column2`/`Column3` and `row-0680j_4`/`row-XZblgos` → `Row2`/`Row3`; plus the matching `ResolvedFlexItemInfo.basis-0680j_4` → `Basis2` on the public implementing class. `GridConfigurationScopeImpl` is package-private, so it isn't bound and needs no transform. This mirrors the inline-class rename approach in `ui-unit-android`. Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Xamarin.AndroidX.Compose.UI.Graphics/.Androidshipped Java-library-only, forcing every Compose consumer to type colors as raw packedlongand re-implement Kotlin'sColorpacking by hand. This un-strips the-androidrecipe soColor,Brush,Shape,Path,ImageBitmap,Outline,Matrix,BlendMode, etc. are bindable.Changes
ui-graphics-android/Transforms/Metadata.xml<remove-node path="/api/package" />.managedNameattrs across all 9 graphics packages to forceUIcasing (androidx.compose.ui.graphics→AndroidX.Compose.UI.Graphics).<remove-node>for two generation blockers:…graphics.shadowpackage — its title-cased namespace collides with the existingShadowspec class (CS0101); kept the class.PathIteratorinterface — auto-generated Invoker can't satisfyIterator.next()'sObjectreturn (CS0738).ui-graphics-android/PublicAPI/PublicAPI.Unshipped.txt— regenerated (~1298 lines).AndroidXProject.cshtml— added both Graphics packages toComposePackagesWithBindings, removing the "C# bindings are not provided" note.published-namespaces.txt— added the 5 new namespaces exposed by the un-stripped binding:AndroidX.Compose.UI.Graphics.Colorspace,.Drawscope,.Internal,.Layer, and.Painter. (AndroidX.Compose.UI.Graphics.Layer.Viewwas removed again — that package emits no bindable public types, soverify-namespace-fileflagged it.)config.json— bumpednugetVersionfor bothXamarin.AndroidX.Compose.UI.GraphicsandXamarin.AndroidX.Compose.UI.Graphics.Androidfrom1.11.2→1.11.2.1. Also bumped bothXamarin.AndroidX.Compose.FoundationandXamarin.AndroidX.Compose.Foundation.Androidfrom1.11.2→1.11.2.1, sincefoundation-androidnow surfaces the new shape bindings.foundation-android/Transforms/Metadata.xml— fixed 24 build errors infoundation-androidthat only surfaced once UI.Graphics became bindable (theandroidx.compose.foundation.shapehierarchy could finally be emitted becauseIShape/CornerBasedShapeare now resolvable). This is purely additive — it surfaces the realRoundedCornerShape,CutCornerShape,AbsoluteRoundedCornerShape,AbsoluteCutCornerShape, andCornerBasedShapebindings (plus factories) that previously couldn't bind at all:Dp) factory overloads are JVM name-mangled (RoundedCornerShape-0680j_4(F)) and collapse onto the plainRoundedCornerShape(F)overload. Removed the mangled overloads inRoundedCornerShapeKt/CutCornerShapeKt/AbsoluteRoundedCornerShapeKt/AbsoluteCutCornerShapeKt, mirroring the existingCornerSizeKtrule.CornerBasedShape.copy(…)is abstract returningCornerBasedShape, but each subclass overrides it with a covariant (subclass-typed) return that the generator emits withoutoverride. PinnedmanagedReturntoAndroidX.Compose.Foundation.Shape.CornerBasedShapeon each subclass'scopy(CornerSize ×4)so the override is recognized.Notes
Inline
@JvmInline value classtypes (Color,Offset,Size,TileMode) surface as rawlong/float(issue option 3b), consistent with the existing Compose bindings; no inline-class support assumed. Example shape:No
-jvm/-androidKMP duplicate clashes surfaced, so no<AndroidIgnoredJavaDependency>entries were required.The common
ui-graphicsrecipe stays stripped — its KMP AAR has noclasses.jar— matching theui/foundationpeer precedent.foundation-android'sPublicAPI.Unshipped.txtwill gain the new shape-class entries on the next full build; it is a build-generated, non-analyzer-gated file (written byMono.ApiTools.MSBuildTasksAfterTargets="Build", not wired into a Roslyn PublicAPI analyzer), so CI regenerates it cleanly. It could not be regenerated in the sandbox becausebinderatehits maven429 Too Many Requests.