Reference type non-null-checks produce incorrect code
switchblade
Posts: 4
I've noticed this bug for a while now, I'm not sure when it was introduced but take this simple example here:
This is the decompiled output:
It seems to replace the expected "!=" with ">" which is not valid C# code. The same occurs on VB decompilation as well.
PS - The forum seems to be encoding "<" and ">" incorrectly using the code tags, would be nice if you could fix that too.
private static void ABC(byte[] b) { if (b != null) { Environment.Exit(0); } } private static void ABC(List<string> b) { if (b != null) { Environment.Exit(0); } }
This is the decompiled output:
private static void ABC(byte[] b) { if (b > null) { Environment.Exit(0); } } private static void ABC(List<string> b) { if (b > null) { Environment.Exit(0); } }
It seems to replace the expected "!=" with ">" which is not valid C# code. The same occurs on VB decompilation as well.
PS - The forum seems to be encoding "<" and ">" incorrectly using the code tags, would be nice if you could fix that too.
Tagged:
Comments
It's odd though, I'm not able to reproduce this at the moment.
May I ask the project type and the .NET Framework version of the assembly you're decompiling?
Thanks!
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?
https://stackoverflow.com/questions/28781839/why-does-the-c-sharp-compiler-translate-this-comparison-as-if-it-were-a-com
I have been able to reproduce this and as .NET Reflector should still be able to decompile != correctly, I have gone ahead and logged a bug for this internally with reference RP-4045. Thank you and I will let you know once I have any updates.
Just a note that we are also working on the bug where our forum is encoding code incorrectly--thanks for reporting this as well!
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?