You've already forked linux-packaging-mono
Imported Upstream version 5.14.0.78
Former-commit-id: 3494343bcc9ddb42b36b82dd9ae7b69e85e0229f
This commit is contained in:
parent
74b74abd9f
commit
19234507ba
@ -525,7 +525,7 @@ namespace MonoTests.System.Reflection.Emit
|
||||
|
||||
var field = type.DefineField ("field", t, FieldAttributes.Public);
|
||||
|
||||
type.CreateType ();
|
||||
var tc = type.CreateType ();
|
||||
|
||||
var resolved_field = (FieldInfo) module.ResolveMember (0x04000001, new [] { typeof (string) }, Type.EmptyTypes);
|
||||
Assert.IsNotNull (resolved_field);
|
||||
@ -1185,5 +1185,55 @@ namespace MonoTests.System.Reflection.Emit
|
||||
Assert.AreEqual ("17", s2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FieldBuilder_DistinctTokens ()
|
||||
{
|
||||
// Regression test for #33208
|
||||
// Fields of distinct classes in the same
|
||||
// module should have distinct tokens.
|
||||
|
||||
AssemblyBuilder ab = genAssembly ();
|
||||
ModuleBuilder module = ab.DefineDynamicModule ("foo.dll", "foo.dll");
|
||||
|
||||
var tb1 = module.DefineType ("T1", TypeAttributes.Public);
|
||||
|
||||
var tb2 = module.DefineType ("T2", TypeAttributes.Public);
|
||||
|
||||
FieldBuilder fbX1 = tb1.DefineField ("X", typeof (Object), FieldAttributes.Public);
|
||||
|
||||
FieldBuilder fbX2 = tb2.DefineField ("X", typeof (Object), FieldAttributes.Public);
|
||||
|
||||
FieldBuilder fbY1 = tb1.DefineField ("Y", typeof (int), FieldAttributes.Public);
|
||||
|
||||
Assert.AreNotEqual (fbX1.GetToken (), fbX2.GetToken (), "GetToken() T1.X != T2.X");
|
||||
Assert.AreNotEqual (fbX1.GetToken (), fbY1.GetToken (), "GetToken() T1.X != T1.Y");
|
||||
Assert.AreNotEqual (fbY1.GetToken (), fbX2.GetToken (), "GetToken() T1.Y != T2.X");
|
||||
|
||||
// .NET throws NotSupportedException for
|
||||
// FieldBuilder.MetadataToken, Mono doesn't.
|
||||
// We'll check that the metadata tokens are
|
||||
// distinct, but it's also okay to take these
|
||||
// assertions out if we start following .NET
|
||||
// behavior.
|
||||
Assert.AreNotEqual (fbX1.MetadataToken, fbX2.MetadataToken, "MetadataToken T1.X != T2.X");
|
||||
Assert.AreNotEqual (fbX1.MetadataToken, fbY1.MetadataToken, "MetadataToken T1.X != T1.Y");
|
||||
Assert.AreNotEqual (fbY1.MetadataToken, fbX2.MetadataToken, "MetadataToken T1.Y != T2.X");
|
||||
|
||||
var t1 = tb1.CreateType ();
|
||||
var t2 = tb2.CreateType ();
|
||||
|
||||
FieldInfo fX1 = t1.GetField ("X");
|
||||
FieldInfo fX2 = t2.GetField ("X");
|
||||
|
||||
FieldInfo fY1 = t1.GetField ("Y");
|
||||
|
||||
Assert.AreNotEqual (fX1.MetadataToken, fX2.MetadataToken, "T1.X != T2.X");
|
||||
Assert.AreNotEqual (fX1.MetadataToken, fY1.MetadataToken, "T1.X != T1.Y");
|
||||
Assert.AreNotEqual (fY1.MetadataToken, fX2.MetadataToken, "T1.Y != T2.X");
|
||||
|
||||
Assert.AreEqual (module.ResolveField (fX1.MetadataToken), fX1, "resolve T1.X");
|
||||
Assert.AreEqual (module.ResolveField (fX2.MetadataToken), fX2, "resolve T2.X");
|
||||
Assert.AreEqual (module.ResolveField (fY1.MetadataToken), fY1, "resolve T1.Y");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace MonoTests.System.Runtime.CompilerServices {
|
||||
var a = new TypeForwardedFromAttribute ("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a");
|
||||
Assert.AreEqual ("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a", a.AssemblyFullName);
|
||||
|
||||
Assert.Throws<ArgumentNullException> ( () => new TypeForwardedFromAttribute (null) );
|
||||
var nullArgumentDoesntThrowException = new TypeForwardedFromAttribute (null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
//
|
||||
// MonoTests.System.Runtime.Remoting.RemotingServicesTest.cs
|
||||
//
|
||||
// Author: Alexis Christoforides (alchri@microsoft.com)
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Runtime.Remoting
|
||||
{
|
||||
[TestFixture]
|
||||
public class RemotingServicesTest
|
||||
{
|
||||
public class AppDomainObject : MarshalByRefObject
|
||||
{
|
||||
public void Init(CrossDomainSerializedObject applicationDependencies) // racy exception here
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class CrossDomainSerializedObject : MarshalByRefObject
|
||||
{
|
||||
}
|
||||
private static CrossDomainSerializedObject crossDomainSerializedObject;
|
||||
|
||||
private static void AppDomainWithRemotingSerialization(Assembly assembly, string name)
|
||||
{
|
||||
var appDomain = AppDomain.CreateDomain(name);
|
||||
var appDomainObject = (AppDomainObject)appDomain.CreateInstanceAndUnwrap(assembly.GetName().Name, typeof(AppDomainObject).FullName);
|
||||
appDomainObject.Init(crossDomainSerializedObject);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Bug46473 () // concurrent serialization/deserialization
|
||||
{
|
||||
bool success = true;
|
||||
crossDomainSerializedObject = new CrossDomainSerializedObject();
|
||||
Task[] tasks = new Task [20];
|
||||
for (int i = 0; i < tasks.Length; i++)
|
||||
{
|
||||
var assembly = Assembly.GetAssembly(typeof(AppDomainObject));
|
||||
var name = "AppDomainWithCall" + i;
|
||||
tasks [i] = Task.Factory.StartNew(() => AppDomainWithRemotingSerialization(assembly, name));
|
||||
}
|
||||
try {
|
||||
Task.WaitAll (tasks);
|
||||
} catch (AggregateException e) {
|
||||
success = false;
|
||||
Console.WriteLine ($"{e}, {e.InnerException}");
|
||||
}
|
||||
Assert.IsTrue (success, "Bug46473 (exception during remoting call)");
|
||||
}
|
||||
}
|
||||
}
|
@ -569,7 +569,6 @@ namespace MonoTests.System.Threading.Tasks
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("MacNotWorking")] // Randomly fails - https://bugzilla.xamarin.com/show_bug.cgi?id=51255
|
||||
public void FromAsync_BeginCallback ()
|
||||
{
|
||||
bool called = false;
|
||||
@ -586,8 +585,9 @@ namespace MonoTests.System.Threading.Tasks
|
||||
Assert.IsFalse (Thread.CurrentThread.IsThreadPoolThread, "#12");
|
||||
|
||||
called2 = true;
|
||||
b.Invoke (null);
|
||||
return null;
|
||||
var ar = Task.CompletedTask;
|
||||
b.Invoke (ar);
|
||||
return ar;
|
||||
},
|
||||
l => {
|
||||
called = true;
|
||||
|
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace MonoTests.System.Threading.Tasks
|
||||
{
|
||||
[TestFixture]
|
||||
public class ThreadPrincipalTests
|
||||
{
|
||||
[Test]
|
||||
public void PrincipalFlowsToAsyncTask ()
|
||||
{
|
||||
var t = _PrincipalFlowsToAsyncTask();
|
||||
t.GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public async Task _PrincipalFlowsToAsyncTask ()
|
||||
{
|
||||
var mockIdentity = new MockIdentity {
|
||||
AuthenticationType = "authtype",
|
||||
IsAuthenticated = true,
|
||||
Name = "name"
|
||||
};
|
||||
var mockPrincipal = new MockPrincipal {
|
||||
Identity = mockIdentity
|
||||
};
|
||||
var oldPrincipal = Thread.CurrentPrincipal;
|
||||
Thread.CurrentPrincipal = mockPrincipal;
|
||||
|
||||
try {
|
||||
await Task.Factory.StartNew(async () =>
|
||||
{
|
||||
var newThreadId = Thread.CurrentThread.ManagedThreadId; // on different thread.
|
||||
Assert.IsTrue(Thread.CurrentPrincipal.Identity.IsAuthenticated);
|
||||
Assert.AreEqual(mockPrincipal, Thread.CurrentPrincipal);
|
||||
|
||||
await Task.Factory.StartNew(() =>
|
||||
{
|
||||
// still works even when nesting..
|
||||
newThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||
Assert.IsTrue(Thread.CurrentPrincipal.Identity.IsAuthenticated);
|
||||
Assert.AreEqual(mockPrincipal, Thread.CurrentPrincipal);
|
||||
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// Following works on NET4.7 and fails under Xamarin.Android.
|
||||
var newThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||
Assert.IsTrue(Thread.CurrentPrincipal.Identity.IsAuthenticated);
|
||||
Assert.AreEqual(mockPrincipal, Thread.CurrentPrincipal);
|
||||
});
|
||||
} finally {
|
||||
Thread.CurrentPrincipal = oldPrincipal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MockPrincipal : IPrincipal {
|
||||
public IIdentity Identity { get; set; }
|
||||
public bool IsInRole (string role) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class MockIdentity : IIdentity {
|
||||
public string AuthenticationType { get; set; }
|
||||
public bool IsAuthenticated { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -835,6 +835,7 @@ namespace MonoTests.System.Threading
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorkingRuntimeInterpreter")]
|
||||
public void Test_Interrupt ()
|
||||
{
|
||||
ManualResetEvent mre = new ManualResetEvent (false);
|
||||
|
@ -1 +1 @@
|
||||
be5e7984757b64a30bba3b7274a9f86edfab970f
|
||||
0be02f7a0bafa90f444ffe344ae9d4564513f5f1
|
@ -1 +1 @@
|
||||
9feda2ab31c0832aa8ddef3b30100db2246253e7
|
||||
744f1a217a1af896659e714634a6b4c7b8a08b5a
|
Reference in New Issue
Block a user