Browse Source

SwitchOnStringTransform: make sure switch variable is of type string in Roslyn case.

pull/887/head
Siegfried Pammer 9 years ago
parent
commit
43c2f891a0
  1. 4
      ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs

4
ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs

@ -93,8 +93,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
isLegacy = false; isLegacy = false;
values.Add((value, firstBlock)); values.Add((value, firstBlock));
} else return false; } else return false;
// switchValueVar must be assigned only once. // switchValueVar must be assigned only once and must be of type string.
if (!switchValueVar.IsSingleDefinition) if (!switchValueVar.IsSingleDefinition || !switchValueVar.Type.IsKnownType(KnownTypeCode.String))
return false; return false;
// if instruction must be followed by a branch to the next case // if instruction must be followed by a branch to the next case
if (!(instructions.ElementAtOrDefault(i + 1) is Branch nextCaseJump)) if (!(instructions.ElementAtOrDefault(i + 1) is Branch nextCaseJump))

Loading…
Cancel
Save