Closed wklingler closed 7 years ago
Unfortunately this is not easy to fix with the old decompiler engine. Type inference there is basically guesswork, as we don't extract the necessary information from the IL code.
This is fixed in the newdecompiler branch. But that's a completely new decompiler engine, so it might be tricky to port JSIL to that.
This should be fixed in the new decompiler engine (which just landed on the master branch).
I'm not sure if you have run across this or not but here is the issue. This function:
becomes this in ILSpy:
The issue is that when the optimizer is on then the if statement if(expr_92 != null) changes the entire flow of the function because expr_92 will never be null and therefore the else block is never entered. The workaround that I found is if I actually move
to right before the if statement so it looks like this:
It looks like there might be some optimization that the C# compiler is doing and understands how to resolve the IL code to make it work properly because if I turn the optimizer off for the project then arg_92_0 is actually set to a bool and everything works fine. I am using JSIL to transpile my c# code into javascript code and they use the IL produced from c#. Because this is happening, it makes the functionality of that function not work right. The only reason this worries me is that this problem could happen in a ton of other locations just depending on how the developer likes to format their code. Do you have ideas or suggestions for this or is this something I'm just going to have to live with? Thanks!