Browse Source

Fix #1742: Special case for case string.Empty generated by mcs.

pull/1754/head
Siegfried Pammer 6 years ago
parent
commit
0a432e23fb
  1. 9
      ICSharpCode.Decompiler/IL/Transforms/SwitchOnStringTransform.cs

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

@ -639,8 +639,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -639,8 +639,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms
index = -1;
if (!(inst is CallInstruction c && c.Method.Name == "Add" && c.Arguments.Count == 3))
return false;
if (!(c.Arguments[0].MatchLdLoc(dictVar) && c.Arguments[1].MatchLdStr(out value)))
if (!c.Arguments[0].MatchLdLoc(dictVar))
return false;
if (!c.Arguments[1].MatchLdStr(out value)) {
if (c.Arguments[1].MatchLdsFld(out var field) && field.DeclaringType.IsKnownType(KnownTypeCode.String) && field.Name == "Empty") {
value = "";
} else {
return false;
}
}
if (!(c.Method.DeclaringType.Equals(dictionaryType) && !c.Method.IsStatic))
return false;
return (c.Arguments[2].MatchLdcI4(out index) || (c.Arguments[2].MatchBox(out var arg, out _) && arg.MatchLdcI4(out index)));

Loading…
Cancel
Save