Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -140,7 +140,7 @@ namespace System.Reflection.Tests
public void Invoke_ParameterWrongType_ThrowsArgumentException()
{
ConstructorInfo[] constructors = GetConstructors(typeof(ClassWith3Constructors));
Assert.Throws<ArgumentException>(() => (ClassWith3Constructors)constructors[1].Invoke(new object[] { "hello" }));
AssertExtensions.Throws<ArgumentException>(null, () => (ClassWith3Constructors)constructors[1].Invoke(new object[] { "hello" }));
}
[Fact]

View File

@@ -314,9 +314,9 @@ namespace System.Reflection.Tests
object obj = Activator.CreateInstance(type);
FieldInfo fieldInfo = GetField(type, "bArray");
Assert.Throws<ArgumentException>(() => fieldInfo.SetValue(obj, ATypeWithMixedAB));
Assert.Throws<ArgumentException>(() => fieldInfo.SetValue(obj, ATypeWithAllA));
Assert.Throws<ArgumentException>(() => fieldInfo.SetValue(obj, ATypeWithAllB));
AssertExtensions.Throws<ArgumentException>(null, () => fieldInfo.SetValue(obj, ATypeWithMixedAB));
AssertExtensions.Throws<ArgumentException>(null, () => fieldInfo.SetValue(obj, ATypeWithAllA));
AssertExtensions.Throws<ArgumentException>(null, () => fieldInfo.SetValue(obj, ATypeWithAllB));
fieldInfo.SetValue(obj, BTypeWithAllB);
Assert.Equal(BTypeWithAllB, fieldInfo.GetValue(obj));
@@ -348,7 +348,7 @@ namespace System.Reflection.Tests
fieldInfo.SetValue(obj, intArray);
Assert.Equal(intArray, fieldInfo.GetValue(obj));
Assert.Throws<ArgumentException>(() => fieldInfo.SetValue(obj, new byte[] { 2, 3, 4 }));
AssertExtensions.Throws<ArgumentException>(null, () => fieldInfo.SetValue(obj, new byte[] { 2, 3, 4 }));
}
[Fact]
@@ -366,8 +366,8 @@ namespace System.Reflection.Tests
fieldInfo.SetValue(obj, BTypeWithAllB_Contra);
Assert.Equal(BTypeWithAllB_Contra, fieldInfo.GetValue(obj));
Assert.Throws<ArgumentException>(() => fieldInfo.SetValue(obj, new int[] { 1, -1, 2, -2 }));
Assert.Throws<ArgumentException>(() => fieldInfo.SetValue(obj, new byte[] { 2, 3, 4 }));
AssertExtensions.Throws<ArgumentException>(null, () => fieldInfo.SetValue(obj, new int[] { 1, -1, 2, -2 }));
AssertExtensions.Throws<ArgumentException>(null, () => fieldInfo.SetValue(obj, new byte[] { 2, 3, 4 }));
}
public static IEnumerable<object[]> FieldInfoRTGenericTests_TestData()

View File

@@ -26,7 +26,7 @@ namespace System.Reflection.Tests
Assert.Null(Type.GetType(aqn, throwOnError: false));
Assert.Throws<TypeLoadException>(() => Type.GetType(typeName, throwOnError: true));
Assert.Throws<ArgumentException>(() => Type.GetType(aqn, throwOnError: true));
AssertExtensions.Throws<ArgumentException>("typeName@0", () => Type.GetType(aqn, throwOnError: true));
Assert.Null(Type.GetType(typeName, throwOnError: false, ignoreCase: false));
Assert.Null(Type.GetType(typeName, throwOnError: false, ignoreCase: true));
@@ -35,33 +35,33 @@ namespace System.Reflection.Tests
Assert.Throws<TypeLoadException>(() => Type.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Throws<TypeLoadException>(() => Type.GetType(typeName, throwOnError: true, ignoreCase: true));
Assert.Throws<ArgumentException>(() => Type.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => Type.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>("typeName@0", () => Type.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>("typeName@0", () => Type.GetType(aqn, throwOnError: true, ignoreCase: true));
// Assembly.GetType
Assert.Throws<ArgumentException>(() => a.GetType(typeName));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(typeName));
Assert.Null(a.GetType(aqn));
Assert.Throws<ArgumentException>(() => a.GetType(typeName, throwOnError: false, ignoreCase: false));
Assert.Throws<ArgumentException>(() => a.GetType(typeName, throwOnError: false, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(typeName, throwOnError: false, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(typeName, throwOnError: false, ignoreCase: true));
Assert.Null(a.GetType(aqn, throwOnError: false, ignoreCase: false));
Assert.Null(a.GetType(aqn, throwOnError: false, ignoreCase: true));
Assert.Throws<ArgumentException>(() => a.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => a.GetType(typeName, throwOnError: true, ignoreCase: true));
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(typeName, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(typeName, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>("typeName@0", () => a.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>("typeName@0", () => a.GetType(aqn, throwOnError: true, ignoreCase: true));
// Module.GetType
Assert.Throws<ArgumentException>(() => m.GetType(typeName, throwOnError: false, ignoreCase: false));
Assert.Throws<ArgumentException>(() => m.GetType(typeName, throwOnError: false, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(typeName, throwOnError: false, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(typeName, throwOnError: false, ignoreCase: true));
Assert.Null(m.GetType(aqn, throwOnError: false, ignoreCase: false));
Assert.Null(m.GetType(aqn, throwOnError: false, ignoreCase: true));
Assert.Throws<ArgumentException>(() => m.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => m.GetType(typeName, throwOnError: true, ignoreCase: true));
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(typeName, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(typeName, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>("typeName@0", () => m.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>("typeName@0", () => m.GetType(aqn, throwOnError: true, ignoreCase: true));
}
public static IEnumerable<object[]> GetType_TestData()
@@ -126,8 +126,8 @@ namespace System.Reflection.Tests
Assert.Throws<TypeLoadException>(() => a.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Throws<TypeLoadException>(() => a.GetType(typeName, throwOnError: true, ignoreCase: true));
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(aqn, throwOnError: true, ignoreCase: true));
// Module.GetType
Assert.Null(m.GetType(typeName, throwOnError: false, ignoreCase: false));
@@ -137,8 +137,8 @@ namespace System.Reflection.Tests
Assert.Throws<TypeLoadException>(() => m.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Throws<TypeLoadException>(() => m.GetType(typeName, throwOnError: true, ignoreCase: true));
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(aqn, throwOnError: true, ignoreCase: true));
}
else if (expectedResult.FullName == typeName)
{
@@ -180,8 +180,8 @@ namespace System.Reflection.Tests
Assert.Equal(expectedResult, a.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Equal(expectedName, a.GetType(typeName, throwOnError: true, ignoreCase: true).AssemblyQualifiedName, StringComparer.OrdinalIgnoreCase);
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(aqn, throwOnError: true, ignoreCase: true));
// Module.GetType
Assert.Equal(expectedResult, m.GetType(typeName, throwOnError: false, ignoreCase: false));
@@ -191,8 +191,8 @@ namespace System.Reflection.Tests
Assert.Equal(expectedResult, m.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Equal(expectedName, m.GetType(typeName, throwOnError: true, ignoreCase: true).AssemblyQualifiedName, StringComparer.OrdinalIgnoreCase);
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(aqn, throwOnError: true, ignoreCase: true));
}
else if (expectedResult.FullName.Equals(typeName, StringComparison.OrdinalIgnoreCase))
{
@@ -234,8 +234,8 @@ namespace System.Reflection.Tests
Assert.Throws<TypeLoadException>(() => a.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Equal(expectedName, a.GetType(typeName, throwOnError: true, ignoreCase: true).AssemblyQualifiedName, StringComparer.OrdinalIgnoreCase);
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => a.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => a.GetType(aqn, throwOnError: true, ignoreCase: true));
// Module.GetType
Assert.Null(m.GetType(typeName, throwOnError: false, ignoreCase: false));
@@ -245,8 +245,8 @@ namespace System.Reflection.Tests
Assert.Throws<TypeLoadException>(() => m.GetType(typeName, throwOnError: true, ignoreCase: false));
Assert.Equal(expectedName, m.GetType(typeName, throwOnError: true, ignoreCase: true).AssemblyQualifiedName, StringComparer.OrdinalIgnoreCase);
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: false));
Assert.Throws<ArgumentException>(() => m.GetType(aqn, throwOnError: true, ignoreCase: true));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(aqn, throwOnError: true, ignoreCase: false));
AssertExtensions.Throws<ArgumentException>(null, () => m.GetType(aqn, throwOnError: true, ignoreCase: true));
}
else
{

View File

@@ -296,7 +296,7 @@ namespace System.Reflection.Tests
[Fact]
public static void Invoke_OptionalParameterUnassingableFromMissing_WithMissingValue_ThrowsArgumentException()
{
Assert.Throws<ArgumentException>(() => GetMethod(typeof(MethodInfoDefaultParameters), "OptionalStringParameter").Invoke(new MethodInfoDefaultParameters(), new object[] { Type.Missing }));
AssertExtensions.Throws<ArgumentException>(null, () => GetMethod(typeof(MethodInfoDefaultParameters), "OptionalStringParameter").Invoke(new MethodInfoDefaultParameters(), new object[] { Type.Missing }));
}
[Theory]
@@ -323,9 +323,9 @@ namespace System.Reflection.Tests
Assert.Throws<InvalidOperationException>(() => GetMethod(typeof(MI_SubClass), nameof(MI_SubClass.VoidMethodReturningInt)).MakeGenericMethod(typeof(int))); // Method is non generic
// Number of typeArguments does not match
Assert.Throws<ArgumentException>(() => GetMethod(typeof(MI_SubClass), nameof(MI_SubClass.GenericMethod1)).MakeGenericMethod());
Assert.Throws<ArgumentException>(() => GetMethod(typeof(MI_SubClass), nameof(MI_SubClass.GenericMethod1)).MakeGenericMethod(typeof(string), typeof(int)));
Assert.Throws<ArgumentException>(() => GetMethod(typeof(MI_SubClass), nameof(MI_SubClass.GenericMethod2)).MakeGenericMethod(typeof(int)));
AssertExtensions.Throws<ArgumentException>(null, () => GetMethod(typeof(MI_SubClass), nameof(MI_SubClass.GenericMethod1)).MakeGenericMethod());
AssertExtensions.Throws<ArgumentException>(null, () => GetMethod(typeof(MI_SubClass), nameof(MI_SubClass.GenericMethod1)).MakeGenericMethod(typeof(string), typeof(int)));
AssertExtensions.Throws<ArgumentException>(null, () => GetMethod(typeof(MI_SubClass), nameof(MI_SubClass.GenericMethod2)).MakeGenericMethod(typeof(int)));
}
[Theory]

View File

@@ -388,7 +388,7 @@ namespace System.Reflection.Tests
[Fact]
public void GetEnumName_Invalid()
{
Assert.Throws<ArgumentException>(() => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumName(""));
AssertExtensions.Throws<ArgumentException>("value", () => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumName(""));
Assert.Throws<ArgumentNullException>(() => typeof(IntEnum).GetTypeInfo().GetEnumName(null));
}
@@ -408,7 +408,7 @@ namespace System.Reflection.Tests
[Fact]
public void GetEnumNames_TypeNotEnum_ThrowsArgumentException()
{
Assert.Throws<ArgumentException>(() => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumNames());
AssertExtensions.Throws<ArgumentException>("enumType", () => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumNames());
}
[Theory]
@@ -422,7 +422,7 @@ namespace System.Reflection.Tests
[Fact]
public void GetEnumUnderlyingType_TypeNotEnum_ThrowsArgumentException()
{
Assert.Throws<ArgumentException>(() => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumUnderlyingType());
AssertExtensions.Throws<ArgumentException>("enumType", () => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumUnderlyingType());
}
[Fact]
@@ -445,7 +445,7 @@ namespace System.Reflection.Tests
[Fact]
public void GetEnumValues_TypeNotEnum_ThrowsArgumentException()
{
Assert.Throws<ArgumentException>(() => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumUnderlyingType());
AssertExtensions.Throws<ArgumentException>("enumType", () => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().GetEnumUnderlyingType());
}
[Theory]
@@ -459,7 +459,7 @@ namespace System.Reflection.Tests
[Fact]
public void IsEnumDefined_Invalid()
{
Assert.Throws<ArgumentException>(() => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().IsEnumDefined(10));
AssertExtensions.Throws<ArgumentException>("", () => typeof(NonGenericClassWithNoInterfaces).GetTypeInfo().IsEnumDefined(10));
Assert.Throws<ArgumentNullException>(() => typeof(IntEnum).GetTypeInfo().IsEnumDefined(null));
Assert.Throws<InvalidOperationException>(() => typeof(IntEnum).GetTypeInfo().IsEnumDefined(new NonGenericClassWithNoInterfaces()));
}