diff --git a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs index 3bfffb9001b..5fab9eaddf4 100644 --- a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs +++ b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs @@ -317,10 +317,19 @@ protected override IEnumerable GetSimpleReferences (Type type) desugarType.Append ("Desugar").Append (name); } - return new[]{ - desugarType.ToString (), - $"{jniSimpleReference}$-CC" + var typeWithPrefix = desugarType.ToString (); + var typeWithSuffix = $"{jniSimpleReference}$-CC"; + + var replacements = new[]{ + GetReplacementTypeCore (typeWithPrefix) ?? typeWithPrefix, + GetReplacementTypeCore (typeWithSuffix) ?? typeWithSuffix, }; + + if (Logger.LogAssembly) { + var message = $"Remapping type `{jniSimpleReference}` to one one of {{ `{replacements[0]}`, `{replacements[1]}` }}"; + Logger.Log (LogLevel.Debug, "monodroid-assembly", message); + } + return replacements; } [DllImport (AndroidRuntime.InternalDllName, CallingConvention = CallingConvention.Cdecl)] @@ -356,11 +365,19 @@ protected override IEnumerable GetSimpleReferences (Type type) var method = new JniRemappingReplacementMethod (); method = Marshal.PtrToStructure(retInfo); + var newSignature = jniMethodSignature; int? paramCount = null; if (method.is_static) { paramCount = JniMemberSignature.GetParameterCountFromMethodSignature (jniMethodSignature) + 1; - jniMethodSignature = $"(L{jniSourceType};" + jniMethodSignature.Substring ("(".Length); + newSignature = $"(L{jniSourceType};" + jniMethodSignature.Substring ("(".Length); + } + + if (Logger.LogAssembly) { + var message = $"Remapping method `{jniSourceType}.{jniMethodName}{jniMethodSignature}` to " + + $"`{method.target_type}.{method.target_name}{newSignature}`; " + + $"param-count: {paramCount}; instance-to-static? {method.is_static}"; + Logger.Log (LogLevel.Debug, "monodroid-assembly", message); } return new JniRuntime.ReplacementMethodInfo { @@ -369,7 +386,7 @@ protected override IEnumerable GetSimpleReferences (Type type) SourceJniMethodSignature = jniMethodSignature, TargetJniType = method.target_type, TargetJniMethodName = method.target_name, - TargetJniMethodSignature = jniMethodSignature, + TargetJniMethodSignature = newSignature, TargetJniMethodParameterCount = paramCount, TargetJniMethodInstanceToStatic = method.is_static, };