Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@ -58,13 +58,13 @@ namespace MonoTests.System.Reflection
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=100)]
public string f2;
#if FEATURE_COMINTEROP
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof (Marshal1), MarshalCookie="5")]
public int f3;
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Marshal1), MarshalCookie = "5")]
public object f4;
#endif
[Obsolete]
public int f5;
}
@ -170,6 +170,15 @@ namespace MonoTests.System.Reflection
}
}
[Test]
public void FieldInfoModule ()
{
Type type = typeof (FieldInfoTest);
FieldInfo field = type.GetField ("i");
Assert.AreEqual (type.Module, field.Module);
}
[Test]
public void GetCustomAttributes ()
{
@ -347,10 +356,12 @@ namespace MonoTests.System.Reflection
Assert.AreEqual (UnmanagedType.ByValTStr, attr.Value, "#E2");
Assert.AreEqual (100, attr.SizeConst, "#E3");
#if FEATURE_COMINTEROP
attrs = typeof (Class2).GetField ("f3").GetCustomAttributes (true);
Assert.AreEqual (1, attrs.Length, "#F1");
attr = (MarshalAsAttribute) attrs [0];
Assert.AreEqual (UnmanagedType.CustomMarshaler, attr.Value, "#F2");
Assert.AreEqual ("5", attr.MarshalCookie, "#F3");
Assert.AreEqual (typeof (Marshal1), Type.GetType (attr.MarshalType), "#F4");
@ -375,6 +386,7 @@ namespace MonoTests.System.Reflection
Assert.AreEqual (UnmanagedType.CustomMarshaler, attr.Value, "#I2");
Assert.AreEqual ("5", attr.MarshalCookie, "#I3");
Assert.AreEqual (typeof (Marshal1), Type.GetType (attr.MarshalType), "#I4");
#endif
}
// Disable "field not used warning", this is intended.
@ -1329,6 +1341,27 @@ namespace MonoTests.System.Reflection
Throws (field, instance, new int[] { 3 });
}
struct TestFields {
public int MaxValue;
public string str;
}
[Test]
public void SetValueDirect ()
{
TestFields fields = new TestFields { MaxValue = 1234, str = "A" };
FieldInfo info = fields.GetType ().GetField ("MaxValue");
TypedReference reference = __makeref(fields);
info.SetValueDirect (reference, 4096);
Assert.AreEqual (4096, fields.MaxValue);
info = fields.GetType ().GetField ("str");
reference = __makeref(fields);
info.SetValueDirect (reference, "B");
Assert.AreEqual ("B", fields.str);
}
public IntEnum PPP;
public class Foo<T>