我的c#脚本包含了一些带有commetns的字段,当我使用CodeDomProvider编译它时,一切都很好,但是当我看到代码时,没有包含注释。
这是我的代码:
CodeDomProvider codeDomProvider = CodeDomProvider.CreateProvider("C#");
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = false;
parameters.OutputAssembly = AppDomain.CurrentDomain.BaseDirectory + "myFile.dll";
CompilerResults results = codeDomProvider.CompileAssemblyFromSource(parameters, "Some C# code with documentation");发布于 2013-12-31 09:08:00
无论如何,您都不会收到非XML注释--它们从来都不是编译结果的一部分。但是,可以使用CompilerOptions属性生成XML文档文件,只需将命令行参数传递给编译器:
parameters.CompilerOptions = "/doc:myFile.xml";所以如果你有这样的代码:
/// <summary>This will be included in myFile.xml</summary>
public class Foo
{
// This will not, as it's not an XML comment.
}https://stackoverflow.com/questions/20854637
复制相似问题