Last post May 06, 2013 12:03 PM by Horizon_Net
May 06, 2013 10:40 AM|aithex2|LINK
Is there any tool that we can use to fetch the documentation from a C# ".cs" file. For example we add
<summary> section before class and methods. and there are so many classes. and i want to make a word file that describes each file, its class summary and methods summary.
Tho i can copy from each file but if there is any tool to do this?
May 06, 2013 10:45 AM|Rion Williams|LINK
It looks like this blog post discusses a very simple library that was written to allow you to access the summary information of specific methods and properties using Reflection as seen below :
//This grabs the specific documentation for a class / property
XmlElement documentation = DocsByReflection.XMLFromMember(typeof(SomeExampleClass).GetProperty("ExampleProperty"));
//This stores the specific documentation summary (what you are looking for) within a variable, which
//could be sent as output to a file or however else you would like to handle it
string summary = documentation["summary"].InnerText.Trim();
It looks like the Jolt.NET project also handles this same exact functionality (although syntax may vary) and may be more recently maintained that the aforementioned blog post.
(I haven't used either of these personally - but they should at least point you in the right direction.)
May 06, 2013 10:48 AM|gerrylowry|LINK
@ aithex2 welcome to forums.asp.net
Sorry, you question is unclear.
a c# file is a TEXT file so it has NO summary section, per se.
Are you talking about the generic "Text file" with the .cs extension?
it would be easier to answer your question if you were to expand it and clarify it ... perhaps you could started by explaining your goal(s).
also, why to a Word file?
P.S.: if you're looking to document your code, check out applications like Sandcastle.
May 06, 2013 10:50 AM|Nasser Malik|LINK
Following will log all the summary section for method
StringBuilder str = new StringBuilder();
using (StreamReader sr = new StreamReader("MyCSFilePath.cs"))
while ((line = sr.ReadLine()) != null)
using (StreamWriter outfile = new StreamWriter("D:\\" + "Summary.txt"))
outfile.Write(str.ToString() + "\n");
May 06, 2013 12:03 PM|Horizon_Net|LINK
there are a few tools out there, which can generate the documentation from the source files (f.e. from the summary comments). One is
Sandcastle which isn't under development any more. Another one is
Doxygen. The choice which tool to use is up to you.