Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unmangling of satellite assembly names #9533

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
new BuildItem ("EmbeddedResource", "Resource.es.resx") {
TextContent = () => InlineData.ResxWithContents ("<data name=\"CancelButton\"><value>Cancelar</value></data>")
},
new BuildItem ("EmbeddedResource", "Resource.de-DE.resx") {
TextContent = () => InlineData.ResxWithContents ("<data name=\"CancelButton\"><value>Abbrechen</value></data>")
},
new AndroidItem.TransformFile ("Transforms.xml") {
// Remove two methods that introduced warnings:
// Com.Balysv.Material.Drawable.Menu.MaterialMenuView.cs(214,30): warning CS0114: 'MaterialMenuView.OnRestoreInstanceState(IParcelable)' hides inherited member 'View.OnRestoreInstanceState(IParcelable?)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
Expand Down Expand Up @@ -163,6 +166,7 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo
helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !TestEnvironment.CommercialBuildAvailable && !isRelease);
helper.AssertContainsEntry ($"assemblies/Mono.Android.dll", shouldContainEntry: expectEmbeddedAssembies);
helper.AssertContainsEntry ($"assemblies/es/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies);
helper.AssertContainsEntry ($"assemblies/de-DE/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies);
foreach (var abi in rids.Select (AndroidRidAbiHelper.RuntimeIdentifierToAbi)) {
helper.AssertContainsEntry ($"lib/{abi}/libmonodroid.so");
helper.AssertContainsEntry ($"lib/{abi}/libmonosgen-2.0.so");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public int GetNumberOfAssemblies (bool forceRefresh = false, AndroidTargetArch a
// Android doesn't allow us to put satellite assemblies in lib/{CULTURE}/assembly.dll.so, we must instead
// mangle the name.
fileTypeMarker = MonoAndroidHelper.MANGLED_ASSEMBLY_SATELLITE_ASSEMBLY_MARKER;
fileName = $"{culture}-{fileName}";
fileName = $"{culture}{MonoAndroidHelper.SATELLITE_CULTURE_END_MARKER_CHAR}{fileName}";
}

var ret = new List<string> ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public static string MakeZipArchivePath (string part1, ICollection<string>? path
public const string MANGLED_ASSEMBLY_NAME_EXT = ".so";
public const string MANGLED_ASSEMBLY_REGULAR_ASSEMBLY_MARKER = "lib_";
public const string MANGLED_ASSEMBLY_SATELLITE_ASSEMBLY_MARKER = "lib-";
public const string SATELLITE_CULTURE_END_MARKER_CHAR = "_";

/// <summary>
/// Mangles APK/AAB entry name for assembly and their associated pdb and config entries in the
Expand All @@ -208,7 +209,7 @@ public static string MakeZipArchivePath (string part1, ICollection<string>? path
public static string MakeDiscreteAssembliesEntryName (string name, string? culture = null)
{
if (!String.IsNullOrEmpty (culture)) {
return $"{MANGLED_ASSEMBLY_SATELLITE_ASSEMBLY_MARKER}{culture}-{name}{MANGLED_ASSEMBLY_NAME_EXT}";
return $"{MANGLED_ASSEMBLY_SATELLITE_ASSEMBLY_MARKER}{culture}_{name}{MANGLED_ASSEMBLY_NAME_EXT}";
}

return $"{MANGLED_ASSEMBLY_REGULAR_ASSEMBLY_MARKER}{name}{MANGLED_ASSEMBLY_NAME_EXT}";
Expand Down
2 changes: 1 addition & 1 deletion src/native/monodroid/embedded-assemblies.hh
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ namespace xamarin::android::internal {
if constexpr (IsSatelliteAssembly) {
// Make sure assembly name is {CULTURE}/assembly.dll
for (size_t idx = start_idx; idx < name.length (); idx++) {
if (name[idx] == SharedConstants::SATELLITE_ASSEMBLY_MARKER_CHAR) {
if (name[idx] == SharedConstants::SATELLITE_CULTURE_END_MARKER_CHAR) {
name[idx] = '/';
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/native/runtime-base/shared-constants.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace xamarin::android::internal
static constexpr std::string_view MANGLED_ASSEMBLY_SATELLITE_ASSEMBLY_MARKER { "lib-" };
static constexpr size_t SATELLITE_ASSEMBLY_MARKER_INDEX = 3uz; // this ☝️
static constexpr char SATELLITE_ASSEMBLY_MARKER_CHAR = MANGLED_ASSEMBLY_SATELLITE_ASSEMBLY_MARKER[SATELLITE_ASSEMBLY_MARKER_INDEX];
static constexpr char SATELLITE_CULTURE_END_MARKER_CHAR = '_';

static constexpr std::string_view MONO_ANDROID_RUNTIME_ASSEMBLY_NAME { "Mono.Android.Runtime" };
static constexpr std::string_view MONO_ANDROID_ASSEMBLY_NAME { "Mono.Android" };
Expand Down
Loading