[Mono-devel-list] Finding Values for all Attributes for classes.

Jonathan Pryor jonpryor at vt.edu
Mon Feb 23 06:43:55 EST 2004


On Mon, 2004-02-23 at 05:03, S Umadevi wrote:
> Hi,
>    I am trying to complete the implementation of classes in
> system.data. In most of the classes some  attributes are not implemented
> for the class /properties/methods. Since there is no documentation of
> the values for the  attributes with the .NET,

Take a look at Type Reflector (CVS module: type-reflector).

This command will display all public members (events, properties,
fields, methods, etc.), in C#-like syntax, including all Attributes
specified on the classes/members, sending output to the console:

	type-reflector --displayer=console \
		--formatter=csharp \
		-S -a AssemblyYouCareAbout

The code that actually displays the Attributes of a particular member is
in formatters/LanguageNodeFormatter.cs:AddCustomAttribute (StringBuilder
sb, object attribute, string attributeType).  It uses reflection on the
Attribute object to get all fields and properties, then prints out the
values of those fields and properties.

>  I need to run the following code on .NET and get the values to be
> used.
> The problem with the following code is that
> 1. I need to find all the attributes that need to be implemented by the
> class.

You're doing that already, sort of; that's what
ICustomAttributeProvider.GetCustomAttributes(bool) does.  You're always
checking against ObsoleteAttribute, though; if you wanted to know *all*
attributes,  you should print them *all* out. :-)

> 2. I need to know the properties of the attributes so that I can call
> it to print the values.

You can use System.Reflection to get this.  See Type Reflector for an
example, as specified above.

> 3. Do it for each of the classes..

Someone else already mentioned Assembly.GetTypes()...


 - Jon

More information about the Mono-devel-list mailing list