为什么在使用 ICSharpCode.Decompiler 反编译时看不到我的 XML 文档?
Why can't I see my XML documentation when decompiling using ICSharpCode.Decompiler?
我一直在研究使用 ICSharpCode.Decompiler 反编译 .dll,并在此线程上找到了一些示例代码和正确方向的手指:
我已经复制了代码并在 DecompilerSettings
中添加了设置变量 ShowXmlDocumentation = true
,但是我仍然看不到我的文档。
我的源代码如下所示:
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();
}
}
但我没有饼干。
我错过了什么吗?我需要更改任何其他配置吗?
如果有人对此有任何想法,我将不胜感激。绞尽脑汁自己也没找到解决办法,就到这里了,求助!
因为 属性 实际上 不做 ICSharpCode.Decompiler
库中的任何事情。它只是为了支持想要使用反编译器的项目(如 ILSpy)。
例如,ILSpy 将 check to see 如果反编译器设置了选项;如果是这样,它将在磁盘上查找适当的 XML 文件并解析 XMLDoc 字符串,并将它们嵌入到最终输出中。
另外,请注意实际的 .NET 程序集没有 XMLDoc。 Visual Studio 会生成一个包含该内容的单独文件,如果您没有该文件,即使您提出要求,ILSpy 也无法包含 XMLDoc。
我一直在研究使用 ICSharpCode.Decompiler 反编译 .dll,并在此线程上找到了一些示例代码和正确方向的手指:
我已经复制了代码并在 DecompilerSettings
中添加了设置变量 ShowXmlDocumentation = true
,但是我仍然看不到我的文档。
我的源代码如下所示:
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();
}
}
但我没有饼干。
我错过了什么吗?我需要更改任何其他配置吗?
如果有人对此有任何想法,我将不胜感激。绞尽脑汁自己也没找到解决办法,就到这里了,求助!
因为 属性 实际上 不做 ICSharpCode.Decompiler
库中的任何事情。它只是为了支持想要使用反编译器的项目(如 ILSpy)。
ILSpy 将 check to see 如果反编译器设置了选项;如果是这样,它将在磁盘上查找适当的 XML 文件并解析 XMLDoc 字符串,并将它们嵌入到最终输出中。
另外,请注意实际的 .NET 程序集没有 XMLDoc。 Visual Studio 会生成一个包含该内容的单独文件,如果您没有该文件,即使您提出要求,ILSpy 也无法包含 XMLDoc。