diff --git a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs index 1d65d197ac67..4f63bf08fb19 100644 --- a/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs +++ b/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs @@ -15,6 +15,7 @@ using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Security.Permissions; +using System.Security.Principal; using System.Threading; using System.Xml; using Mono.Data.Sqlite; @@ -1115,5 +1116,24 @@ public void AsQueryable_Enumerable () var list = new List { "hello hello" }; Assert.NotNull (list.AsQueryable ().GroupBy (x => x).FirstOrDefault ()?.FirstOrDefault (), "Enumerable"); } + + public class CustomIdentity : IIdentity { + public string AuthenticationType => "test"; + public bool IsAuthenticated => true; + public string Name => "abc"; + } + + public class CustomPrincipal : IPrincipal { + public IIdentity Identity => new CustomIdentity (); + public bool IsInRole (string role) => true; + } + + [Test] + // https://github.com/xamarin/xamarin-macios/issues/7321 + public void Principal () + { + Thread.CurrentPrincipal = new CustomPrincipal (); + Assert.That (Thread.CurrentPrincipal.Identity.Name, Is.EqualTo ("abc"), "Name"); + } } } \ No newline at end of file diff --git a/tools/linker/MonoTouch.Tuner/RemoveCode.cs b/tools/linker/MonoTouch.Tuner/RemoveCode.cs index 6f438f07ebf0..6a0661df6f9a 100644 --- a/tools/linker/MonoTouch.Tuner/RemoveCode.cs +++ b/tools/linker/MonoTouch.Tuner/RemoveCode.cs @@ -176,8 +176,14 @@ static bool IsCandidate (TypeDefinition type) case "System.Runtime.Remoting.Proxies": return true; case "System.Runtime.Remoting.Messaging": - return type.Name != "AsyncResult" && type.Name != "LogicalCallContext" - && type.Name != "MonoMethodMessage"; + switch (type.Name) { + case "AsyncResult": + case "CallContextSecurityData": + case "LogicalCallContext": + case "MonoMethodMessage": + return false; + } + return true; case "System.Security.AccessControl": case "System.Security.Permissions": case "System.Security.Policy":