Browse Source

2003-06-23 Andreas Nahr <[email protected]>

	* DesignerAttribute.cs: Fixed AttributeUsage, implementation errors,
	better Hashcode generation
	* EditorAttribute.cs: Fixed AttributeUsage, implementation errors,
	better Hashcode generation
	* LicenseContext.cs: Added and implemented missing property
	* ListBindableAttribute.cs: Simplified implementation, removed
	unneccessary data.
	* ReadOnlyAttribute.cs: Better Hashcode generation
	* RunInstallerAttribute.cs: Better Hashcode generation, more robust
	Equals check.

	* LicenseProviderAttribute.cs: Fixed AttributeUsage, indentation
	* ProvidePropertyAttribute.cs: Fixed AttributeUsage
	* ToolboxItemFilterAttribute.cs: Fixed AttributeUsage

	* MarshalByValueComponent.cs:
	* IContainer.cs:
	* IComponent.cs: Added missing attribute(s)

svn path=/trunk/mcs/; revision=15614
Gonzalo Paniagua Javier 22 years ago
parent
commit
d7c7c9ca73

+ 22 - 1
mcs/class/System/System.ComponentModel/ChangeLog

@@ -1,4 +1,25 @@
-2003-06-23  Gonzalo Paniagua Javier <[email protected]>
+2003-06-23  Andreas Nahr <[email protected]>
+
+	* DesignerAttribute.cs: Fixed AttributeUsage, implementation errors,
+	better Hashcode generation
+	* EditorAttribute.cs: Fixed AttributeUsage, implementation errors,
+	better Hashcode generation
+	* LicenseContext.cs: Added and implemented missing property
+	* ListBindableAttribute.cs: Simplified implementation, removed
+	unneccessary data.
+	* ReadOnlyAttribute.cs: Better Hashcode generation
+	* RunInstallerAttribute.cs: Better Hashcode generation, more robust
+	Equals check.
+
+	* LicenseProviderAttribute.cs: Fixed AttributeUsage, indentation
+	* ProvidePropertyAttribute.cs: Fixed AttributeUsage
+	* ToolboxItemFilterAttribute.cs: Fixed AttributeUsage
+
+	* MarshalByValueComponent.cs:
+	* IContainer.cs:
+	* IComponent.cs: Added missing attribute(s)
+
+2003-06-24  Gonzalo Paniagua Javier <[email protected]>
 
 	* AmbientValueAttribute.cs:
 	* ArrayConverter.cs:

+ 54 - 57
mcs/class/System/System.ComponentModel/DesignerAttribute.cs

@@ -3,11 +3,14 @@
 //
 // Author:
 //   Alejandro Sánchez Acosta ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
 //
 
-namespace System.ComponentModel {
+namespace System.ComponentModel 
+{
 
 	/// <summary>
 	///   Designer Attribute for classes. 
@@ -16,73 +19,67 @@ namespace System.ComponentModel {
 	/// <remarks>
 	/// </remarks>
 	
-	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
-		public sealed class DesignerAttribute : Attribute
-		{
-			string name;
-			string basetypename;
-			Type type;
-			Type basetype;
+	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
+	public sealed class DesignerAttribute : Attribute
+	{
+		private string name;
+		private string basetypename;
 			
-			public DesignerAttribute (string designerTypeName)
-			{
-				name  = designerTypeName;
-			}
+		public DesignerAttribute (string designerTypeName)
+		{
+			name = designerTypeName;
+		}
 
-			public DesignerAttribute (Type designerType)
-			{
-				type = designerType;
-			}
+		public DesignerAttribute (Type designerType)
+			: this (designerType.AssemblyQualifiedName)
+		{
+		}
 
-			public DesignerAttribute (string designerTypeName, string designerBaseTypeName)
-			{
-				name = designerTypeName;
-				basetypename = designerBaseTypeName;
-			}
+		public DesignerAttribute (string designerTypeName, Type designerBaseType)
+			: this (designerTypeName, designerBaseType.AssemblyQualifiedName)
+		{
+		}
 
-			public DesignerAttribute (string designerTypeName, Type designerBaseType)
-			{
-				name = designerTypeName;
-				basetype = designerBaseType;
-			}
+		public DesignerAttribute (Type designerType, Type designerBaseType)
+			: this (designerType.AssemblyQualifiedName, designerBaseType.AssemblyQualifiedName)
+		{
+		}
 
-			public DesignerAttribute (Type designerType, Type designerBaseType)
-			{
-				type = designerType;
-				basetype = designerBaseType;
-			}
+		public DesignerAttribute (string designerTypeName, string designerBaseTypeName)
+		{
+			name = designerTypeName;
+			basetypename = designerBaseTypeName;
+        	}
 
-			public string DesignerBaseTypeName {
-				get {
-					return basetypename;
-				}
-			}
+		public string DesignerBaseTypeName {
+            		get {
+				return basetypename;
+ 			}
+		}
 
-			public string DesignerTypeName  {
-				get {
-					return name;
-				}
+		public string DesignerTypeName {
+			get {
+				return name;
 			}
+		}
 
-			public override object TypeId {
-				get {
-					return this.GetType ();
-				}
+		public override object TypeId {
+			get {
+				return this.GetType ();
 			}
+		}
 			
-			public override bool Equals (object obj)
-			{
-	                        if (!(obj is DesignerAttribute))
-	                                return false;
-	                        return (((DesignerAttribute) obj).name == name) && 
-					(((DesignerAttribute) obj).basetype == basetype) &&
-					(((DesignerAttribute) obj).type == type) &&
-					(((DesignerAttribute) obj).basetypename == basetypename);
-			}				
+		public override bool Equals (object obj)
+		{
+			if (!(obj is DesignerAttribute))
+				return false;
+			return ((DesignerAttribute) obj).DesignerBaseTypeName.Equals (basetypename) && 
+				((DesignerAttribute) obj).DesignerTypeName.Equals (name);
+		}				
 
-			public override int GetHashCode ()
-			{
-				return base.GetHashCode ();
-			}
+		public override int GetHashCode ()
+		{
+			return string.Concat(name, basetypename).GetHashCode ();
 		}
+	}
 }

+ 10 - 19
mcs/class/System/System.ComponentModel/EditorAttribute.cs

@@ -3,8 +3,10 @@
 //
 // Author:
 //   Alejandro Sánchez Acosta ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
 //
 
 namespace System.ComponentModel {
@@ -12,18 +14,15 @@ namespace System.ComponentModel {
 	/// <summary>
 	///   Editor Attribute for classes. 
 	/// </summary>
-
-	[AttributeUsage (AttributeTargets.All)]
+	[AttributeUsage (AttributeTargets.All, AllowMultiple = true, Inherited = true)]
 	public sealed class EditorAttribute : Attribute {
 		
-		string name;	
+		string name;
 		string basename;
-		Type baseType;
-		Type nametype;
 
 		public EditorAttribute ()
 		{
-			this.name = "";
+			this.name = string.Empty;
 		}
 
 		public EditorAttribute (string typeName, string baseTypeName)
@@ -33,15 +32,13 @@ namespace System.ComponentModel {
 		}
 
 		public EditorAttribute (string typeName, Type baseType)
+			: this (typeName, baseType.AssemblyQualifiedName)
 		{
-			name = typeName;
-			this.baseType = baseType;	
 		}
 
 		public EditorAttribute (Type type, Type baseType)
+			: this (type.AssemblyQualifiedName, baseType.AssemblyQualifiedName)
 		{
-			nametype = type;
-			this.baseType = baseType;
 		}
 
 		public string EditorBaseTypeName {
@@ -67,19 +64,13 @@ namespace System.ComponentModel {
 			if (!(obj is EditorAttribute))
 				return false;
 
-			return (((EditorAttribute) obj).name == name) &&
-				(((EditorAttribute) obj).basename == basename) &&
-				(((EditorAttribute) obj).baseType == baseType) &&
-				(((EditorAttribute) obj).nametype == nametype);
-
+			return ((EditorAttribute) obj).EditorBaseTypeName.Equals (basename) &&
+				((EditorAttribute) obj).EditorTypeName.Equals (name);
 		}
 		
 		public override int GetHashCode ()
 		{
-                        if (name == null)
-	                        return 0;
-
-                        return name.GetHashCode ();
+			return string.Concat(name, basename).GetHashCode ();
 		}
 	}
 }

+ 7 - 2
mcs/class/System/System.ComponentModel/IComponent.cs

@@ -2,8 +2,8 @@
 // System.ComponentModel.IComponent.cs
 //
 // Authors:
-//  Miguel de Icaza ([email protected])
-//  Andreas Nahr ([email protected])
+//   Miguel de Icaza ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) Ximian, Inc.  http://www.ximian.com
 // (C) 2003 Andreas Nahr
@@ -13,6 +13,11 @@ using System;
 
 namespace System.ComponentModel
 {
+	[ComVisible (true),
+		TypeConverter (typeof (System.ComponentModel.ComponentConverter)),
+		Designer ("System.Windows.Forms.Design.ComponentDocumentDesigner, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (System.ComponentModel.Design.IRootDesigner)),
+		Designer ("System.ComponentModel.Design.ComponentDesigner, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (System.ComponentModel.Design.IDesigner)),
+		RootDesignerSerializer ("System.ComponentModel.Design.Serialization.RootCodeDomSerializer, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", true)]
 	public interface IComponent : IDisposable
 	{
 		ISite Site { get; set; }

+ 3 - 1
mcs/class/System/System.ComponentModel/IContainer.cs

@@ -9,7 +9,9 @@
 
 namespace System.ComponentModel {
 
-	public interface IContainer : IDisposable {
+	[ComVisible (true)]
+	public interface IContainer : IDisposable 
+	{
 
 		ComponentCollection Components {
 			get;

+ 8 - 5
mcs/class/System/System.ComponentModel/LicenseContext.cs

@@ -1,10 +1,12 @@
 //
-// System.ComponentModel.LicenseContext
+// System.ComponentModel.LicenseContext.cs
 //
 // Authors:
-//      Martin Willemoes Hansen ([email protected])
+//   Martin Willemoes Hansen ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2003 Martin Willemoes Hansen
+// (C) 2003 Andreas Nahr
 //
 
 using System.Reflection;
@@ -37,9 +39,10 @@ namespace System.ComponentModel
 			throw new NotImplementedException();
 		}
 
-		[MonoTODO]
-		~LicenseContext()
-		{
+		public virtual LicenseUsageMode UsageMode {
+			get {
+				return LicenseUsageMode.Runtime;
+			}
 		}
 	}
 }

+ 8 - 8
mcs/class/System/System.ComponentModel/LicenseProviderAttribute.cs

@@ -1,9 +1,9 @@
 //
-// System.ComponentModel.LicenseProviderAttribute
+// System.ComponentModel.LicenseProviderAttribute.cs
 //
 // Authors:
-//  Martin Willemoes Hansen ([email protected])
-//  Andreas Nahr ([email protected])
+//   Martin Willemoes Hansen ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2003 Martin Willemoes Hansen
 // (C) 2003 Andreas Nahr
@@ -11,7 +11,7 @@
 
 namespace System.ComponentModel
 {
-	[AttributeUsage(AttributeTargets.Class)]
+	[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
 	public sealed class LicenseProviderAttribute : Attribute
 	{
 		private Type Provider;
@@ -38,9 +38,9 @@ namespace System.ComponentModel
 		}
 
 		public override object TypeId {
-		get {
-			// Seems to be MS implementation
-			return (base.ToString() + Provider.ToString());
+			get {
+				// Seems to be MS implementation
+				return (base.ToString() + Provider.ToString());
 			}
 		}
 
@@ -50,7 +50,7 @@ namespace System.ComponentModel
 				return false;
 			if (obj == this)
 				return true;
-			return ((LicenseProviderAttribute) obj).LicenseProvider == Provider;
+			return ((LicenseProviderAttribute) obj).LicenseProvider.Equals (Provider);
 		}
 
 		public override int GetHashCode()

+ 16 - 22
mcs/class/System/System.ComponentModel/ListBindableAttribute.cs

@@ -1,10 +1,12 @@
 //
-// System.ComponentModel.ListBindableAttribute
+// System.ComponentModel.ListBindableAttribute.cs
 //
 // Authors:
-//	Gonzalo Paniagua Javier ([email protected])
+//   Gonzalo Paniagua Javier ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2002 Ximian, Inc (http://www.ximian.com)
+// (C) 2003 Andreas Nahr
 //
 
 using System;
@@ -14,29 +16,23 @@ namespace System.ComponentModel
 	[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
 	public sealed class ListBindableAttribute : Attribute
 	{
-		public static readonly ListBindableAttribute Default = new ListBindableAttribute (true, true);
-		public static readonly ListBindableAttribute No = new ListBindableAttribute (false, true);
-		public static readonly ListBindableAttribute Yes = new ListBindableAttribute (true, true);
+		public static readonly ListBindableAttribute Default = new ListBindableAttribute (true);
+		public static readonly ListBindableAttribute No = new ListBindableAttribute (false);
+		public static readonly ListBindableAttribute Yes = new ListBindableAttribute (true);
 
-		bool deflt;
 		bool bindable;
-
-		private ListBindableAttribute (bool listBindable, bool deflt)
-		{
-			this.deflt = deflt;
-			bindable = listBindable;
-		}
 		
 		public ListBindableAttribute (bool listBindable)
 		{
-			deflt = false;
-			bindable = true;
+			bindable = listBindable;
 		}
 
 		public ListBindableAttribute (BindableSupport flags)
 		{
-			bindable = (flags == BindableSupport.Yes);
-			deflt = (flags == BindableSupport.Default);
+            		if (flags == BindableSupport.No)
+                		bindable = false;
+            		else
+                		bindable = true;
 		}
 
 		public override bool Equals (object obj)
@@ -44,22 +40,20 @@ namespace System.ComponentModel
 			if (!(obj is ListBindableAttribute))
 				return false;
 
-			return (((ListBindableAttribute) obj).bindable == bindable &&
-				((ListBindableAttribute) obj).deflt == deflt);
+			return ((ListBindableAttribute) obj).ListBindable.Equals (bindable);
 		}
 
 		public override int GetHashCode ()
 		{
-			return base.GetHashCode ();
+			return bindable.GetHashCode ();
 		}
 
 		public override bool IsDefaultAttribute ()
 		{
-			return deflt;
+			return Equals (Default);
 		}
 
-		public bool ListBindable
-		{
+		public bool ListBindable {
 			get {
 				return bindable;
 			}

+ 3 - 0
mcs/class/System/System.ComponentModel/MarshalByValueComponent.cs

@@ -18,6 +18,9 @@ namespace System.ComponentModel
 	/// <summary>
 	/// Implements IComponent and provides the base implementation for remotable components that are marshaled by value (a copy of the serialized object is passed).
 	/// </summary>
+	[DesignerCategory ("Component"),
+		TypeConverter (typeof (ComponentConverter)), 
+    		Designer ("System.Windows.Forms.Design.ComponentDocumentDesigner, System.Design, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (IRootDesigner))]
 	public class MarshalByValueComponent : IComponent, IDisposable, IServiceProvider
 	{
 		private EventHandlerList eventList;

+ 2 - 2
mcs/class/System/System.ComponentModel/ProvidePropertyAttribute.cs

@@ -1,5 +1,5 @@
 //
-// System.ComponentModel.ProvidePropertyAttribute
+// System.ComponentModel.ProvidePropertyAttribute.cs
 //
 // Authors:
 //  Martin Willemoes Hansen ([email protected])
@@ -11,7 +11,7 @@
 
 namespace System.ComponentModel
 {
-	[AttributeUsage(AttributeTargets.Class)]
+	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
 	public sealed class ProvidePropertyAttribute : Attribute
 	{
 

+ 3 - 3
mcs/class/System/System.ComponentModel/ReadOnlyAttribute.cs

@@ -1,5 +1,5 @@
 //
-// ReadOnlyAttribute.cs
+// System.ComponentModel.ReadOnlyAttribute.cs
 //
 // Author:
 //   Chris J Breisch ([email protected])
@@ -35,7 +35,7 @@ namespace System.ComponentModel {
 
 		public override int GetHashCode ()
 		{
-			return base.GetHashCode ();
+			return read_only.GetHashCode ();
 		}
 
 		public override bool Equals (object o)
@@ -43,7 +43,7 @@ namespace System.ComponentModel {
 			if (!(o is ReadOnlyAttribute))
 				return false;
 
-			return (((ReadOnlyAttribute) o).read_only == read_only);
+			return (((ReadOnlyAttribute) o).IsReadOnly.Equals (read_only));
 		}
 
 		public override bool IsDefaultAttribute ()

+ 7 - 5
mcs/class/System/System.ComponentModel/RunInstallerAttribute.cs

@@ -1,10 +1,12 @@
 //
-// System.ComponentModel.RunInstallerAttribute
+// System.ComponentModel.RunInstallerAttribute.cs
 //
 // Authors:
-//	Gonzalo Paniagua Javier ([email protected])
+//   Gonzalo Paniagua Javier ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2003 Ximian, Inc (http://www.ximian.com)
+// (C) 2003 Andreas Nahr
 //
 
 using System;
@@ -30,17 +32,17 @@ namespace System.ComponentModel
 			if (!(obj is RunInstallerAttribute))
 				return false;
 
-			return (((RunInstallerAttribute) obj).runInstaller == runInstaller);
+			return ((RunInstallerAttribute) obj).RunInstaller.Equals (runInstaller);
 		}
 
 		public override int GetHashCode ()
 		{
-			return base.GetHashCode ();
+			return runInstaller.GetHashCode ();
 		}
 
 		public override bool IsDefaultAttribute ()
 		{
-			return (runInstaller == false); // false is the Default
+			return Equals (Default);
 		}
 
 		public bool RunInstaller

+ 4 - 4
mcs/class/System/System.ComponentModel/ToolboxItemFilterAttribute.cs

@@ -1,9 +1,9 @@
 //
-// System.ComponentModel.ToolboxItemFilterAttribute
+// System.ComponentModel.ToolboxItemFilterAttribute.cs
 //
 // Authors:
-//  Martin Willemoes Hansen ([email protected])
-//  Andreas Nahr ([email protected])
+//   Martin Willemoes Hansen ([email protected])
+//   Andreas Nahr ([email protected])
 //
 // (C) 2003 Martin Willemoes Hansen
 // (C) 2003 Andreas Nahr
@@ -11,7 +11,7 @@
 
 namespace System.ComponentModel
 {
-	[AttributeUsage(AttributeTargets.Class)]
+	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
 	[Serializable]
 	public sealed class ToolboxItemFilterAttribute : Attribute
 	{