You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -6,7 +6,7 @@ IF "%ErrorCode%"=="100" (
|
||||
echo %~n0: pass
|
||||
EXIT /b 0
|
||||
) ELSE (
|
||||
echo %~n0: fail
|
||||
echo %~n0: fail - %ErrorCode%
|
||||
EXIT /b 1
|
||||
)
|
||||
endlocal
|
||||
|
||||
@@ -34,6 +34,9 @@ public class ReflectionTest
|
||||
if (TestReflectionFieldAccess() == Fail)
|
||||
return Fail;
|
||||
|
||||
if (TestCreateDelegate() == Fail)
|
||||
return Fail;
|
||||
|
||||
return Pass;
|
||||
}
|
||||
|
||||
@@ -121,6 +124,12 @@ public class ReflectionTest
|
||||
|
||||
internal class InvokeTests
|
||||
{
|
||||
private string _world = "world";
|
||||
|
||||
public InvokeTests() { }
|
||||
|
||||
public InvokeTests(string message) { _world = message; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public static string GetHello(string name)
|
||||
{
|
||||
@@ -138,6 +147,12 @@ public class ReflectionTest
|
||||
{
|
||||
return "Hello " + obj;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public string GetHelloInstance()
|
||||
{
|
||||
return "Hello " + _world;
|
||||
}
|
||||
}
|
||||
|
||||
private static int TestReflectionInvoke()
|
||||
@@ -177,14 +192,13 @@ public class ReflectionTest
|
||||
return Fail;
|
||||
}
|
||||
|
||||
// TODO: Can't be tested temporarily since it would end up calling into type loader to load a ByRef type.
|
||||
//{
|
||||
// MethodInfo helloByRefMethod = typeof(InvokeTests).GetTypeInfo().GetDeclaredMethod("GetHelloByRef");
|
||||
// object[] args = new object[] { "world", null };
|
||||
// helloByRefMethod.Invoke(null, args);
|
||||
// if ((string)args[1] != "Hello world")
|
||||
// return Fail;
|
||||
//}
|
||||
{
|
||||
MethodInfo helloByRefMethod = typeof(InvokeTests).GetTypeInfo().GetDeclaredMethod("GetHelloByRef");
|
||||
object[] args = new object[] { "world", null };
|
||||
helloByRefMethod.Invoke(null, args);
|
||||
if ((string)args[1] != "Hello world")
|
||||
return Fail;
|
||||
}
|
||||
|
||||
return Pass;
|
||||
}
|
||||
@@ -228,6 +242,38 @@ public class ReflectionTest
|
||||
return Pass;
|
||||
}
|
||||
}
|
||||
|
||||
delegate string GetHelloInstanceDelegate(InvokeTests o);
|
||||
|
||||
private static int TestCreateDelegate()
|
||||
{
|
||||
Console.WriteLine("Testing MethodInfo.CreateDelegate");
|
||||
|
||||
// Dummy code to make sure the reflection targets are compiled.
|
||||
if (String.Empty.Length > 0)
|
||||
{
|
||||
new InvokeTests().GetHelloInstance();
|
||||
GetHelloInstanceDelegate d = null;
|
||||
Func<InvokeTests, string> d2 = d.Invoke;
|
||||
d = d2.Invoke;
|
||||
}
|
||||
|
||||
TypeInfo ti = typeof(InvokeTests).GetTypeInfo();
|
||||
MethodInfo mi = ti.GetDeclaredMethod("GetHelloInstance");
|
||||
{
|
||||
var d = (GetHelloInstanceDelegate)mi.CreateDelegate(typeof(GetHelloInstanceDelegate));
|
||||
if (d(new InvokeTests("mom")) != "Hello mom")
|
||||
return Fail;
|
||||
}
|
||||
|
||||
{
|
||||
var d = (Func<InvokeTests, string>)mi.CreateDelegate(typeof(Func<InvokeTests, string>));
|
||||
if (d(new InvokeTests("pop")) != "Hello pop")
|
||||
return Fail;
|
||||
}
|
||||
|
||||
return Pass;
|
||||
}
|
||||
}
|
||||
|
||||
class UnallocatedType { }
|
||||
|
||||
Reference in New Issue
Block a user