Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -1112,6 +1112,7 @@ public class AssemblyNameTest {
[Test]
[Category ("AndroidNotWorking")] // Accessing assemblies by asm.Location is not supported
[Category ("StaticLinkedAotNotWorking")] // Can't find .dll files when bundled in .exe
[Category ("NotWasm")]
public void GetAssemblyName_CodeBase ()
{
Assembly execAssembly = Assembly.GetExecutingAssembly ();

View File

@@ -195,7 +195,7 @@ namespace MonoTests.System.Reflection
// note: only available in default appdomain
// http://weblogs.asp.net/asanto/archive/2003/09/08/26710.aspx
// Not sure we should emulate this behavior.
#if MONOTOUCH_WATCH
#if MONOTOUCH_WATCH || WASM
Assert.IsNull (Assembly.GetEntryAssembly (), "GetEntryAssembly");
Assert.IsTrue (AppDomain.CurrentDomain.IsDefaultAppDomain (), "!default appdomain");
#elif !MONODROID
@@ -318,6 +318,7 @@ namespace MonoTests.System.Reflection
[Test]
[Category ("AndroidNotWorking")] // Assemblies in Xamarin.Android cannot be accessed as FileStream
[Category ("StaticLinkedAotNotWorking")] // Can't find .dll files when bundled in .exe
[Category ("NotWasm")]
public void GetFiles_False ()
{
Assembly corlib = typeof (int).Assembly;
@@ -332,6 +333,7 @@ namespace MonoTests.System.Reflection
[Test]
[Category ("AndroidNotWorking")] // Assemblies in Xamarin.Android cannot be accessed as FileStream
[Category ("StaticLinkedAotNotWorking")] // Can't find .dll files when bundled in .exe
[Category ("NotWasm")]
public void GetFiles_True ()
{
Assembly corlib = typeof (int).Assembly;
@@ -461,6 +463,7 @@ namespace MonoTests.System.Reflection
}
[Test]
[Category ("StackWalks")]
public void LoadWithPartialName ()
{
// FIXME?
@@ -1133,7 +1136,7 @@ namespace MonoTests.System.Reflection
Module module = assembly.ManifestModule;
Assert.IsNotNull (module, "#1");
Assert.AreEqual ("MonoModule", module.GetType ().Name, "#2");
Assert.AreEqual ("RuntimeModule", module.GetType ().Name, "#2");
#if !MONOTOUCH && !FULL_AOT_RUNTIME
Assert.AreEqual ("mscorlib.dll", module.Name, "#3");
@@ -1244,6 +1247,7 @@ namespace MonoTests.System.Reflection
}
[Test]
[Category ("StackWalks")]
public void GetCallingAssembly_Direct() {
var a = GetCallingAssemblyCallee.DirectCall ();
Assert.IsNotNull (a);
@@ -1252,6 +1256,7 @@ namespace MonoTests.System.Reflection
}
[Test]
[Category ("StackWalks")]
public void GetCallingAssembly_SkipsReflection () {
// check that the calling assembly is this
// one, not mscorlib (aka, the reflection

View File

@@ -149,5 +149,14 @@ namespace MonoTests.System.Reflection
Assert.AreEqual (type.Module, co.Module);
}
delegate int D1 ();
[Test] // https://github.com/mono/mono/issues/10838
public void Issue10838 ()
{
var ctorInfo = typeof (D1).GetConstructors ()[0];
Assert.AreEqual ("Void .ctor(System.Object, IntPtr)", ctorInfo.ToString ());
}
}
}

View File

@@ -130,7 +130,44 @@ namespace MonoTests.System.Reflection
Assert.IsTrue ((int)ev.MetadataToken > 0);
}
[Test]
public void TestDerivedClassHidingEventWithPrivate ()
{
Type derived = typeof(Derived);
EventInfo[] events = derived.GetEvents (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
Assert.AreEqual(0, events.Length, "MyEvent event is private in derived class and should be hidden.");
Type staticDerived2 = typeof(StaticDerived2);
EventInfo[] events2 = staticDerived2.GetEvents(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
Console.WriteLine(events2.Length);
}
[Test]
public void TestDerivedClassOveridingEventWithStatic () {
Type staticDerived2 = typeof(StaticDerived2);
EventInfo[] events = staticDerived2.GetEvents(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
Assert.AreEqual(0, events.Length, "MyEvent event is static in parent class and should be hidden.");
}
// https://github.com/mono/mono/issues/13350
[Test]
public void ReflectedType () {
Type type = typeof (B);
EventInfo eventInfo = type.GetEvent (nameof (A.Event));
MemberInfo memberInfo = eventInfo.AddMethod;
Assert.AreEqual (type, memberInfo.ReflectedType);
}
#pragma warning disable 67
public class A
{
public event Action Event { add { } remove { } }
}
public class B : A
{
}
public class PrivateEvent
{
private static event EventHandler x;
@@ -147,6 +184,35 @@ namespace MonoTests.System.Reflection
private event EventHandler priv;
}
private abstract class Base
{
public event Action MyEvent { add { } remove { } }
public int MyProp { get; }
}
private abstract class Derived : Base
{
private new event Action MyEvent { add { } remove { } }
private new int MyProp { get; }
}
private abstract class Derived2 : Derived
{
}
private class StaticBase
{
public event Action MyEvent { add { } remove { } }
}
private class StaticDerived : StaticBase
{
public new static event Action MyEvent { add { } remove { } }
}
private class StaticDerived2 : StaticDerived
{
}
#pragma warning restore 67
}
}

View File

@@ -261,7 +261,7 @@ namespace MonoTests.System.Reflection.Emit
ic = ib.MakeGenericType(typeof (char)); // this is a MonoGenericMethod
var mintf = TypeBuilder.GetMethod(ic, winfo);
// the next line causes mono_class_init() to
// the next line causes mono_class_init_internal () to
// be called on JJJ<char> when we try to setup
// the vtable for SSS
tb.DefineMethodOverride(mb, mintf);

View File

@@ -11,6 +11,9 @@
using System;
using System.Threading;
using System.Reflection;
#if !MONOTOUCH && !FULL_AOT_RUNTIME
using System.Reflection.Emit;
#endif
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
@@ -527,6 +530,40 @@ namespace MonoTests.System.Reflection
Assert.AreEqual (null, type.GetMethod ("M5").GetParameters () [0].RawDefaultValue);
}
public sealed class A { }
public sealed class B { }
public sealed class C { }
public sealed class D { }
#if !MONOTOUCH && !FULL_AOT_RUNTIME
[Test]
// https://github.com/mono/mono/issues/11302
public void CustomModifiersOrder()
{
var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly (new AssemblyName ("SomeAssembly"), AssemblyBuilderAccess.RunAndSave);
var moduleBuilder = assemblyBuilder.DefineDynamicModule ("SomeAssembly", "SomeAssembly.dll");
var typeBuilder = moduleBuilder.DefineType ("SomeClass", TypeAttributes.Class);
var methodBuilder = typeBuilder.DefineMethod (
"SomeMethod",
MethodAttributes.Public,
CallingConventions.HasThis,
typeof (void),
null,
null,
new[] { typeof (int) },
new[] { new[] { typeof (A), typeof (B), typeof (A), typeof (A) } },
new[] { new[] { typeof (C), typeof (D), typeof (C), typeof (C) } });
methodBuilder.GetILGenerator ().Emit (OpCodes.Ret);
var type = typeBuilder.CreateType ();
var method = type.GetMethod ("SomeMethod");
var parameter = method.GetParameters () [0];
var requiredCustomModifiers = parameter.GetRequiredCustomModifiers ();
Assert.AreEqual (new[] { typeof (A), typeof (A), typeof (B), typeof (A) }, requiredCustomModifiers);
var optionalCustomModifiers = parameter.GetOptionalCustomModifiers ();
Assert.AreEqual (new[] { typeof (C), typeof (C), typeof (D), typeof (C) }, optionalCustomModifiers);
}
#endif
[Test]
public void ReturnParameter_IsDefined_False ()
{