icsharpcode / ILSpy

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

Decompilation error on BinaryWriter::Write #526

Closed alfaproject closed 7 years ago

alfaproject commented 9 years ago

This is probably not specific to this specific method, but anyway, here be dragons:

IL

    IL_0063: ldloc.s 4
    IL_0065: ldc.i4.2
    IL_0066: callvirt instance void [mscorlib]System.IO.BinaryWriter::Write(uint8)
    IL_006b: ldloc.s 4
    IL_006d: ldc.i4.0
    IL_006e: callvirt instance void [mscorlib]System.IO.BinaryWriter::Write(int16)
    IL_0073: ldloc.s 4
    IL_0075: ldc.i4 43522
    IL_007a: callvirt instance void [mscorlib]System.IO.BinaryWriter::Write(int32)

C#

    binaryWriter.Write(2);
    binaryWriter.Write(0);
    binaryWriter.Write(43522);

As you can see the C# code is not using the correct overloads, and therefore the output has a different size. ):

siegfriedpammer commented 7 years ago

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