From af8993f641f266d90026ee10b73d9a32064c869b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 30 Sep 2017 21:26:14 +0200 Subject: [PATCH] Leave off '.Invoke' when calling delegates. --- .../TestCases/Pretty/CheckedUnchecked.cs | 2 +- ICSharpCode.Decompiler/CSharp/CallBuilder.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs index 45c576f84..62e28d983 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CheckedUnchecked.cs @@ -97,7 +97,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public T TestHelp(T t, Func f) { - return f.Invoke(t); + return f(t); } public void CheckedInArrayCreationArgument(int a, int b) diff --git a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs index 7e747e087..b50676a44 100644 --- a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs @@ -161,6 +161,8 @@ namespace ICSharpCode.Decompiler.CSharp int allowedParamCount = (method.ReturnType.IsKnownType(KnownTypeCode.Void) ? 1 : 0); if (method.IsAccessor && (method.AccessorOwner.SymbolKind == SymbolKind.Indexer || expectedParameters.Count == allowedParamCount)) { return HandleAccessorCall(inst, target, method, arguments.ToList()); + } else if (method.Name == "Invoke" && method.DeclaringType.Kind == TypeKind.Delegate) { + return new InvocationExpression(target, arguments.Select(arg => arg.Expression)).WithILInstruction(inst).WithRR(rr); } else { bool requireTypeArguments = false; bool targetCasted = false;