icsharpcode / ILSpy

.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
21.45k stars 3.35k forks source link

Can't decompile method of class #360

Closed greenozon closed 7 years ago

greenozon commented 12 years ago

Issue (ILSpy version 2.1.0.1603) When clicking on one of methods of the class inside lefthand treeview:

System.NullReferenceException: Object reference not set to an instance of an object. at ICSharpCode.Decompiler.Disassembler.DisassemblerHelpers.WriteTo(TypeReference type, ITextOutput writer, ILNameSyntax syntax) at ICSharpCode.Decompiler.Disassembler.DisassemblerHelpers.WriteTo(TypeReference type, ITextOutput writer, ILNameSyntax syntax) at ICSharpCode.Decompiler.Disassembler.DisassemblerHelpers.WriteTo(MethodReference method, ITextOutput writer) at ICSharpCode.Decompiler.Disassembler.DisassemblerHelpers.WriteOperand(ITextOutput writer, Object operand) at ICSharpCode.Decompiler.Disassembler.DisassemblerHelpers.WriteTo(Instruction instruction, ITextOutput writer) at ICSharpCode.Decompiler.Disassembler.MethodBodyDisassembler.WriteStructureBody(ILStructure s, HashSet`1 branchTargets, Instruction& inst, MemberMapping currentMethodMapping, Int32 codeSize) at ICSharpCode.Decompiler.Disassembler.MethodBodyDisassembler.Disassemble(MethodBody body, MemberMapping methodMapping) at ICSharpCode.Decompiler.Disassembler.ReflectionDisassembler.DisassembleMethodInternal(MethodDefinition method) at ICSharpCode.ILSpy.ILLanguage.DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) at ICSharpCode.ILSpy.TextView.DecompilerTextView.DecompileNodes(DecompilationContext context, ITextOutput textOutput) at ICSharpCode.ILSpy.TextView.DecompilerTextView.<>cDisplayClass17.b16()

here is the IL code:

.method public hidebysig newslot virtual final instance bool Authenticate(string username, string password) cil managed { .maxstack 4 L_0000: ldarg.1 L_0001: brtrue.s L_0005 L_0003: ldc.i4.0 L_0004: ret L_0005: ldarg.2 L_0006: brtrue.s L_000a L_0008: ldc.i4.0 L_0009: ret L_000a: ldarg.0 L_000b: ldfld class [mscorlib]System.Collections.Hashtable XHTTPServer.BasicAuthenticator::ycxmNmyxHC L_0010: ldarg.1 L_0011: callvirt instance bool [mscorlib]System.Collections.Hashtable::ContainsKey(object) L_0016: brtrue.s L_001a L_0018: ldc.i4.0 L_0019: ret L_001a: ldarg.0 L_001b: ldfld class [mscorlib]System.Collections.Hashtable XHTTPServer.BasicAuthenticator::ycxmNmyxHC L_0020: ldarg.1 L_0021: callvirt instance object [mscorlib]System.Collections.Hashtable::get_Item(object) L_0026: isinst uint8[] L_002b: ldarg.0 L_002c: ldfld class [mscorlib]System.Security.Cryptography.MD5CryptoServiceProvider XHTTPServer.BasicAuthenticator::md5CryptoServiceProvider_0 L_0031: ldarg.0 L_0032: ldfld class [mscorlib]System.Text.Encoding XHTTPServer.BasicAuthenticator::encoding_0 L_0037: ldarg.2 L_0038: callvirt instance uint8[] [mscorlib]System.Text.Encoding::GetBytes(string) L_003d: callvirt instance uint8[] [mscorlib]System.Security.Cryptography.HashAlgorithm::ComputeHash(uint8[]) L_0042: call bool XHTTPServer.BasicAuthenticator::smethod_1(class [mscorlib]System.Collections.Generic.IEnumerable`1<!!??? // Unknown generic parameter>, uint8[]) L_0047: brfalse.s L_004b L_0049: ldc.i4.1 L_004a: ret L_004b: ldc.i4.0 L_004c: ret }

siegfriedpammer commented 7 years ago

This was probably fixed in the new decompiler engine (which just landed on the master branch).