Skip to content
Merged
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 @@ -236,7 +236,7 @@ void AddEnvironment ()
HashSet<string> archAssemblyNames = null;
HashSet<string> uniqueAssemblyNames = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
Action<ITaskItem> updateAssemblyCount = (ITaskItem assembly) => {
string? culture = assembly.GetMetadata ("Culture");
string? culture = MonoAndroidHelper.GetAssemblyCulture (assembly);
string fileName = Path.GetFileName (assembly.ItemSpec);
string assemblyName;

Expand Down
32 changes: 32 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,38 @@ public static string GetNativeLibsRootDirectoryPath (string androidBinUtilsDirec
return Path.GetFullPath (Path.Combine (androidBinUtilsDirectory, relPath, "lib"));
}

public static string? GetAssemblyCulture (ITaskItem assembly)
{
// The best option
string? culture = assembly.GetMetadata ("Culture");
if (!String.IsNullOrEmpty (culture)) {
return TrimSlashes (culture);
Copy link
Member

@akoeplinger akoeplinger Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it'd be pretty weird if Culture contained any slashes, might be ok to return it unmodified nevermind I just saw a binlog that had a Culture with a slash :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I learned the hard way... :)

}

// ...slightly worse
culture = assembly.GetMetadata ("RelativePath");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I checked the history and there was some discussion around RelativePath here: #7823 (review)

Not sure how that would've been set for satellite assemblies though, I can't find where it'd be set.

I'm only seeing Culture (for satellite assemblies in the current project) or DestinationSubDirectory (for satellites from referenced projects) being set.

Instead of checking every assembly can you only look at the satellite assemblies? you're already passing those to the GeneratePackageManagerJava task

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we possibly should do that, but not until after #8478 is merged (it changes a lot in this area, and all the optimizations and tweaks to the code should be done only after the merge)

if (!String.IsNullOrEmpty (culture)) {
return TrimSlashes (Path.GetDirectoryName (culture));
}

// ...not ideal
culture = assembly.GetMetadata ("DestinationSubDirectory");
if (!String.IsNullOrEmpty (culture)) {
return TrimSlashes (culture);
}

return null;

string? TrimSlashes (string? s)
{
if (String.IsNullOrEmpty (s)) {
return null;
}

return s.TrimEnd ('/').TrimEnd ('\\');
}
}

/// <summary>
/// Process a collection of assembly `ITaskItem` objects, splitting it on the assembly architecture (<see cref="GetTargetArch"/>) while, at the same time, ignoring
/// all assemblies which are **not** in the <paramref name="supportedAbis"/> collection. If necessary, the selection can be further controlled by passing a qualifier
Expand Down