Closed greenozon closed 7 years ago
ILSpy has a step for decompiling switch on strings, but that only handles Dictionary<string, int>
, not Hashtable
.
Could you point me to the right location in sources on the mentioned handler? I've encountered this type of decompilation and would like to see it in depth..... Thanks
It's TransformSwitchOnString
in PatternStatementTransform.cs.
Unfortunately it's currently implemented as a C# transform which tries to detect a specific pattern with the if (dict.TryGetValue())
call. This is a problem in certain scenarios, as control flow analysis / goto-removal sometimes produces different patterns. It would be better to do this step earlier in the decompilation pipeline (in the ILAst, before the control flow transformations), but we haven't had the time to re-implement this step for the ILAst.
Sorry for taking so long to work on this. With the rewrite of the decompiler engine we now reimplemented switch-on-string
in the ILAst. We currently can only correctly handle C# switch-string patterns that either use Dictionary<string, int>
(legacy C#) or a special hash function (Roslyn).
Could you provide a binary containing an example that uses Hashtable
?
Here is how ILSpy 2.2 decompiles some switch blocks:
public static BitArray getBoolArrayOfPermissions(ArrayList permissions) { if (.$$method0x600024f-1 == null)
{