Click here to Skip to main content
15,885,061 members
Articles / Programming Languages / XML

Attributes Inspector

Rate me:
Please Sign up or sign in to vote.
4.55/5 (12 votes)
28 Jan 20032 min read 74.8K   731   25   4
Simple program to inspect custom attributes in assemblies

Sample Image - asseminspect.jpg

Introduction

I develop custom server controls in ASP.NET and C#, and one of my challenges is the integration of the controls in VS.NET designer surface. One of the problems is that I haven't found any simple application to see the custom attributes attached to types (example: DesignerAttribute). I've searched documentation and I've written this simple application to do the job.

Application Description

The application is very simple, you can do the following tasks with it:

  • load an assembly: This shows at the bottom panel the custom attributes of the assembly, which can be recalled by double clicking at assembly name, and it shows public exported types contained in the assembly in the second panel.
  • To show custom attributes of a type, click on the type: It loads its properties , methods (not the inherited ones for brevity) and fields in the third panel and type custom attributes in the bottom panel.
  • To show custom attributes of a property , method or field, click on it.

The last version shows public and non public properties, and optionally by clicking the checkbox, shows the values of the fields inside attributes.

Details

This application shows a few interesting things, obviously all of these interesting things are explained in other CodeProject articles and various documents, but it is another example:

  • Loading assemblies at runtime and discovering its types, methods and properties using reflection
  • Obtaining custom attributes and its values at runtime
  • Using the richtextbox with simplicity which has being a discovery for me

To Do

There are few improvements which I can figure out:

  • Make the attribute description to show the exact type where it is declared, now it flattens the type hierarchy causing the same attribute to be shown more that one time and possibly with different values.
  • Use a tree control to show the types hierarchy

History

  • 02/29/2003 - Initial release
  • 02/30/2003 - Added the possibility to show non public properties of attributes, and optionally (by clicking the checkbox) the possibility to show field values (public and non public) of attributes which are of different colour
  • 02/30/2003 (II)- Added the possibility to show attributes for fields in types

Conclusion

I've achieved my objective to find what Designers are attached to control types of System.Web. I'll follow my investigations, and I've another tool in my toolbox.

By the way, the documentation and public articles on modifying and personalizing the design time of controls are very poor or I haven't found an article that gives in-depth information. Please let me know if you have found one.

Thanks for this great site!

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.


Written By
Hzi
Web Developer Ajuntament del Vendrell
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generaluseful Pin
Stephane Rodriguez.29-Jan-03 2:45
Stephane Rodriguez.29-Jan-03 2:45 
GeneralRe: useful Pin
Hzi29-Jan-03 21:15
Hzi29-Jan-03 21:15 
I've uploaded a new version that arranges your first suggestion, now you can see field values of attributes.

Thanks.

PS: I'll update my bio soon.Smile | :)
GeneralRe: useful Pin
Stephane Rodriguez.29-Jan-03 21:39
Stephane Rodriguez.29-Jan-03 21:39 
GeneralRe: useful Pin
Hzi29-Jan-03 23:39
Hzi29-Jan-03 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.