From 143c22301e1db9f083cbb20198119ab46cd8ffd2 Mon Sep 17 00:00:00 2001
From: Pavel Vostretsov
Date: Sat, 7 Sep 2019 23:29:49 +0500
Subject: [PATCH 1/3] fix LambdaExpressionCreator
---
GrobExp.Compiler.Tests/Test.cs | 7 +++++++
GrobExp.Compiler/LambdaExpressionCreator.cs | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/GrobExp.Compiler.Tests/Test.cs b/GrobExp.Compiler.Tests/Test.cs
index 8227db3..fde0191 100644
--- a/GrobExp.Compiler.Tests/Test.cs
+++ b/GrobExp.Compiler.Tests/Test.cs
@@ -20,6 +20,13 @@ public void TestNullable()
func(null);
}
+ [Test]
+ public void TestLambdaExpressionCreator()
+ {
+ Expression> e = x => x.Substring(1, 2);
+ LambdaExpressionCreator.Create>(e.Body, e.Parameters.ToArray());
+ }
+
[Test]
public void TestRefParameter()
{
diff --git a/GrobExp.Compiler/LambdaExpressionCreator.cs b/GrobExp.Compiler/LambdaExpressionCreator.cs
index d7ff6cc..f7b492c 100644
--- a/GrobExp.Compiler/LambdaExpressionCreator.cs
+++ b/GrobExp.Compiler/LambdaExpressionCreator.cs
@@ -69,7 +69,7 @@ private static LambdaCreateDelegate BuildLambdaFactory(Type delegateType)
il.Ldarg(1);
il.Ldarg(2);
il.Ldarg(3);
- il.Newobj(resultType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single());
+ il.Callnonvirt(resultType.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Single(x => x.Name == "Create"));
il.Ret();
}
return (LambdaCreateDelegate)method.CreateDelegate(typeof(LambdaCreateDelegate));
From 8491360dbd6e5d13a126d87bb7db698aa880aad4 Mon Sep 17 00:00:00 2001
From: Pavel Vostretsov
Date: Tue, 10 Sep 2019 13:56:35 +0500
Subject: [PATCH 2/3] Review fixes
---
GrobExp.Compiler.Tests/Test.cs | 3 ++-
GrobExp.Compiler/LambdaExpressionCreator.cs | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/GrobExp.Compiler.Tests/Test.cs b/GrobExp.Compiler.Tests/Test.cs
index fde0191..248d2d7 100644
--- a/GrobExp.Compiler.Tests/Test.cs
+++ b/GrobExp.Compiler.Tests/Test.cs
@@ -24,7 +24,8 @@ public void TestNullable()
public void TestLambdaExpressionCreator()
{
Expression> e = x => x.Substring(1, 2);
- LambdaExpressionCreator.Create>(e.Body, e.Parameters.ToArray());
+ var lambda = LambdaExpressionCreator.Create>(e.Body, e.Parameters.ToArray());
+ Assert.That(lambda.Compile()("abcd"), Is.EqualTo("bc"));
}
[Test]
diff --git a/GrobExp.Compiler/LambdaExpressionCreator.cs b/GrobExp.Compiler/LambdaExpressionCreator.cs
index f7b492c..c5fed5d 100644
--- a/GrobExp.Compiler/LambdaExpressionCreator.cs
+++ b/GrobExp.Compiler/LambdaExpressionCreator.cs
@@ -69,7 +69,7 @@ private static LambdaCreateDelegate BuildLambdaFactory(Type delegateType)
il.Ldarg(1);
il.Ldarg(2);
il.Ldarg(3);
- il.Callnonvirt(resultType.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Single(x => x.Name == "Create"));
+ il.Callnonvirt(resultType.GetMethod("Create", BindingFlags.NonPublic | BindingFlags.Static));
il.Ret();
}
return (LambdaCreateDelegate)method.CreateDelegate(typeof(LambdaCreateDelegate));
From c668015becbc46a98bf9fe3523ba71fdb92946a0 Mon Sep 17 00:00:00 2001
From: Pavel Vostretsov
Date: Tue, 10 Sep 2019 13:59:31 +0500
Subject: [PATCH 3/3] up version
---
GrobExp.Compiler.Tests/GrobExp.Compiler.Tests.csproj | 6 +++---
GrobExp.Compiler/GrobExp.Compiler.csproj | 2 +-
version.json | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/GrobExp.Compiler.Tests/GrobExp.Compiler.Tests.csproj b/GrobExp.Compiler.Tests/GrobExp.Compiler.Tests.csproj
index 5f06973..dea3ca8 100644
--- a/GrobExp.Compiler.Tests/GrobExp.Compiler.Tests.csproj
+++ b/GrobExp.Compiler.Tests/GrobExp.Compiler.Tests.csproj
@@ -7,9 +7,9 @@
-
-
-
+
+
+
diff --git a/GrobExp.Compiler/GrobExp.Compiler.csproj b/GrobExp.Compiler/GrobExp.Compiler.csproj
index b0ae52a..58161e6 100644
--- a/GrobExp.Compiler/GrobExp.Compiler.csproj
+++ b/GrobExp.Compiler/GrobExp.Compiler.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/version.json b/version.json
index 9a35ff8..07bb75a 100644
--- a/version.json
+++ b/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
- "version": "1.2",
+ "version": "1.3",
"assemblyVersion": {
"precision": "build"
},