在使用ICSharpCode.Decompiler进行反编译时,为什么看不到我的XML文档?

时间:2015-09-02 23:21:44

标签: c# decompiling mono.cecil xml-documentation

我一直在寻找使用ICSharpCode.Decompiler反编译.dll并在此主题上找到正确方向的示例代码和指针:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/00e59445-9f85-4ec5-a04f-9796a72a00a2/library-to-decompile-assembly-to-c

我已经复制了代码,并在override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! MyCollectionViewCell // Configure the cell let book = self.books[indexPath.row] let coverImage = book.coverImage if coverImage == nil { book.fetchCoverImage({ (image, error) -> Void in collectionView.reloadItemsAtIndexPaths([indexPath]) }) } else { let imageView = cell.imageView imageView.image = book.coverImage } return cell } 中添加了变量ShowXmlDocumentation = true,但我仍然无法查看我的文档。

我的源代码如下所示:

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(); 从未包含任何预期的XML文档。

我完整了解.dll中的内容,例如

line

但是我期待接口方法拥有我定义的XML文档,la

namespace Experiments.Decompilation
{
    public interface ITest
    {
        long Method();
    }
}

但对我来说没有cookie。

我错过了什么吗?我是否需要更改任何其他配置?

如果有人对此有任何想法,我真的很感激。我一直在绞尽脑汁,自己找不到解决方案,所以在这里你就是这样,请帮忙!

1 个答案:

答案 0 :(得分:1)

因为该属性实际上 buf = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE) int_pointer = ctypes.c_int.from_buffer(buf) 库中没有任何内容。它只是支持想要使用反编译器的项目(如ILSpy)。

例如,如果反编译器设置了选项,则ILSpy将check to see;如果是这样,它将在磁盘上查找相应的XML文件并解析XMLDoc字符串,并将它们嵌入到最终输出中。

另外,请注意实际的.NET程序集中没有 XMLDoc。 Visual Studio会生成一个单独的文件,如果你没有这个,那么即使你提出要求,ILSpy也无法包含XMLDoc。