Skip to content

Compose Material3: ShapesKt.Shapes(...) builder missing from binding (no inline-class params, not blocked on java-interop#1440) #1452

@jonathanpeppers

Description

@jonathanpeppers

Background

In Xamarin.AndroidX.Compose.Material3Android (verified against
1.4.0.3), the ShapesKt companion class only exposes the
LocalShapes CompositionLocal accessor — the public
Shapes(small, medium, large, extraSmall, extraLarge) builder
function is missing entirely:

// AndroidX.Compose.Material3.ShapesKt (full method list)
get_class_ref()                       -> IntPtr
get_JniPeerMembers()                  -> JniPeerMembers
get_ThresholdClass()                  -> IntPtr
get_ThresholdType()                   -> Type
get_LocalShapes()                     -> ProvidableCompositionLocal
.ctor(IntPtr, JniHandleOwnership)     -> Void
.cctor()                              -> Void
// ^ no Shapes(...) builder

Upstream Kotlin (androidx.compose.material3.ShapesKt):

fun Shapes(
    extraSmall: CornerBasedShape = ShapeDefaults.ExtraSmall,
    small:      CornerBasedShape = ShapeDefaults.Small,
    medium:     CornerBasedShape = ShapeDefaults.Medium,
    large:      CornerBasedShape = ShapeDefaults.Large,
    extraLarge: CornerBasedShape = ShapeDefaults.ExtraLarge,
): Shapes

Notably none of the parameters are inline-class types — they're
all reference types (CornerBasedShape). So this is not the same
JVM-mangling story as Text--4IGK_g / Button-bWB7cM8 /
lightColorScheme(-...) from
dotnet/java-interop#1440. This looks like a real binder
bug or an overly broad <remove-node> rule in
material3-android/Transforms/Metadata.xml.

The same package does expose:

  • MaterialThemeKt.MaterialTheme(ColorScheme, Shapes, Typography, …)
  • ColorSchemeKt.LightColorScheme(Int64×47) /
    DarkColorScheme(Int64×47)
  • MaterialTheme.GetShapes(IComposer, Int32) companion accessor
  • new Shapes() parameterless ctor (so callers can take the
    Compose default)

— so the type Shapes is fully bound and consumable; only the
factory function that lets you build a customized Shapes with
the standard defaults is missing. This blocks
jonathanpeppers/compose-net#61 (parameterizing
MaterialTheme).

Ask

Find and remove the <remove-node> (or equivalent
<remove-method>) in material3-android/Transforms/Metadata.xml
that's stripping the Shapes(...) static builder out of
ShapesKt, then bump nugetVersion on
Xamarin.AndroidX.Compose.Material3Android.

If the strip is intentional because of a related binder issue
(e.g. CornerBasedShape not yet being resolvable at the right
binding-pipeline stage), please flag that as the underlying root
cause so we can track it separately.

Verification

After the fix, this should compile:

using AndroidX.Compose.Material3;
using AndroidX.Compose.Foundation.Shape;

Shapes shapes = ShapesKt.Shapes(
    extraSmall: RoundedCornerShapeKt.RoundedCornerShape(2),
    small:      RoundedCornerShapeKt.RoundedCornerShape(4),
    medium:     RoundedCornerShapeKt.RoundedCornerShape(8),
    large:      RoundedCornerShapeKt.RoundedCornerShape(12),
    extraLarge: RoundedCornerShapeKt.RoundedCornerShape(16));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions