You've already forked linux-packaging-mono
Imported Upstream version 4.2.1.60
Former-commit-id: 05052d1d7a3a94b0d9ee70461d62b6591e5ab5bc
This commit is contained in:
committed by
Jo Shields
parent
ea5caba957
commit
bdd40f83c0
@@ -60,6 +60,7 @@ namespace System
|
||||
private object m_target;
|
||||
private IntPtr method;
|
||||
private IntPtr delegate_trampoline;
|
||||
private IntPtr rgctx;
|
||||
private IntPtr method_code;
|
||||
private MethodInfo method_info;
|
||||
|
||||
@@ -68,6 +69,8 @@ namespace System
|
||||
private MethodInfo original_method_info;
|
||||
|
||||
private DelegateData data;
|
||||
|
||||
private bool method_is_virtual;
|
||||
#pragma warning restore 169, 414, 649
|
||||
#endregion
|
||||
|
||||
@@ -103,13 +106,19 @@ namespace System
|
||||
return method_info;
|
||||
} else {
|
||||
if (method != IntPtr.Zero) {
|
||||
method_info = (MethodInfo)MethodBase.GetMethodFromHandleNoGenericCheck (new RuntimeMethodHandle (method));
|
||||
if (!method_is_virtual)
|
||||
method_info = (MethodInfo)MethodBase.GetMethodFromHandleNoGenericCheck (new RuntimeMethodHandle (method));
|
||||
else
|
||||
method_info = GetVirtualMethod_internal ();
|
||||
}
|
||||
return method_info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
extern MethodInfo GetVirtualMethod_internal ();
|
||||
|
||||
public object Target {
|
||||
get {
|
||||
return m_target;
|
||||
@@ -467,13 +476,15 @@ namespace System
|
||||
return MemberwiseClone ();
|
||||
}
|
||||
|
||||
internal bool Compare (Delegate d)
|
||||
public override bool Equals (object obj)
|
||||
{
|
||||
Delegate d = obj as Delegate;
|
||||
|
||||
if (d == null)
|
||||
return false;
|
||||
|
||||
|
||||
// Do not compare method_ptr, since it can point to a trampoline
|
||||
if (d.m_target == m_target && d.method == method) {
|
||||
if (d.m_target == m_target && d.Method == Method) {
|
||||
if (d.data != null || data != null) {
|
||||
/* Uncommon case */
|
||||
if (d.data != null && data != null)
|
||||
@@ -492,14 +503,10 @@ namespace System
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool Equals (object obj)
|
||||
{
|
||||
return Compare (obj as Delegate);
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return method.GetHashCode () ^ (m_target != null ? m_target.GetHashCode () : 0);
|
||||
/* same implementation as CoreCLR */
|
||||
return GetType ().GetHashCode ();
|
||||
}
|
||||
|
||||
protected virtual MethodInfo GetMethodImpl ()
|
||||
|
@@ -57,7 +57,7 @@ namespace System {
|
||||
* of icalls, do not require an increment.
|
||||
*/
|
||||
#pragma warning disable 169
|
||||
private const int mono_corlib_version = 135;
|
||||
private const int mono_corlib_version = 138;
|
||||
#pragma warning restore 169
|
||||
|
||||
[ComVisible (true)]
|
||||
|
@@ -361,14 +361,20 @@ namespace MonoTests.System.Reflection
|
||||
|
||||
IList<LocalVariableInfo> locals = mb.LocalVariables;
|
||||
|
||||
// This might break with different compilers etc.
|
||||
Assert.AreEqual (2, locals.Count, "#3");
|
||||
bool foundPinnedBytePointer = false;
|
||||
unsafe {
|
||||
foreach (LocalVariableInfo lvi in locals) {
|
||||
if (lvi.LocalType == typeof (byte[]))
|
||||
// This is optimized out by CSC in .NET 4.6
|
||||
Assert.IsFalse (lvi.IsPinned, "#3-1");
|
||||
|
||||
Assert.IsTrue ((locals [0].LocalType == typeof (byte[])) || (locals [1].LocalType == typeof (byte[])), "#4");
|
||||
if (locals [0].LocalType == typeof (byte[]))
|
||||
Assert.AreEqual (false, locals [0].IsPinned, "#5");
|
||||
else
|
||||
Assert.AreEqual (false, locals [1].IsPinned, "#6");
|
||||
if (/* mcs */ lvi.LocalType == typeof (byte*) || /* csc */ lvi.LocalType == typeof (byte).MakeByRefType ()) {
|
||||
foundPinnedBytePointer = true;
|
||||
Assert.IsTrue (lvi.IsPinned, "#3-2");
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.IsTrue (foundPinnedBytePointer, "#4");
|
||||
}
|
||||
|
||||
public int return_parameter_test ()
|
||||
@@ -804,21 +810,44 @@ namespace MonoTests.System.Reflection
|
||||
var type = typeof (GenericClass<>).GetMethod("Method").GetMethodBody().LocalVariables[0].LocalType;
|
||||
Assert.AreEqual (typeofT, type);
|
||||
Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
|
||||
|
||||
bool foundTypeOfK = false;
|
||||
bool foundExpectedType = false;
|
||||
|
||||
MethodBody mb = typeof (GenericClass<>).GetMethod("Method2").GetMethodBody();
|
||||
foreach (LocalVariableInfo lvi in mb.LocalVariables) {
|
||||
if (lvi.LocalType == typeofK) {
|
||||
foundTypeOfK = true;
|
||||
Assert.AreEqual (typeof (GenericClass<>), lvi.LocalType.DeclaringType, "#1-1");
|
||||
} else if (lvi.LocalType == typeofT) {
|
||||
foundExpectedType = true;
|
||||
Assert.AreEqual (typeof (GenericClass<>), lvi.LocalType.DeclaringType, "#1-2");
|
||||
}
|
||||
}
|
||||
|
||||
type = typeof (GenericClass<>).GetMethod("Method2").GetMethodBody().LocalVariables[0].LocalType;
|
||||
Assert.AreEqual (typeofT, type);
|
||||
Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
|
||||
|
||||
type = typeof (GenericClass<>).GetMethod("Method2").GetMethodBody().LocalVariables[1].LocalType;
|
||||
Assert.AreEqual (typeofK, type);
|
||||
Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
|
||||
|
||||
type = typeof (GenericClass<int>).GetMethod("Method2").GetMethodBody().LocalVariables[0].LocalType;
|
||||
Assert.AreEqual (typeof (int), type);
|
||||
|
||||
type = typeof (GenericClass<int>).GetMethod("Method2").GetMethodBody().LocalVariables[1].LocalType;
|
||||
Assert.AreEqual (typeofK, type);
|
||||
Assert.AreEqual (typeof (GenericClass<>), type.DeclaringType);
|
||||
Assert.IsTrue (foundTypeOfK, "#1-3");
|
||||
if (mb.LocalVariables.Count < 2)
|
||||
Assert.Ignore ("Code built in release mode - 'T var0' optmized out");
|
||||
else
|
||||
Assert.IsTrue (foundExpectedType, "#1-4");
|
||||
|
||||
foundTypeOfK = false;
|
||||
foundExpectedType = false;
|
||||
mb = typeof (GenericClass<int>).GetMethod("Method2").GetMethodBody();
|
||||
foreach (LocalVariableInfo lvi in mb.LocalVariables) {
|
||||
if (lvi.LocalType == typeofK) {
|
||||
foundTypeOfK = true;
|
||||
Assert.AreEqual (typeof (GenericClass<>), lvi.LocalType.DeclaringType, "#2-1");
|
||||
} else if (lvi.LocalType == typeof (int)) {
|
||||
foundExpectedType = true;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsTrue (foundTypeOfK, "#2-3");
|
||||
if (mb.LocalVariables.Count < 2)
|
||||
Assert.Ignore ("Code built in release mode - 'int var0' optmized out");
|
||||
else
|
||||
Assert.IsTrue (foundExpectedType, "#2-4");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user