Browse Source

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

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

Loading…
Cancel
Save