Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linker] Fix "Linked Away" exceptions with Thread.CurrentPrincipal. Fix #7321 #7510

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/linker/ios/link sdk/LinkSdkRegressionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1115,5 +1116,24 @@ public void AsQueryable_Enumerable ()
var list = new List<string> { "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");
}
}
}
10 changes: 8 additions & 2 deletions tools/linker/MonoTouch.Tuner/RemoveCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down