Skip to content

Commit 7e78c1c

Browse files
committed
Merge branch 'master' into dev
2 parents e63ec02 + c2201bb commit 7e78c1c

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3278,5 +3278,22 @@ public void MethodWithInParameterInlineVarDeclarationAndInit()
32783278

32793279
#endregion
32803280

3281+
#region Method with implicit parameter
3282+
3283+
[Test]
3284+
[Category("ImplicitParameterMethod")]
3285+
public void MethodWithImplicitParameter()
3286+
{
3287+
ExpressionEvaluator evaluator = new ExpressionEvaluator();
3288+
3289+
evaluator.Variables["inObj"] = new MethodArgKeywordClass();
3290+
3291+
evaluator.Variables["x"] = "string";
3292+
3293+
evaluator.Evaluate("inObj.AcceptStringLike(x)")
3294+
.ShouldBe(true);
3295+
}
3296+
3297+
#endregion
32813298
}
32823299
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CodingSeb.ExpressionEvaluator.Tests.TestsUtils
8+
{
9+
public readonly struct StringLikeParameter
10+
{
11+
public readonly string Value;
12+
13+
public StringLikeParameter(string s)
14+
{
15+
Value = s;
16+
}
17+
18+
public static implicit operator StringLikeParameter(string s) => new StringLikeParameter(s);
19+
}
20+
}

CodingSeb.ExpressionEvaluator.Tests/TestsUtils/MethodArgKeywordClass.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Linq;
1+
using CodingSeb.ExpressionEvaluator.Tests.TestsUtils;
2+
using System.Linq;
23

34
namespace CodingSeb.ExpressionEvaluator.Tests
45
{
@@ -53,8 +54,15 @@ public int SumOf(int val1 = 19, int val2 = 21)
5354
{
5455
return val1 + val2;
5556
}
57+
58+
public bool AcceptStringLike(StringLikeParameter value)
59+
{
60+
return true;
61+
}
5662
}
5763

64+
65+
5866
public static class MethodArgKeywordClassExtension
5967
{
6068
public static string UseAsSepForJoin(this string separator, params object[] values)

0 commit comments

Comments
 (0)