The switch/case logic is not handling goto case ...; instead either complicated ifs are generated or a bunch of labels and gotos are generated after the switch.
Set of ifs:
string test = "hello";
switch (test)
{
case "hello":
Console.WriteLine("Foo");
goto case "bar";
case "bar":
Console.WriteLine("Bar");
break;
case "baz":
Console.WriteLine("Bar");
break;
case "frob":
Console.WriteLine("Bar");
goto case "bar";
}
We get (which is likely 'correct'):
string test = "hello";
string text = test;
if (text != null)
{
if (!(text == "hello"))
{
if (!(text == "bar"))
{
if (text == "baz")
{
Console.WriteLine("Bar");
return;
}
if (!(text == "frob"))
{
return;
}
Console.WriteLine("Bar");
}
}
else
{
Console.WriteLine("Foo");
}
Console.WriteLine("Bar");
}
For the goto example decompile System.Web.Mvc.Html.InputExtensions::InputHelper from System.Web.Mvc (Version 3.0.0.0).
The switch/case logic is not handling
goto case ...; instead either complicatedifs are generated or a bunch of labels andgotos are generated after theswitch.Set of
ifs:We get (which is likely 'correct'):
For the
gotoexample decompileSystem.Web.Mvc.Html.InputExtensions::InputHelperfrom System.Web.Mvc (Version 3.0.0.0).