Generating XML from documentation comments C# with Example



Generating XML from documentation comments C# with Example

To generate an XML documentation file from documentation comments in the code, use the /doc option with the 
csc.exe C# compiler. 
In Visual Studio 2013/2015, In Project -> Properties -> Build -> Output, check the XML documentation file 
checkbox: 
When you build the project, an XML file will be produced by the compiler with a name corresponding to the project 
name (e.g. XMLDocumentation.dll -> XMLDocumentation.xml). 
When you use the assembly in another project, make sure that the XML file is in the same directory as the DLL 
being referenced. 
 

This example: 
///  
/// Data class description 
///  
public class DataClass 
{ 
///  
/// Name property description 
///  
public string Name { get; set; } 
} 
///  
/// Foo function 
///  
public class Foo 
{ 
///  
/// This method returning some data 
///  
///  Id  parameter 
/// Time parameter 
/// Data will be returned 
public DataClass GetData(int id, DateTime time) 
{ 
return new DataClass(); 
} 
} 
Produces this xml on build: 
 
 
 
XMLDocumentation 
 
 
 
 
Data class description 
 
 
 
 
Name property description 
 
 
 
 
Foo function 
 
 
 
 
This method returning some data 
 
Id parameter 
Time parameter 
Data will be returned 
 

 
 
 

0 Comment's

Comment Form

Submit Comment