diff --git a/tests/linker-ios/link all/LinkAllTest.cs b/tests/linker-ios/link all/LinkAllTest.cs index b5fd67d0550e..83a6909752c2 100644 --- a/tests/linker-ios/link all/LinkAllTest.cs +++ b/tests/linker-ios/link all/LinkAllTest.cs @@ -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; @@ -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)); + 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 + } } } diff --git a/tools/linker/MobileMarkStep.cs b/tools/linker/MobileMarkStep.cs index 1f3a51e57713..5b2107ba715f 100644 --- a/tools/linker/MobileMarkStep.cs +++ b/tools/linker/MobileMarkStep.cs @@ -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":