Repository navigation
Bump Compose UI.Graphics to 1.11.2.1, port colors to ColorKt - #77
Merged
Merged
Conversation
Switches Modifier.Background/Border to take a packed Compose Colorlong directly (the value Kotlin's @JvmInline value class Color uses)
instead of an Android.Graphics.Color that we hand-packed via
PackComposeColor. Call sites build the packed long via the now-bound
AndroidX.Compose.UI.Graphics.ColorKt.Color(int red, int green,
int blue, int alpha) factory.
Xamarin.AndroidX.Compose.UI.Graphics{,.Android} 1.11.2.1 transitively
requires Compose.UI.Unit 1.11.2.x, which version-locks the rest of the
1.11.x stack to 1.11.2 (no .1 published yet for UI/UI.Android/
Foundation.Layout/Runtime). Bumped accordingly in
Directory.Build.targets. Material3 1.4.0.x has minimum-version
dependencies on the 1.11.x stack so it stays put.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Updates the repo’s Compose dependency set to the 1.11.2/1.11.2.1 line and switches the facade/samples from Android.Graphics.Color to the now-bound Compose Color packing (represented as a long), constructed via AndroidX.Compose.UI.Graphics.ColorKt.
Changes:
- Bumped central Compose package versions and added
Xamarin.AndroidX.Compose.UI.Graphics{,.Android}references. - Updated
Modifier.Background/BorderAPIs to accept packed ComposeColor(long) directly and removed the AndroidColorpacking helper. - Updated sample and Jetchat call sites/docs to create colors via
ColorKt.Color(...)and droppedusing Android.Graphics;.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ComposeNet.Sample/MainActivity.cs | Switched sample color creation to ColorKt.Color(...) and removed Android Color usage. |
| src/ComposeNet.Compose/Modifier.cs | Changed Background/Border to take packed Compose Color (long), removed packing helper, updated XML docs. |
| src/ComposeNet.Compose/ComposeNet.Compose.csproj | Added Compose UI.Graphics package references needed for ColorKt usage. |
| samples/Jetchat/README.md | Updated documentation to reflect new Background(long) / Border(int, long, ...) signatures and ColorKt construction. |
| samples/Jetchat/Conversation.cs | Converted static palette colors from Android.Graphics.Color to packed Compose long via ColorKt. |
| README.md | Updated Compose version references in repo-level docs to 1.11.2.x. |
| Directory.Build.targets | Central package version bump to 1.11.2 / 1.11.2.1 and added UI.Graphics version entries. |
Reorder the two ColorKt.Color factories the doc comment points at to recommend the per-channel (int, int, int, int) overload first, since the (int) overload can't be called with a bare 0xAARRGGBB literal in C# when alpha is set (0xFF... is uint, not int). Notes the unchecked((int)0xFF...) cast for consumers who do reach for the int overload. Co-authored-by: Copilot <[email protected]>
jonathanpeppers
added a commit
that referenced
this pull request
Jun 5, 2026
Add C# representations for Compose `@JvmInline value class` params (Dp, Sp/Em, TextAlign, FontWeight, TextDecoration, Shape) plus the bridge generator plumbing to lower them to JNI primitives with auto `$default`-bit clearing. `androidx.compose.ui.graphics.Color` is intentionally left out of the value-type registry. PR #77 just bound it via `Xamarin.AndroidX.Compose.UI.Graphics`, but Kotlin's `@JvmInline value class Color(val value: ULong)` surfaces as a raw packed `long` once you reference the binding, so call sites already pass `long` straight through to `ModifierBackground`/`ModifierBorder` via `ColorKt.Color(r,g,b,a)`. There is no C# struct to lower from, and re-wrapping it would only force callers into a more verbose `new Color(ColorKt.Color(...))` style for no benefit. ## Generator changes - New `ComposeValueTypes` registry keyed on full C# type name, with per-entry JNI slot character and lowering template. - `EmitUserArgValue` has a value-type branch; auto-default-mask recognizes value types and `IntPtr?` (mirroring `IModifier?`); when the user passes a non-null value the matching `$default` bit is cleared. - `NeedsKeepAlive` skips recognized value types (no `IJavaPeerable` peer to keep alive). - New **CN2007** diagnostic - recognized value type on a no-`$default` bridge fails fast (auto-mask only fires when there's a bit to clear). ## Value type files - `Dp`, `Sp`, `Em`, `TextAlign` -- `readonly record struct` wrappers with `Pack(T?)` static helpers. Kotlin `@JvmInline value class` so the binder will never surface them as value types regardless of un-stripping. - `FontWeight`, `TextDecoration`, `Shape` -- `sealed class : Java.Lang.Object` with JNI-resolved companion statics / factories, designed to swap to bound types once dotnet/android-libraries#1439 ships and the Compose UI Text/Graphics text packages stop being Java-library-only stubs. These use the existing reference-type lowering path, not the value-type registry. No existing bridges or facades are converted in this PR -- the infrastructure is staged so the next batch of bridges (`Text` colors, font sizes, padding, etc.) can use typed parameters straight away. ## Tests Four new generator tests cover Dp on a non-`@Composable` extension shape, Sp/Em/TextAlign on a `@Composable` shape, FontWeight on the existing reference-type path, and the CN2007 fail-fast. All 53 generator tests pass; `ComposeNet.Compose`, `ComposeNet.Sample`, and `samples/Jetchat` all build clean. Closes #65 Co-authored-by: Copilot <[email protected]>
jonathanpeppers
added a commit
that referenced
this pull request
Jun 5, 2026
Add C# representations for Compose `@JvmInline value class` params (Dp, Sp/Em, TextAlign, FontWeight, TextDecoration, Shape) plus the bridge generator plumbing to lower them to JNI primitives with auto `$default`-bit clearing. `androidx.compose.ui.graphics.Color` is intentionally left out of the value-type registry. PR #77 just bound it via `Xamarin.AndroidX.Compose.UI.Graphics`, but Kotlin's `@JvmInline value class Color(val value: ULong)` surfaces as a raw packed `long` once you reference the binding, so call sites already pass `long` straight through to `ModifierBackground`/`ModifierBorder` via `ColorKt.Color(r,g,b,a)`. There is no C# struct to lower from, and re-wrapping it would only force callers into a more verbose `new Color(ColorKt.Color(...))` style for no benefit. ## Generator changes - New `ComposeValueTypes` registry keyed on full C# type name, with per-entry JNI slot character and lowering template. - `EmitUserArgValue` has a value-type branch; auto-default-mask recognizes value types and `IntPtr?` (mirroring `IModifier?`); when the user passes a non-null value the matching `$default` bit is cleared. - `NeedsKeepAlive` skips recognized value types (no `IJavaPeerable` peer to keep alive). - New **CN2007** diagnostic - recognized value type on a no-`$default` bridge fails fast (auto-mask only fires when there's a bit to clear). ## Value type files - `Dp`, `Sp`, `Em`, `TextAlign` -- `readonly record struct` wrappers with `Pack(T?)` static helpers. Kotlin `@JvmInline value class` so the binder will never surface them as value types regardless of un-stripping. - `FontWeight`, `TextDecoration`, `Shape` -- `sealed class : Java.Lang.Object` with JNI-resolved companion statics / factories, designed to swap to bound types once dotnet/android-libraries#1439 ships and the Compose UI Text/Graphics text packages stop being Java-library-only stubs. These use the existing reference-type lowering path, not the value-type registry. No existing bridges or facades are converted in this PR -- the infrastructure is staged so the next batch of bridges (`Text` colors, font sizes, padding, etc.) can use typed parameters straight away. ## Tests Four new generator tests cover Dp on a non-`@Composable` extension shape, Sp/Em/TextAlign on a `@Composable` shape, FontWeight on the existing reference-type path, and the CN2007 fail-fast. All 53 generator tests pass; `ComposeNet.Compose`, `ComposeNet.Sample`, and `samples/Jetchat` all build clean. Closes #65 Co-authored-by: Copilot <[email protected]>
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.
Xamarin.AndroidX.Compose.UI.Graphics1.11.2.1 finally binds the ComposeColortype that we'd been hand-packing fromAndroid.Graphics.Color(the temporary workaround called out inModifier.csand tracked as dotnet/android-libraries#1437). This swaps to the real bindings.What changed
Modifier.BackgroundandModifier.Bordernow take a packed ComposeColorlongdirectly, the same value Kotlin's@JvmInline value class Color(val value: ULong)uses and thatComposeBridges.Modifier{Background,Border}already expect. The hand-rolledPackComposeColor(Android.Graphics.Color)helper is gone.AndroidX.Compose.UI.Graphics.ColorKt.Color(int red, int green, int blue, int alpha)factory, so the onlyColor-typed thing in the facade and samples is the Compose one.using Android.Graphics;is dropped fromModifier.cs,MainActivity.cs, andsamples/Jetchat/Conversation.cs.Package version coupling
UI.Graphics1.11.2.1 transitively requiresCompose.UI.Unit [1.11.2, 1.11.3), which version-locks the rest of the 1.11.x stack to 1.11.2. There's no.1revision yet on UI / UI.Android / Foundation.Layout{,.Android} / Runtime{,.Android} / UI.Unit{,.Android}, so those move to plain1.11.2;Foundation{,.Android}andUI.Graphics{,.Android}go to1.11.2.1. Material3 1.4.0.x is unchanged because its dependencies on the 1.11.x stack are minimum-version constraints.Verification
dotnet test src/ComposeNet.SourceGenerators.Tests-- 37/37 passing.dotnet build src/ComposeNet.Compose,src/ComposeNet.Sample, andsamples/Jetchatall clean (only the pre-existing XML-cref warnings unrelated to this change).