c# - How to make source code a part of XML documentation and not violate DRY? -


I want to add some parts of the source code to XML documents. I copy & amp; Some & lt; Code & gt; Paste the source code element to, like this:

  /// & lt; Summary & gt; /// Hello world, in a very basic way: /// & lt; Code & gt; /// System.console Weidline ("Hello World!"); /// System Console Wrightite ("Press any key to exit."); /// System.console Readkey (); /// & lt; / Code & gt; /// & lt; / Summary & gt; Static zero main () {System.Console.WriteLine ("Hello World!"); System.Console.WriteLine ("Press any key to exit."); System.Console.ReadKey (); }  

It will be painful to maintain it. Are there any other possibilities to add source code to XML document in C #?

I am processing XML documentation with Sandcastle and would like to create a technical support file (* .cm) from it. I would like to add parts or entire method bodies to that assist file.


Edit: Thanks for the comment from slide_url I have added a more realistic and less trivial example:

Suppose I have this There is no such method:

  Public Decimal Calculation (Bill Bill) {if (Bill Shoms & Lieutenant); 5000) 500 returns; Other (if bill (especially special offers) return the bills. ShortSome * 0.01; Second Bill Refund Shortset * 0.02;}}  

How to calculate fees in a technical help file It would be good to add this information.

The most obvious solution would be written in the comment like the following: "If the bill has less than 5000 total amount ...".

Another solution will be mimicking & paste the body of the method into the comments area and let it The C & lt; code & gt; element. The body of this method can be easily understood, even without much information about C # - so there is nothing wrong with the technical help file. / P>

Both solutions violate the dry theory! I would like to add pieces of a law body or a law body in the help file, without repetition.

Is it possible in C # (I think Ruby's The RDoc is capable of doing this, but I need some solution in C #)

Just there Throw out an idea ...

In a process that looks for the code block delimited in some way, then inject that code into the XML code.

  /// & LT; Summary & gt; /// Hello world, in a very basic way: /// & lt; Code & gt; /// code block 1 /// & lt; / Code & gt; /// & lt; / Summary & gt; Static Zero Main () {// Launch System of Code Block 1 Console WrightLine ("Hello World!"); System.Console.WriteLine ("Press any key to exit."); System.Console.ReadKey (); // Code Block 1 End}  

I know that this is not beautiful, but this is a start! ;)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -