我一直在研究使用.dlls对ICSharpCode.Decompiler进行反编译,并在这个线程上找到了一些正确方向的示例代码和手指:
我已经复制了代码并在DecompilerSettings中添加了设置变量DecompilerSettings,但是我仍然无法看到我的文档。
我的源代码如下所示:
var settings = new DecompilerSettings
{
FullyQualifyAmbiguousTypeNames = true,
ShowXmlDocumentation = true
};
const string assemblyName = "Experiments.Decompilation.dll";
var assembly1 = AssemblyDefinition.ReadAssembly(assemblyName);
var decompilerContext = new DecompilerContext(assembly1.MainModule) {Settings = settings};
var decompiler = new AstBuilder(decompilerContext);
decompiler.AddAssembly(assembly1);
var output = new StringWriter();
decompiler.GenerateCode(new PlainTextOutput(output));
var byteArray = Encoding.ASCII.GetBytes(output.ToString());
TextReader codeReader = new StreamReader(new MemoryStream(byteArray));
var line = codeReader.ReadToEnd();然而,变量line中从未包含任何预期的XML文档。
例如,我得到了.dll中的全部跟踪信息
namespace Experiments.Decompilation
{
public interface ITest
{
long Method();
}
}但是我希望接口方法有我定义的XML文档,即la。
namespace Experiments.Decompilation
{
///<summary>
///This is some test documentation
///</summary>
public interface ITest
{
long Method();
}
}但我不吃饼干。
我有遗漏什么吗?我需要更改其他配置吗?
如果有人对此有任何想法,我会非常感激的。我一直在绞尽脑汁,我自己还没有找到解决办法,所以请你帮帮忙!
发布于 2015-09-03 00:17:30
因为该属性实际上不会在ICSharpCode.Decompiler库中执行任何操作。它只是为了支持那些想要使用反编译器的项目(比如ILSpy)。
例如,如果反编译程序有选项集,ILSpy将在磁盘上查找适当的XML文件并解析XMLDoc字符串,并将它们嵌入最终的输出中。
另外,请注意,实际的.NET程序集中没有XMLDoc。Visual使用这些内容生成一个单独的文件,如果没有,ILSpy将无法包含XMLDoc,即使您这样问。
https://stackoverflow.com/questions/32364694
复制相似问题