Regression test for multiple attributes on the same type (dotnet/corefx#37518)
authorJan Kotas <jkotas@microsoft.com>
Wed, 22 May 2019 04:26:13 +0000 (21:26 -0700)
committerGitHub <noreply@github.com>
Wed, 22 May 2019 04:26:13 +0000 (21:26 -0700)
Contributes to dotnet/corefx#37261

Commit migrated from https://github.com/dotnet/corefx/commit/85d82a0402e26fb02be4c006752904cb8e0f8b02

src/libraries/System.Runtime/tests/System/Attributes.cs

index 035429c..4fb34d9 100644 (file)
@@ -199,6 +199,13 @@ namespace System.Tests
             Assert.Throws<ArgumentNullException>(() => Attribute.GetCustomAttributes(typeof(TestClass2).GetMethod("TestMethod2"), null, false));
             Assert.Throws<ArgumentNullException>(() => Attribute.GetCustomAttributes(typeof(TestClass2).GetMethod("TestMethod2").GetParameters()[0], null, false));
         }
+
+        [Fact]
+        public static void MultipleAttributesTest()
+        {
+            Assert.Equal("System.Tests.MyCustomAttribute System.Tests.MyCustomAttribute", string.Join(" ", typeof(MultipleAttributes).GetCustomAttributes(inherit: false)));
+            Assert.Equal("System.Tests.MyCustomAttribute System.Tests.MyCustomAttribute", string.Join(" ", typeof(MultipleAttributes).GetCustomAttributes(inherit: true)));
+        }
     }
     public static class GetCustomAttribute
     {
@@ -786,4 +793,10 @@ namespace System.Tests
             set { }
         }
     }
+
+    [MyCustomAttribute("Test")]
+    [MyCustomAttribute("Test")]
+    class MultipleAttributes
+    {
+    }
 }