views:

673

answers:

5

In this question I see that microsoft ships the XML documentation files for the BCL. I wonder if anyone knows if there an API within .net that can be used to look this up at runtime. I know we can parse the files manually using the XML api.

The use case is that we allow custom (read 3rd party) types/assemblies to be used in our system, and when selecting these in the UI, we'd like to extract the documentation as specified by the custom type/assembly creator or if not available provide other defaults.

+2  A: 

Microsoft's Sandcastle is a tool for extracting documentation from assemblies with or without the help of the XML comment files. It has been released as open source. You can try taking a look at the code of that tool.

Kirtan
Hmmm.. my experience of Sandcastle was that it used a XSL processing and reflection. I'll check it out again.
Preet Sangha
It seems that it reflects namespace and type hierarchy not comments. So question is still open
Preet Sangha
A: 

i would suggest you to take a look at nDoc

Vikram
Thank you I have done. It doesn't do what I'm after.
Preet Sangha
what did you use or how did you do it ?
Vikram
Sorry I'm confused I don't understand your comment. Could you elaborate for me please.
Preet Sangha
What I mean is that ndoc is out of date. The code comments need to take into account things like generics.
Preet Sangha
+2  A: 

Let's think about this.

The XML comments are never part of the assembly unit. So the 3rd party assembly you are talking about will not have any information for you to extract comments from.

Now, if those assemblies can generate XML files that contain this documentation, probably using SandCastle or nDoc, then you can read those XML files as you are wanting to do.

Next the question is - assuming you have these XML doc files, how to parse them and read them

  • I would suggest to use Linq to XML for quick and easy way to load this documentation. This is better in so many ways than the XSLT processing that SandCastle does. Using Linq to XML to do this shouldn't take that long, as long as you understand the XML schema/hierarchy of the XML doc file

Let me know how that goes OR if you have any questions

Vin
Thank you for your answer. We are already parsing the XML files currently (using Linq2Xml as it happens). What I was trying to determine was if there is a specific reusable set of functionality with .net (or its ugly child VS.net) that would perform the processing for us in a superior manner to our processing of the comment files.
Preet Sangha
+1  A: 

You might want to investigate the following libraries

Conrad
thank you. will investigate.
Preet Sangha
Whoops the other answer got auto selected. Sorry
Preet Sangha
+2  A: 

I maintain the Jolt.NET project on CodePlex and have implemented a feature that performs this very task. Please refer to the Jolt library for more information.

In essence, the library allows you to programatically locate and query an XML doc comments file for an assembly using the metadata types in System.Reflection (i.e. MethodInfo, PropertyInfo, etc...).

Steve Guidi
Will do. Many thanks
Preet Sangha