[Mono-bugs] [Bug 54518][Blo] Changed - PropertyInfo:GetCustomAttributes does not work for base class properties

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 11 Mar 2004 17:54:20 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ndrochak@gol.com.

http://bugzilla.ximian.com/show_bug.cgi?id=54518

--- shadow/54518	2004-03-11 10:19:45.000000000 -0500
+++ shadow/54518.tmp.10415	2004-03-11 17:54:20.000000000 -0500
@@ -79,6 +79,71 @@
 Lets remember to get nunit tests for all the cases of this bug. I 
 will write some tonight if someone doesnt preempt me.
 
 Am voting this series of bugs the most annoying bug of the month.
 
 Lluis, does the webservices stack still get messed up because of this?
+
+------- Additional Comments From ndrochak@gol.com  2004-03-11 17:54 -------
+The corlib nunit tests (AttributeTest) has a test case.  Here's the 
+snippet:
+
+	/* Test for bug 54518 */
+	[AttributeUsage(AttributeTargets.Field | 
+AttributeTargets.Property)]
+	public class PropTestAttribute : Attribute
+	{
+		public PropTestAttribute() {}
+	}
+
+	public class TestBase
+	{
+		public TestBase() {}
+			
+		[PropTest]
+		public int PropBase1 
+		{
+			get { return 0; }
+			set { }
+		}
+		
+		[PropTest]
+		public string PropBase2
+		{
+			get { return ""; }
+			set { }
+		}
+	}
+
+	public class TestSub : TestBase
+	{
+		public TestSub() {}
+			
+		[PropTest]
+		public int PropSub1 
+		{
+			get { return 0; }
+			set { }
+		}
+		
+		[PropTest]
+		public string PropSub2
+		{
+			get { return ""; }
+			set { }
+		}
+	}
+
+	[Test]
+	public void BaseAttributes ()
+	{
+		object [] attrs;
+		PropertyInfo [] props = typeof 
+(TestSub).GetProperties (BindingFlags.Public | BindingFlags.Instance);
+		
+		foreach (PropertyInfo prop in props) {
+			attrs = prop.GetCustomAttributes (typeof
+(PropTestAttribute), true);
+			AssertEquals (prop.Name, true, attrs.Length > 
+0);
+		}
+	}