[Mono-list] Adding missing Attributes to System.Web

Duncan Mak duncan@ximian.com
10 Jun 2002 18:11:22 -0400

Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hey guys,

We're missing a bunch of Attributes in the classes for the System.Web
namespace. I played around with the reflection API (always fun!) and
came up with a tool that'll show what Attributes are missing in each

If anyone's interested, you can use this tool to add the missing bits to
the classes. This is a great way to start contributing to the project.
Any help is really appreciated.

If you look into the ToString() method in the AttributeCollection class
in the file, you'll see that there's a 'filter' for finding out what
type of Attribute it is. All you need to do is add new filters, then
find out from the documentation what useful information can obtained
from each particular Attribute.

Gonzalo said that, when adding these Attributes, please start with
System.Web.UI.HtmlControls, then WebControls, then Validators.

If there is any other questions, please mail me.


Duncan Mak <duncan@ximian.com>

Content-Disposition: attachment; filename=attributes.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=attributes.cs; charset=ISO-8859-1

// Attributes.cs - Let's go look up some Attributes!
// Author: Duncan Mak (duncan@ximian.com)
// (C) Ximian, Inc.

using System;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using System.Text;
using System.Web.UI;

class X {
	static void Main ()
		Page p =3D new Page ();
		Type type =3D p.GetType ();
		Assembly web =3D Assembly.GetAssembly (type);
		Type[] types =3D web.GetTypes ();
		Hashtable ht =3D new Hashtable ();

		foreach (Type t in types)
			ht.Add (t.FullName, new AttributeCollection (t.GetCustomAttributes (true=
		foreach (object key in ht.Keys)
			Console.WriteLine (key + ":\n" + ht[key]);

class AttributeCollection {
	object [] attributes;
	public AttributeCollection (object [] att)
		attributes =3D att;
	public override string ToString ()
		StringBuilder s =3D new StringBuilder ();
		foreach (Attribute a in attributes) {
			s.Append ("\t[" + a + "]\n");
			if (a is ControlBuilderAttribute) {
				ControlBuilderAttribute c =3D a as ControlBuilderAttribute;
				s.Append ("\t\t" + c.BuilderType.FullName + "\n");
			if (a is DefaultEventAttribute) {
				DefaultEventAttribute c =3D a as DefaultEventAttribute;
				s.Append ("\t\t" + c.Name + "\n");
			if (a is DefaultPropertyAttribute) {
				DefaultPropertyAttribute c =3D a as DefaultPropertyAttribute;
				s.Append ("\t\t" + c.Name + "\n");

			if (a is DefaultMemberAttribute) {
				DefaultMemberAttribute c =3D a as DefaultMemberAttribute;
				s.Append ("\t\t" + c.MemberName + "\n");
			// Add more here
			// if (a is SOME_ATTRIBUTE) {
			// s.Append ("\t\t" + x.SOME_PROPERTY + "\n");
		}		=09
		return s.ToString ();