Skip to content

Commit 2a67bee

Browse files
committed
Merge branch 'main' into dev/grendel/blobs-in-lib
* main: [monodroid] typemaps may need to load assemblies (#8625) Bump $(AndroidNetPreviousVersion) to 34.0.79 (#8693) Bump to xamarin/java.interop/main@07c73009 (#8681) Bump to dotnet/installer@1c496970b7 9.0.100-preview.2.24078.1 (#8685)
2 parents d706ffe + 06b1d7f commit 2a67bee

21 files changed

+130
-63
lines changed

Configuration.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<DebugType Condition=" '$(DebugType)' == '' ">portable</DebugType>
4444
<Deterministic Condition=" '$(Deterministic)' == '' ">True</Deterministic>
4545
<LangVersion Condition=" '$(LangVersion)' == '' ">latest</LangVersion>
46-
<AndroidNetPreviousVersion Condition=" '$(AndroidNetPreviousVersion)' == '' ">34.0.56</AndroidNetPreviousVersion>
46+
<AndroidNetPreviousVersion Condition=" '$(AndroidNetPreviousVersion)' == '' ">34.0.79</AndroidNetPreviousVersion>
4747
</PropertyGroup>
4848
<PropertyGroup Condition=" '$(HostOS)' == '' ">
4949
<HostOS Condition="$([MSBuild]::IsOSPlatform('windows'))">Windows</HostOS>

eng/Version.Details.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<Dependencies>
22
<ProductDependencies>
3-
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="9.0.100-preview.2.24073.12">
3+
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="9.0.100-preview.2.24078.1">
44
<Uri>https://github.com/dotnet/installer</Uri>
5-
<Sha>5680e93cb251d7741e19f2d759f04141e9d95a93</Sha>
5+
<Sha>1c496970b7479284364bc7eaf5c30e59f1cdb2ec</Sha>
66
</Dependency>
7-
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.2.24072.10" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
7+
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="9.0.0-preview.2.24076.4" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
88
<Uri>https://github.com/dotnet/runtime</Uri>
9-
<Sha>e3547f1d3ac768a14a0598abf7868641ecf0c9d7</Sha>
9+
<Sha>bcc1d3d6f00fbcea3f454b2e35bceeaa51e604b1</Sha>
1010
</Dependency>
11-
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.2.24072.10" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
11+
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.2.24076.4" CoherentParentDependency="Microsoft.Dotnet.Sdk.Internal">
1212
<Uri>https://github.com/dotnet/runtime</Uri>
13-
<Sha>e3547f1d3ac768a14a0598abf7868641ecf0c9d7</Sha>
13+
<Sha>bcc1d3d6f00fbcea3f454b2e35bceeaa51e604b1</Sha>
1414
</Dependency>
15-
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-alpha.1.24068.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
15+
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-alpha.1.24072.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
1616
<Uri>https://github.com/dotnet/emsdk</Uri>
17-
<Sha>fd99e59a43cfd6fe323c98ff267b620a67e71e67</Sha>
17+
<Sha>ae7c93e25ae596594b3b22d64115f374a3595912</Sha>
1818
</Dependency>
1919
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.4-alpha.24065.1" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
2020
<Uri>https://github.com/dotnet/cecil</Uri>

eng/Versions.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project>
22
<!--Package versions-->
33
<PropertyGroup>
4-
<MicrosoftDotnetSdkInternalPackageVersion>9.0.100-preview.2.24073.12</MicrosoftDotnetSdkInternalPackageVersion>
5-
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.2.24072.10</MicrosoftNETILLinkTasksPackageVersion>
6-
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.2.24072.10</MicrosoftNETCoreAppRefPackageVersion>
4+
<MicrosoftDotnetSdkInternalPackageVersion>9.0.100-preview.2.24078.1</MicrosoftDotnetSdkInternalPackageVersion>
5+
<MicrosoftNETILLinkTasksPackageVersion>9.0.0-preview.2.24076.4</MicrosoftNETILLinkTasksPackageVersion>
6+
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.2.24076.4</MicrosoftNETCoreAppRefPackageVersion>
77
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>
88
<MicrosoftDotNetBuildTasksFeedPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetBuildTasksFeedPackageVersion>
9-
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-alpha.1.24068.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
9+
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-alpha.1.24072.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
1010
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
1111
<MicrosoftTemplateEngineTasksPackageVersion>7.0.100-rc.1.22410.7</MicrosoftTemplateEngineTasksPackageVersion>
1212
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24065.1</MicrosoftDotNetCecilPackageVersion>

external/Java.Interop

src/Mono.Android/Java.Interop/TypeManager.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ internal static IJavaPeerable CreateInstance (IntPtr handle, JniHandleOwnership
267267
{
268268
Type? type = null;
269269
IntPtr class_ptr = JNIEnv.GetObjectClass (handle);
270-
string class_name = GetClassName (class_ptr);
270+
string? class_name = GetClassName (class_ptr);
271271
lock (TypeManagerMapDictionaries.AccessLock) {
272272
while (class_ptr != IntPtr.Zero && !TypeManagerMapDictionaries.JniToManaged.TryGetValue (class_name, out type)) {
273273

@@ -279,23 +279,33 @@ internal static IJavaPeerable CreateInstance (IntPtr handle, JniHandleOwnership
279279

280280
IntPtr super_class_ptr = JNIEnv.GetSuperclass (class_ptr);
281281
JNIEnv.DeleteLocalRef (class_ptr);
282+
class_name = null;
282283
class_ptr = super_class_ptr;
283-
class_name = GetClassName (class_ptr);
284+
if (class_ptr != IntPtr.Zero) {
285+
class_name = GetClassName (class_ptr);
286+
}
284287
}
285288
}
286289

287-
JNIEnv.DeleteLocalRef (class_ptr);
290+
if (class_ptr != IntPtr.Zero) {
291+
JNIEnv.DeleteLocalRef (class_ptr);
292+
class_ptr = IntPtr.Zero;
293+
}
294+
295+
if (targetType != null &&
296+
(type == null ||
297+
!targetType.IsAssignableFrom (type))) {
298+
type = targetType;
299+
}
288300

289301
if (type == null) {
302+
class_name = JNIEnv.GetClassNameFromInstance (handle);
290303
JNIEnv.DeleteRef (handle, transfer);
291304
throw new NotSupportedException (
292-
FormattableString.Invariant ($"Internal error finding wrapper class for '{JNIEnv.GetClassNameFromInstance (handle)}'. (Where is the Java.Lang.Object wrapper?!)"),
305+
FormattableString.Invariant ($"Internal error finding wrapper class for '{class_name}'. (Where is the Java.Lang.Object wrapper?!)"),
293306
CreateJavaLocationException ());
294307
}
295308

296-
if (targetType != null && !targetType.IsAssignableFrom (type))
297-
type = targetType;
298-
299309
if (type.IsInterface || type.IsAbstract) {
300310
var invokerType = JavaObjectExtensions.GetInvokerType (type);
301311
if (invokerType == null)

src/Xamarin.Android.Build.Tasks/Tasks/GenerateCompressedAssembliesNativeSourceFiles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void GenerateCompressedAssemblySources ()
9292

9393
void Generate (Dictionary<AndroidTargetArch, Dictionary<string, CompressedAssemblyInfo>> dict)
9494
{
95-
var composer = new CompressedAssembliesNativeAssemblyGenerator (dict);
95+
var composer = new CompressedAssembliesNativeAssemblyGenerator (Log, dict);
9696
LLVMIR.LlvmIrModule compressedAssemblies = composer.Construct ();
9797

9898
foreach (string abi in SupportedAbis) {

src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override bool RunTask ()
5454

5555
void GenerateEmpty ()
5656
{
57-
Generate (new JniRemappingAssemblyGenerator (), typeReplacementsCount: 0);
57+
Generate (new JniRemappingAssemblyGenerator (Log), typeReplacementsCount: 0);
5858
}
5959

6060
void Generate ()
@@ -74,7 +74,7 @@ void Generate ()
7474
}
7575
}
7676

77-
Generate (new JniRemappingAssemblyGenerator (typeReplacements, methodReplacements), typeReplacements.Count);
77+
Generate (new JniRemappingAssemblyGenerator (Log, typeReplacements, methodReplacements), typeReplacements.Count);
7878
}
7979

8080
void Generate (JniRemappingAssemblyGenerator jniRemappingComposer, int typeReplacementsCount)

src/Xamarin.Android.Build.Tasks/Tasks/JavaCompileToolTask.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ private void GenerateResponseFile ()
9090
file.Replace (@"\", @"\\").Normalize (NormalizationForm.FormC)));
9191
}
9292
}
93+
Log.LogDebugMessage ($"javac response file contents: {TemporarySourceListFile}");
94+
foreach (var line in File.ReadLines (TemporarySourceListFile)) {
95+
Log.LogDebugMessage ($" {line}");
96+
}
9397
}
9498
}
9599
}

src/Xamarin.Android.Build.Tasks/Tasks/R8.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Microsoft.Build.Framework;
23
using Microsoft.Build.Utilities;
34
using System.Collections.Generic;
@@ -82,16 +83,15 @@ protected override CommandLineBuilder GetCommandLineBuilder ()
8283

8384
if (EnableShrinking) {
8485
if (!string.IsNullOrEmpty (AcwMapFile)) {
85-
var acwLines = File.ReadAllLines (AcwMapFile);
86+
var acwMap = MonoAndroidHelper.LoadMapFile (BuildEngine4, Path.GetFullPath (AcwMapFile), StringComparer.OrdinalIgnoreCase);
87+
var javaTypes = new List<string> (acwMap.Values.Count);
88+
foreach (var v in acwMap.Values) {
89+
javaTypes.Add (v);
90+
}
91+
javaTypes.Sort (StringComparer.Ordinal);
8692
using (var appcfg = File.CreateText (ProguardGeneratedApplicationConfiguration)) {
87-
for (int i = 0; i + 2 < acwLines.Length; i += 3) {
88-
try {
89-
var line = acwLines [i + 2];
90-
var java = line.Substring (line.IndexOf (';') + 1);
91-
appcfg.WriteLine ("-keep class " + java + " { *; }");
92-
} catch {
93-
// skip invalid lines
94-
}
93+
foreach (var java in javaTypes) {
94+
appcfg.WriteLine ($"-keep class {java} {{ *; }}");
9595
}
9696
}
9797
}

src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Java.Interop.Tools.TypeNameMappings;
77
using Microsoft.Build.Framework;
88
using Microsoft.Build.Utilities;
9+
using Microsoft.Android.Build.Tasks;
910
using Xamarin.Android.Tasks.LLVMIR;
1011

1112
namespace Xamarin.Android.Tasks
@@ -153,7 +154,6 @@ sealed class XamarinAndroidBundledAssembly
153154

154155
SortedDictionary <string, string>? environmentVariables;
155156
SortedDictionary <string, string>? systemProperties;
156-
TaskLoggingHelper log;
157157
StructureInstance? application_config;
158158
List<StructureInstance<DSOCacheEntry>>? dsoCache;
159159
List<StructureInstance<XamarinAndroidBundledAssembly>>? xamarinAndroidBundledAssemblies;
@@ -190,6 +190,7 @@ sealed class XamarinAndroidBundledAssembly
190190
public bool MarshalMethodsEnabled { get; set; }
191191

192192
public ApplicationConfigNativeAssemblyGenerator (IDictionary<string, string> environmentVariables, IDictionary<string, string> systemProperties, TaskLoggingHelper log)
193+
: base (log)
193194
{
194195
if (environmentVariables != null) {
195196
this.environmentVariables = new SortedDictionary<string, string> (environmentVariables, StringComparer.Ordinal);
@@ -198,8 +199,6 @@ public ApplicationConfigNativeAssemblyGenerator (IDictionary<string, string> env
198199
if (systemProperties != null) {
199200
this.systemProperties = new SortedDictionary<string, string> (systemProperties, StringComparer.Ordinal);
200201
}
201-
202-
this.log = log;
203202
}
204203

205204
protected override void Construct (LlvmIrModule module)
@@ -353,7 +352,7 @@ List<StructureInstance<DSOCacheEntry>> InitDSOCache ()
353352
continue;
354353
}
355354

356-
dsos.Add ((name, $"dsoName{dsos.Count.ToString (CultureInfo.InvariantCulture)}", ELFHelper.IsEmptyAOTLibrary (log, item.ItemSpec)));
355+
dsos.Add ((name, $"dsoName{dsos.Count.ToString (CultureInfo.InvariantCulture)}", ELFHelper.IsEmptyAOTLibrary (Log, item.ItemSpec)));
357356
}
358357

359358
var dsoCache = new List<StructureInstance<DSOCacheEntry>> ();

src/Xamarin.Android.Build.Tasks/Utilities/CompressedAssembliesNativeAssemblyGenerator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Collections.Generic;
33

4+
using Microsoft.Build.Utilities;
5+
46
using Xamarin.Android.Tasks.LLVMIR;
57
using Xamarin.Android.Tools;
68

@@ -74,7 +76,8 @@ sealed class CompressedAssemblies
7476
StructureInfo compressedAssembliesStructureInfo;
7577
Dictionary<AndroidTargetArch, List<StructureInstance<CompressedAssemblyDescriptor>>> archData = new Dictionary<AndroidTargetArch, List<StructureInstance<CompressedAssemblyDescriptor>>> ();
7678

77-
public CompressedAssembliesNativeAssemblyGenerator (IDictionary<AndroidTargetArch, Dictionary<string, CompressedAssemblyInfo>>? archAssemblies)
79+
public CompressedAssembliesNativeAssemblyGenerator (TaskLoggingHelper log, IDictionary<AndroidTargetArch, Dictionary<string, CompressedAssemblyInfo>>? archAssemblies)
80+
: base (log)
7881
{
7982
this.archAssemblies = archAssemblies;
8083
}

src/Xamarin.Android.Build.Tasks/Utilities/JniRemappingAssemblyGenerator.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Collections.Generic;
33
using System.Text;
44

5+
using Microsoft.Build.Utilities;
6+
57
using Xamarin.Android.Tasks.LLVMIR;
68

79
namespace Xamarin.Android.Tasks
@@ -190,10 +192,12 @@ sealed class JniRemappingTypeReplacementEntry
190192

191193
public int ReplacementMethodIndexEntryCount { get; private set; } = 0;
192194

193-
public JniRemappingAssemblyGenerator ()
195+
public JniRemappingAssemblyGenerator (TaskLoggingHelper log)
196+
: base (log)
194197
{}
195198

196-
public JniRemappingAssemblyGenerator (List<JniRemappingTypeReplacement> typeReplacements, List<JniRemappingMethodReplacement> methodReplacements)
199+
public JniRemappingAssemblyGenerator (TaskLoggingHelper log, List<JniRemappingTypeReplacement> typeReplacements, List<JniRemappingMethodReplacement> methodReplacements)
200+
: base (log)
197201
{
198202
this.typeReplacementsInput = typeReplacements ?? throw new ArgumentNullException (nameof (typeReplacements));
199203
this.methodReplacementsInput = methodReplacements ?? throw new ArgumentNullException (nameof (methodReplacements));

src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrComposer.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.IO;
33

4+
using Microsoft.Build.Utilities;
5+
46
using Xamarin.Android.Tools;
57

68
namespace Xamarin.Android.Tasks.LLVMIR
@@ -9,6 +11,13 @@ abstract class LlvmIrComposer
911
{
1012
bool constructed;
1113

14+
protected readonly TaskLoggingHelper Log;
15+
16+
protected LlvmIrComposer (TaskLoggingHelper log)
17+
{
18+
this.Log = log ?? throw new ArgumentNullException (nameof (log));
19+
}
20+
1221
protected abstract void Construct (LlvmIrModule module);
1322

1423
public LlvmIrModule Construct ()

src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsNativeAssemblyGenerator.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ public MarshalMethodAssemblyIndexValuePlaceholder (MarshalMethodInfo mmi, Assemb
228228

229229
readonly ICollection<string> uniqueAssemblyNames;
230230
readonly int numberOfAssembliesInApk;
231-
readonly TaskLoggingHelper logger;
232231

233232
StructureInfo marshalMethodsManagedClassStructureInfo;
234233
StructureInfo marshalMethodNameStructureInfo;
@@ -244,7 +243,8 @@ public MarshalMethodAssemblyIndexValuePlaceholder (MarshalMethodInfo mmi, Assemb
244243
/// <summary>
245244
/// Constructor to be used ONLY when marshal methods are DISABLED
246245
/// </summary>
247-
public MarshalMethodsNativeAssemblyGenerator (AndroidTargetArch targetArch, int numberOfAssembliesInApk, ICollection<string> uniqueAssemblyNames)
246+
public MarshalMethodsNativeAssemblyGenerator (TaskLoggingHelper log, AndroidTargetArch targetArch, int numberOfAssembliesInApk, ICollection<string> uniqueAssemblyNames)
247+
: base (log)
248248
{
249249
this.targetArch = targetArch;
250250
this.numberOfAssembliesInApk = numberOfAssembliesInApk;
@@ -256,9 +256,9 @@ public MarshalMethodsNativeAssemblyGenerator (AndroidTargetArch targetArch, int
256256
/// <summary>
257257
/// Constructor to be used ONLY when marshal methods are ENABLED
258258
/// </summary>
259-
public MarshalMethodsNativeAssemblyGenerator (TaskLoggingHelper logger, int numberOfAssembliesInApk, ICollection<string> uniqueAssemblyNames, NativeCodeGenState codeGenState)
259+
public MarshalMethodsNativeAssemblyGenerator (TaskLoggingHelper log, int numberOfAssembliesInApk, ICollection<string> uniqueAssemblyNames, NativeCodeGenState codeGenState)
260+
: base (log)
260261
{
261-
this.logger = logger ?? throw new ArgumentNullException (nameof (logger));
262262
this.numberOfAssembliesInApk = numberOfAssembliesInApk;
263263
this.uniqueAssemblyNames = uniqueAssemblyNames ?? throw new ArgumentNullException (nameof (uniqueAssemblyNames));
264264
this.codeGenState = codeGenState ?? throw new ArgumentNullException (nameof (codeGenState));
@@ -308,7 +308,7 @@ void Init ()
308308
foreach (IList<MarshalMethodEntry> entryList in marshalMethods.Values) {
309309
bool useFullNativeSignature = entryList.Count > 1;
310310
foreach (MarshalMethodEntry entry in entryList) {
311-
logger.LogDebugMessage ($"MM: processing {entry.DeclaringType.FullName} {entry.NativeCallback.FullName}");
311+
Log.LogDebugMessage ($"MM: processing {entry.DeclaringType.FullName} {entry.NativeCallback.FullName}");
312312
ProcessAndAddMethod (allMethods, entry, useFullNativeSignature, seenClasses, overloadedNativeSymbolNames);
313313
}
314314
}
@@ -338,7 +338,7 @@ void Init ()
338338

339339
foreach (MarshalMethodInfo method in allMethods) {
340340
if (seenNativeSymbols.Contains (method.NativeSymbolName)) {
341-
logger.LogDebugMessage ($"Removed MM duplicate '{method.NativeSymbolName}' (implemented: {method.Method.ImplementedMethod.FullName}; registered: {method.Method.RegisteredMethod.FullName}");
341+
Log.LogDebugMessage ($"Removed MM duplicate '{method.NativeSymbolName}' (implemented: {method.Method.ImplementedMethod.FullName}; registered: {method.Method.RegisteredMethod.FullName}");
342342
continue;
343343
}
344344

@@ -658,7 +658,7 @@ void AddMarshalMethods (LlvmIrModule module, AssemblyCacheState acs, LlvmIrVaria
658658

659659
void AddMarshalMethod (LlvmIrModule module, MarshalMethodInfo method, ulong asmId, MarshalMethodsWriteState writeState)
660660
{
661-
logger.LogDebugMessage ($"MM: generating code for {method.Method.DeclaringType.FullName} {method.Method.NativeCallback.FullName}");
661+
Log.LogDebugMessage ($"MM: generating code for {method.Method.DeclaringType.FullName} {method.Method.NativeCallback.FullName}");
662662
CecilMethodDefinition nativeCallback = method.Method.NativeCallback;
663663
string backingFieldName = $"native_cb_{method.Method.JniMethodName}_{asmId}_{method.ClassCacheIndex}_{nativeCallback.MetadataToken.ToUInt32():x}";
664664

src/Xamarin.Android.Build.Tasks/Utilities/NativeTypeMappingData.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.Collections.Generic;
33
using System.Linq;
44

5+
using Microsoft.Build.Utilities;
6+
using Microsoft.Android.Build.Tasks;
7+
58
namespace Xamarin.Android.Tasks
69
{
710
class NativeTypeMappingData
@@ -12,7 +15,7 @@ class NativeTypeMappingData
1215
public uint MapModuleCount { get; }
1316
public uint JavaTypeCount { get; }
1417

15-
public NativeTypeMappingData (TypeMapGenerator.ModuleReleaseData[] modules)
18+
public NativeTypeMappingData (TaskLoggingHelper log, TypeMapGenerator.ModuleReleaseData[] modules)
1619
{
1720
Modules = modules ?? throw new ArgumentNullException (nameof (modules));
1821

@@ -21,15 +24,37 @@ public NativeTypeMappingData (TypeMapGenerator.ModuleReleaseData[] modules)
2124
var tempJavaTypes = new Dictionary<string, TypeMapGenerator.TypeMapReleaseEntry> (StringComparer.Ordinal);
2225
var moduleComparer = new TypeMapGenerator.ModuleUUIDArrayComparer ();
2326

27+
TypeMapGenerator.ModuleReleaseData? monoAndroid = null;
2428
foreach (TypeMapGenerator.ModuleReleaseData data in modules) {
29+
if (data.AssemblyName == "Mono.Android") {
30+
monoAndroid = data;
31+
break;
32+
}
33+
}
34+
35+
if (monoAndroid != null) {
36+
ProcessModule (monoAndroid);
37+
}
38+
39+
foreach (TypeMapGenerator.ModuleReleaseData data in modules) {
40+
if (data.AssemblyName == "Mono.Android") {
41+
continue;
42+
}
43+
ProcessModule (data);
44+
};
45+
46+
void ProcessModule (TypeMapGenerator.ModuleReleaseData data)
47+
{
2548
int moduleIndex = Array.BinarySearch (modules, data, moduleComparer);
2649
if (moduleIndex < 0)
2750
throw new InvalidOperationException ($"Unable to map module with MVID {data.Mvid} to array index");
2851

2952
foreach (TypeMapGenerator.TypeMapReleaseEntry entry in data.Types) {
3053
entry.ModuleIndex = moduleIndex;
31-
if (tempJavaTypes.ContainsKey (entry.JavaName))
54+
if (tempJavaTypes.ContainsKey (entry.JavaName)) {
55+
log.LogDebugMessage ($"Skipping typemap entry for `{entry.ManagedTypeName}, {data.AssemblyName}`; `{entry.JavaName}` is already mapped.");
3256
continue;
57+
}
3358
tempJavaTypes.Add (entry.JavaName, entry);
3459
}
3560
}

0 commit comments

Comments
 (0)