Background
Xamarin.AndroidX.Compose.Material.Icons.Core (and its .Android
sibling) ships an essentially empty managed assembly. Verified
against 1.7.8.3:
D:\.nuget\packages\xamarin.androidx.compose.material.icons.core\1.7.8.3\
lib\net10.0-android36.0\Xamarin.AndroidX.Compose.Material.Icons.Core.dll (16 432 bytes)
var asm = AssemblyDefinition.ReadAssembly(dll);
asm.MainModule.Types.Count // => 1
asm.MainModule.Types[0].FullName // => "<Module>"
The underlying AAR contains the androidx.compose.material.icons.Icons
class (with nested Filled / Outlined / Rounded / Sharp /
TwoTone / AutoMirrored companion objects) plus the baseline icon
set (~36 ImageVector extension properties — Icons.Default.Search,
Menu, Add, Delete, Edit, Settings, MoreVert, ArrowBack,
Close, Check, Star, Favorite, Share, Home, Person,
Notifications, Refresh, Info, Warning, …), but none of it
surfaces to managed callers. Today there is no way to write
Icons.Default.Search from C# without hand-rolling a JNI
GetStaticFieldID lookup per icon.
This blocks any managed Compose effort from using the official
Material icon set — the same baseline icons every Jetpack Compose
sample uses for app-bar navigation, list-item actions, and FAB
contents. (We have an open tracking issue for this on the C# side:
jonathanpeppers/compose-net#61.)
Ask
Mirror the #1438
/ #1439
recipe applied to ui-graphics-android / ui-text-android /
ui-unit-android:
- Drop the
<remove-node path="/api/package" /> (or equivalent
<remove-node> rules) in
source/androidx.compose.material.icons/material-icons-core-android/Transforms/Metadata.xml
(and the JVM-only material-icons-core source if applicable).
- Add
managedName overrides forcing Material.Icons casing on the
package map:
androidx.compose.material.icons → AndroidX.Compose.Material.Icons
androidx.compose.material.icons.filled → AndroidX.Compose.Material.Icons.Filled
androidx.compose.material.icons.outlined → AndroidX.Compose.Material.Icons.Outlined
androidx.compose.material.icons.rounded → AndroidX.Compose.Material.Icons.Rounded
androidx.compose.material.icons.sharp → AndroidX.Compose.Material.Icons.Sharp
androidx.compose.material.icons.twotone → AndroidX.Compose.Material.Icons.TwoTone
androidx.compose.material.icons.automirrored.* →
AndroidX.Compose.Material.Icons.AutoMirrored.*
- Add
Xamarin.AndroidX.Compose.Material.Icons.Core /
.Android to ComposePackagesWithBindings in
AndroidXProject.cshtml.
- Update
published-namespaces.txt for the newly-exposed namespaces.
- Bump
nugetVersion on both packages.
After the fix, Icons.Default.Search-style baseline icons should be
callable directly. The 1500+ icon material-icons-extended artifact
has been deprecated upstream by Google, so this issue is intentionally
scoped to material-icons-core only.
Verification
// Should resolve at compile time after the fix:
var v = AndroidX.Compose.Material.Icons.Icons.Filled.Search;
// expected: AndroidX.Compose.UI.Graphics.Vector.ImageVector
Background
Xamarin.AndroidX.Compose.Material.Icons.Core(and its.Androidsibling) ships an essentially empty managed assembly. Verified
against
1.7.8.3:The underlying AAR contains the
androidx.compose.material.icons.Iconsclass (with nested
Filled/Outlined/Rounded/Sharp/TwoTone/AutoMirroredcompanion objects) plus the baseline iconset (~36
ImageVectorextension properties —Icons.Default.Search,Menu,Add,Delete,Edit,Settings,MoreVert,ArrowBack,Close,Check,Star,Favorite,Share,Home,Person,Notifications,Refresh,Info,Warning, …), but none of itsurfaces to managed callers. Today there is no way to write
Icons.Default.Searchfrom C# without hand-rolling a JNIGetStaticFieldIDlookup per icon.This blocks any managed Compose effort from using the official
Material icon set — the same baseline icons every Jetpack Compose
sample uses for app-bar navigation, list-item actions, and FAB
contents. (We have an open tracking issue for this on the C# side:
jonathanpeppers/compose-net#61.)
Ask
Mirror the #1438
/ #1439
recipe applied to
ui-graphics-android/ui-text-android/ui-unit-android:<remove-node path="/api/package" />(or equivalent<remove-node>rules) insource/androidx.compose.material.icons/material-icons-core-android/Transforms/Metadata.xml(and the JVM-only
material-icons-coresource if applicable).managedNameoverrides forcingMaterial.Iconscasing on thepackage map:
androidx.compose.material.icons→AndroidX.Compose.Material.Iconsandroidx.compose.material.icons.filled→AndroidX.Compose.Material.Icons.Filledandroidx.compose.material.icons.outlined→AndroidX.Compose.Material.Icons.Outlinedandroidx.compose.material.icons.rounded→AndroidX.Compose.Material.Icons.Roundedandroidx.compose.material.icons.sharp→AndroidX.Compose.Material.Icons.Sharpandroidx.compose.material.icons.twotone→AndroidX.Compose.Material.Icons.TwoToneandroidx.compose.material.icons.automirrored.*→AndroidX.Compose.Material.Icons.AutoMirrored.*Xamarin.AndroidX.Compose.Material.Icons.Core/.AndroidtoComposePackagesWithBindingsinAndroidXProject.cshtml.published-namespaces.txtfor the newly-exposed namespaces.nugetVersionon both packages.After the fix,
Icons.Default.Search-style baseline icons should becallable directly. The 1500+ icon
material-icons-extendedartifacthas been deprecated upstream by Google, so this issue is intentionally
scoped to
material-icons-coreonly.Verification