Browse Source

fix build; add correct resolve result for delegate construction

pull/728/head
Siegfried Pammer 10 years ago
parent
commit
214ddaa17d
  1. 6
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  2. 2
      ICSharpCode.Decompiler/Tests/ILTransforms/InliningTests.cs
  3. 7
      ICSharpCode.Decompiler/Tests/TestCases/Switch.cs

6
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -410,9 +410,11 @@ namespace ICSharpCode.Decompiler.CSharp @@ -410,9 +410,11 @@ namespace ICSharpCode.Decompiler.CSharp
{
var func = (LdFtn)inst.Arguments[1];
var target = TranslateTarget(func.Method, inst.Arguments[0], func.OpCode == OpCode.LdFtn);
return new MemberReferenceExpression(target, func.Method.Name)
return new ObjectCreateExpression(ConvertType(inst.Method.DeclaringType), new MemberReferenceExpression(target, func.Method.Name))
.WithILInstruction(inst)
.WithRR(new MemberResolveResult(target.ResolveResult, func.Method));
.WithRR(new ConversionResolveResult(func.Method.DeclaringType,
new MemberResolveResult(target.ResolveResult, func.Method),
Conversion.MethodGroupConversion(func.Method, func.OpCode == OpCode.LdVirtFtn, false))); // TODO handle extension methods capturing the first argument
}
TranslatedExpression TranslateTarget(IMember member, ILInstruction target, bool nonVirtualInvocation)

2
ICSharpCode.Decompiler/Tests/ILTransforms/InliningTests.cs

@ -93,7 +93,7 @@ namespace ICSharpCode.Decompiler.Tests.ILTransforms @@ -93,7 +93,7 @@ namespace ICSharpCode.Decompiler.Tests.ILTransforms
);
}
[Test]
[Test, Ignore("Inline blocks are currently disabled")]
public void BuildInlineBlock()
{
var f = MakeFunction(

7
ICSharpCode.Decompiler/Tests/TestCases/Switch.cs

@ -22,8 +22,11 @@ public static class Switch @@ -22,8 +22,11 @@ public static class Switch
{
public static void Main()
{
string[] args = { "First case", "Else" };
TestCase(ShortSwitchOverString, args);
TestCase(ShortSwitchOverString, "First case", "Else");
TestCase(SwitchOverString1, "First case", "Second case", "2nd case", "Third case", "Fourth case", "Fifth case", "Sixth case", null, "default", "else");
Console.WriteLine(SwitchOverString2());
Console.WriteLine(SwitchOverBool(true));
Console.WriteLine(SwitchOverBool(false));
}
static void TestCase(Func<string, string> target, params string[] args)

Loading…
Cancel
Save