Browse Source

Merge remote-tracking branch 'origin/newdecompiler' into newdecompiler

Conflicts:
	NRefactory
pull/728/head
Daniel Grunwald 11 years ago
parent
commit
f5009f9487
  1. 14
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 6
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  3. 2
      ICSharpCode.Decompiler/Tests/ILTransforms/InliningTests.cs
  4. 7
      ICSharpCode.Decompiler/Tests/TestCases/Switch.cs

14
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -193,6 +193,20 @@ namespace ICSharpCode.Decompiler.CSharp @@ -193,6 +193,20 @@ namespace ICSharpCode.Decompiler.CSharp
typeDecl.Members.Add(memberDecl);
}
}
if (typeDecl.Members.OfType<IndexerDeclaration>().Any(idx => idx.PrivateImplementationType.IsNull)) {
// Remove the [DefaultMember] attribute if the class contains indexers
foreach (AttributeSection section in typeDecl.Attributes) {
foreach (var attr in section.Attributes) {
var tr = attr.Type.GetResolveResult().Type;
if (tr.Name == "DefaultMemberAttribute" && tr.Namespace == "System.Reflection") {
attr.Remove();
}
}
if (section.Attributes.Count == 0)
section.Remove();
}
}
return typeDecl;
}

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