[Mono-bugs] [Bug 52655][Nor] New - Custom attributes should not be cached

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 7 Jan 2004 14:36:12 -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 lluis@ximian.com.

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

--- shadow/52655	2004-01-07 14:36:12.000000000 -0500
+++ shadow/52655.tmp.10774	2004-01-07 14:36:12.000000000 -0500
@@ -0,0 +1,45 @@
+Bug#: 52655
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lluis@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Custom attributes should not be cached
+
+Description of Problem:
+
+An application should not be able to modify custom attributes applied to
+language elements. For example, the following test should always print "hello".
+
+using System;
+using System.Xml.Serialization;
+
+[XmlType(TypeName="hello")]
+public class Test
+{
+	public static void Main ()
+	{
+		XmlTypeAttribute at = (XmlTypeAttribute)
+Attribute.GetCustomAttribute(typeof(Test), typeof(XmlTypeAttribute));
+		at.TypeName = "modified";
+		
+		at = (XmlTypeAttribute) Attribute.GetCustomAttribute(typeof(Test),
+typeof(XmlTypeAttribute));
+		Console.WriteLine (at.TypeName);
+	}
+}
+
+MS.NET creates an instance of the attribute each time it is accessed, so
+changes to it will be always local, never global. 
+
+The solution is to remove the attribute cache from MonoCustomAttrs.