diff options
author | Stephen Toub <stoub@microsoft.com> | 2017-01-04 02:18:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-04 02:18:47 +0300 |
commit | 8dc68d828c1d0478e1390a7d83367b5806894b7d (patch) | |
tree | 3a307bdd9d8ffa970e2a564c42e2d6dc3b21d743 /src | |
parent | e3ee974bfb1cdd938561ace61ce462ca389ff375 (diff) | |
parent | c803de886895a271c591fcb39c71ead0039b22a2 (diff) |
Merge pull request #14603 from hughbe/ilgeneration-desktop
Support System.Reflection.Emit.ILGeneration tests on the full .NET Framework
Diffstat (limited to 'src')
-rw-r--r-- | src/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs b/src/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs index e93d028158..3f7e75fda5 100644 --- a/src/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs +++ b/src/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs @@ -575,6 +575,10 @@ namespace System.Reflection.Emit.Tests yield return new object[] { new int[0, 0] }; yield return new object[] { Enum.GetValues(CreateEnum(typeof(char), 'a')).GetValue(0) }; yield return new object[] { Enum.GetValues(CreateEnum(typeof(bool), true)).GetValue(0) }; + } + + public static IEnumerable<object[]> FloatEnum_DoubleEnum_TestData() + { yield return new object[] { Enum.GetValues(CreateEnum(typeof(float), 0.0f)).GetValue(0) }; yield return new object[] { Enum.GetValues(CreateEnum(typeof(double), 0.0)).GetValue(0) }; } @@ -586,6 +590,14 @@ namespace System.Reflection.Emit.Tests } [Theory] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Netfx doesn't support Enum.GetEnumName for float or double enums.")] + [MemberData(nameof(FloatEnum_DoubleEnum_TestData))] + public void ConstructorArgsContainsFloatEnumOrDoubleEnum_ThrowsArgumentException(object value) + { + NotSupportedObjectInConstructorArgs_ThrowsArgumentException(value); + } + + [Theory] [MemberData(nameof(NotSupportedObject_Constructor_TestData))] [MemberData(nameof(NotSupportedObject_Others_TestData))] public static void NotSupportedObjectInConstructorArgs_ThrowsArgumentException(object value) @@ -613,10 +625,14 @@ namespace System.Reflection.Emit.Tests Assert.Throws<ArgumentException>(null, () => new CustomAttributeBuilder(con, constructorArgs, new PropertyInfo[0], new object[0], new FieldInfo[0], new object[0])); } - public static IEnumerable<object[]> InvalidAttributeTypes_TestData() + public static IEnumerable<object[]> IntPtrAttributeTypes_TestData() { yield return new object[] { typeof(IntPtr), (IntPtr)1 }; yield return new object[] { typeof(UIntPtr), (UIntPtr)1 }; + } + + public static IEnumerable<object[]> InvalidAttributeTypes_TestData() + { yield return new object[] { typeof(Guid), new Guid() }; yield return new object[] { typeof(int[,]), new int[5, 5] }; yield return new object[] { CreateEnum(typeof(char), 'a'), 'a' }; @@ -628,6 +644,14 @@ namespace System.Reflection.Emit.Tests } [Theory] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Coreclr fixed an issue where IntPtr/UIntPtr in constructorParameters causes a corrupt created binary.")] + [MemberData(nameof(IntPtrAttributeTypes_TestData))] + public void ConstructorParametersContainsIntPtrOrUIntPtrArgument_ThrowsArgumentException(Type type, object value) + { + ConstructorParametersNotSupportedInAttributes_ThrowsArgumentException(type, value); + } + + [Theory] [MemberData(nameof(InvalidAttributeTypes_TestData))] public void ConstructorParametersNotSupportedInAttributes_ThrowsArgumentException(Type type, object value) { @@ -642,9 +666,9 @@ namespace System.Reflection.Emit.Tests } [Fact] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Used to throw a NullReferenceException, see issue #11702.")] public void NullValueForPrimitiveTypeInConstructorArgs_ThrowsArgumentNullException() { - // Used to throw a NullReferenceException, see issue #11702 ConstructorInfo con = typeof(TestAttribute).GetConstructor(new Type[] { typeof(int) }); object[] constructorArgs = new object[] { null }; @@ -661,6 +685,7 @@ namespace System.Reflection.Emit.Tests } [Theory] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Coreclr fixed an issue where IntPtr/UIntPtr in constructorArgs causes a corrupt created binary.")] [MemberData(nameof(NotSupportedPrimitives_TestData))] public static void NotSupportedPrimitiveInConstructorArgs_ThrowsArgumentException(object value) { @@ -806,6 +831,7 @@ namespace System.Reflection.Emit.Tests [Theory] [MemberData(nameof(NotSupportedPrimitives_TestData))] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Coreclr fixed an issue where IntPtr/UIntPtr in fieldValues causes a corrupt created binary.")] public static void NotSupportedPrimitiveInFieldValues_ThrowsArgumentException(object value) { // Used to assert in CustomAttributeBuilder.EmitType(), not writing any CustomAttributeEncoding. @@ -893,6 +919,7 @@ namespace System.Reflection.Emit.Tests [Theory] [MemberData(nameof(InvalidAttributeTypes_TestData))] + [MemberData(nameof(IntPtrAttributeTypes_TestData))] public void NamedProperties_TypeNotSupportedInAttributes_ThrowsArgumentException(Type type, object value) { TypeBuilder typeBuilder = Helpers.DynamicType(TypeAttributes.Public); @@ -966,6 +993,7 @@ namespace System.Reflection.Emit.Tests [Theory] [MemberData(nameof(NotSupportedPrimitives_TestData))] + [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Coreclr fixed an issue where IntPtr/UIntPtr in propertValues causes a corrupt created binary.")] public static void NotSupportedPrimitiveInPropertyValues_ThrowsArgumentException(object value) { ConstructorInfo con = typeof(TestAttribute).GetConstructor(new Type[0]); |