Skip to content

Commit 528219b

Browse files
committed
[linker] improve method detection in FixAbstractMethodsStep
The forms team run into an issue with debugger in VS [1]. During investigation it turned out that our FixAbstractMethodsStep injects 2 methods, which were not needed, as the methods were already implemented. The bug itself looks like an issue, where original mdb file was used in the apk, instead of the one written by our linker. This change improves the method detection, where explicit interface methods name starts with `global::` [2]. In this particular case it were these methods: global::Android.Views.View.IOnTouchListener.OnTouch global::Android.Views.View.IOnClickListener.OnClick This is possibly compiler specific, so we rather look in MethodDefinition's Overrides to find the interface method and compare it to the interface method we are looking for. [1] https://bugzilla.xamarin.com/show_bug.cgi?id=59293 [2] excerpt from ikdasm output: .method private hidebysig newslot virtual final instance void 'global::Android.Views.View.IOnClickListener.OnClick'(class [Mono.Android]Android.Views.View v) cil managed { .override [Mono.Android]Android.Views.View/IOnClickListener::OnClick
1 parent f9a31c1 commit 528219b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,23 @@ static bool CompareTypes (TypeReference iType, TypeReference tType)
9595
return true;
9696
}
9797

98+
bool IsInOverrides (MethodDefinition iMethod, MethodDefinition tMethod)
99+
{
100+
if (!tMethod.HasOverrides)
101+
return false;
102+
103+
foreach (var o in tMethod.Overrides)
104+
if (o != null && iMethod == o.Resolve ())
105+
return true;
106+
107+
return false;
108+
}
109+
98110
bool HaveSameSignature (TypeReference iface, MethodDefinition iMethod, MethodDefinition tMethod)
99111
{
112+
if (IsInOverrides (iMethod, tMethod))
113+
return true;
114+
100115
if (iMethod.Name != tMethod.Name && (iMethod.DeclaringType == null || (iMethod.DeclaringType.DeclaringType == null ? (string.Format ("{0}.{1}", iface.FullName, iMethod.Name) != tMethod.Name) : (string.Format ("{0}.{1}.{2}", iMethod.DeclaringType.DeclaringType, iface.Name, iMethod.Name) != tMethod.Name))))
101116
return false;
102117

0 commit comments

Comments
 (0)