我尝试使用 MonoDevelop.AssemblyBrowser (使用OSX 10.10上的MonoDevelop 5.9.6)来反编译并查看我的一些常用类型是如何实现的。但是我没有设法看到它们中的任何一个,因为它们中的很多都是属性[MethodImpl (MethodImplOptions.InternalCall)]
(据我所知 - 这意味着实现在CLR内部,如果我错了就纠正我),或者我只是看不到任何方法或属性的主体,如本例所示(它是System.Mathf.Max(int, int):int
):
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
public static int Max (int val1, int val2);
/* body decompilation failed:
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 System.Math::Max(System.Int32,System.Int32)
---> System.OverflowException: Number overflow.
at (wrapper alloc) object:AllocVector (intptr,intptr)
at ICSharpCode.Decompiler.ILAst.ILAstBuilder+StackSlot.ModifyStack (StackSlot[] stack, Int32 popCount, Int32 pushCount, ICSharpCode.Decompiler.ILAst.ByteCode pushDefinition) [0x00000] in <filename unknown>:0
at ICSharpCode.Decompiler.ILAst.ILAstBuilder.StackAnalysis (Mono.Cecil.MethodDefinition methodDef) [0x00000] in <filename unknown>:0
at ICSharpCode.Decompiler.ILAst.ILAstBuilder.Build (Mono.Cecil.MethodDefinition methodDef, Boolean optimize, ICSharpCode.Decompiler.DecompilerContext context) [0x00000] in <filename unknown>:0
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody (IEnumerable`1 parameters) [0x00000] in <filename unknown>:0
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody (Mono.Cecil.MethodDefinition methodDef, ICSharpCode.Decompiler.DecompilerContext context, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody (Mono.Cecil.MethodDefinition methodDef, ICSharpCode.Decompiler.DecompilerContext context, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0
at ICSharpCode.Decompiler.Ast.AstBuilder.CreateMethodBody (Mono.Cecil.MethodDefinition method, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0
at ICSharpCode.Decompiler.Ast.AstBuilder.CreateMethod (Mono.Cecil.MethodDefinition methodDef) [0x00000] in <filename unknown>:0
at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethod (Mono.Cecil.MethodDefinition method) [0x00000] in <filename unknown>:0
at MonoDevelop.AssemblyBrowser.DomMethodNodeBuilder+<Decompile>c__AnonStorey0.<>m__0 (ICSharpCode.Decompiler.Ast.AstBuilder b) [0x00000] in <filename unknown>:0
at MonoDevelop.AssemblyBrowser.DomMethodNodeBuilder.Decompile (Mono.TextEditor.TextEditorData data, Mono.Cecil.ModuleDefinition module, Mono.Cecil.TypeDefinition currentType, System.Action`1 setData, ICSharpCode.Decompiler.DecompilerSettings settings) [0x00000] in <filename unknown>:0 */
或有时不会抛出任何异常:
所以有人知道如何使用这些工具查看实施代码吗?我做错了什么?
感谢。