Skip to content

Commit

Permalink
[linker] Use correct namespace for async debugging helpers. Fixes #59015
Browse files Browse the repository at this point in the history
Replace xamarin#2704
It's almost identical but it adds unit tests so this does not regress.

The issue was already reported in [1] but the fix [2] was incorrect
and that was also missed when the bug was verified by QA [3].

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=55037
[2] xamarin#2004
[3] https://bugzilla.xamarin.com/show_bug.cgi?id=55037#c10
  • Loading branch information
spouliot committed Sep 26, 2017
1 parent 50148e7 commit a59de59
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
31 changes: 31 additions & 0 deletions tests/linker-ios/link all/LinkAllTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;

using MonoTouch;
Expand Down Expand Up @@ -542,5 +544,34 @@ public void WebKit_NSProxy ()
var fqn = typeof (NSObject).AssemblyQualifiedName.Replace ("Foundation.NSObject", "Foundation.NSProxy");
Assert.Null (Type.GetType (fqn), fqn);
}

[Test]
public void Bug59015 ()
{
CheckAsyncTaskMethodBuilder (typeof (AsyncTaskMethodBuilder));
CheckAsyncTaskMethodBuilder (typeof (AsyncTaskMethodBuilder<int>));
var t = typeof (Task);
var snfwc = t.GetMethod ("SetNotificationForWaitCompletion", BindingFlags.Instance | BindingFlags.NonPublic);
#if DEBUG
Assert.NotNull (snfwc, "Task.NotifyDebuggerOfWaitCompletion");
#else
// something keeps it from being removed
// Assert.Null (snfwc, "Task.NotifyDebuggerOfWaitCompletion");
#endif
}

void CheckAsyncTaskMethodBuilder (Type atmb)
{
Assert.NotNull (atmb, "AsyncTaskMethodBuilder");
var snfwc = atmb.GetMethod ("SetNotificationForWaitCompletion", BindingFlags.Instance | BindingFlags.NonPublic);
var oifd = atmb.GetProperty ("ObjectIdForDebugger", BindingFlags.Instance | BindingFlags.NonPublic);
#if DEBUG
Assert.NotNull (snfwc, atmb.FullName + ".SetNotificationForWaitCompletion");
Assert.NotNull (oifd, atmb.FullName + ".ObjectIdForDebugger");
#else
Assert.Null (snfwc, atmb.FullName + ".SetNotificationForWaitCompletion");
Assert.Null (oifd, atmb.FullName + ".ObjectIdForDebugger");
#endif
}
}
}
28 changes: 17 additions & 11 deletions tools/linker/MobileMarkStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,25 @@ void MarkMetadata (IMetadataTokenProvider tp)
void ProcessCorlib (TypeDefinition type)
{
switch (type.Namespace) {
case "System.Runtime.CompilerServices.AsyncTaskMethodBuilder":
if (DebugBuild)
MarkNamedMethod (type, "SetNotificationForWaitCompletion");
break;
case "System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1":
if (DebugBuild)
MarkNamedMethod (type, "SetNotificationForWaitCompletion");
case "System.Runtime.CompilerServices":
switch (type.Name) {
case "AsyncTaskMethodBuilder":
case "AsyncTaskMethodBuilder`1":
if (DebugBuild) {
MarkNamedMethod (type, "SetNotificationForWaitCompletion");
MarkNamedMethod (type, "get_ObjectIdForDebugger");
}
break;
}
break;
case "System.Threading.Tasks.Task":
if (DebugBuild)
MarkNamedMethod (type, "NotifyDebuggerOfWaitCompletion");
case "System.Threading.Tasks":
switch (type.Name) {
case "Task":
if (DebugBuild)
MarkNamedMethod (type, "NotifyDebuggerOfWaitCompletion");
break;
}
break;

case "System.Security.Cryptography":
switch (type.Name) {
case "Aes":
Expand Down

0 comments on commit a59de59

Please sign in to comment.