Skip to content

Commit bca761c

Browse files
authored
Merge pull request #43 from codingseb/dev
Dev
2 parents 1d414dc + 71ad335 commit bca761c

File tree

7 files changed

+184
-18
lines changed

7 files changed

+184
-18
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorScriptEvaluateTests.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,21 @@ public static IEnumerable<TestCaseData> TestCasesForScriptEvaluateTests
825825

826826
#endregion
827827

828+
#region List<>.ForEach
829+
yield return new TestCaseData(Resources.Script0068, null, null, null, null)
830+
.SetCategory("Script")
831+
.SetCategory("List")
832+
.SetCategory("variable assignation")
833+
.SetCategory("ForEach")
834+
.Returns(10);
835+
yield return new TestCaseData(Resources.Script0069, null, null, null, null)
836+
.SetCategory("Script")
837+
.SetCategory("List")
838+
.SetCategory("variable assignation")
839+
.SetCategory("ForEach")
840+
.Returns("1;2;3;4;");
841+
#endregion
842+
828843
#region if, else if, else
829844

830845
yield return new TestCaseData(Resources.Script0004.Replace("[valx]", "0").Replace("[valy]", "1"), null, null, null, null)
@@ -1612,12 +1627,12 @@ public static IEnumerable<TestCaseData> TestCasesForRemoveCommentsTests
16121627
yield return new TestCaseData("/* multi line\nblock comment */").SetCategory("RemoveComments").Returns("\n");
16131628
yield return new TestCaseData(@"a = ""apple""; // test").SetCategory("RemoveComments").Returns(@"a = ""apple""; ");
16141629
yield return new TestCaseData(@"a = ""apple""; /* test */").SetCategory("RemoveComments").Returns(@"a = ""apple""; ");
1615-
yield return new TestCaseData(@"// /*comment within comments */").SetCategory("RemoveComments").Returns(@" ");
1616-
yield return new TestCaseData(@"/* //comment within comments */").SetCategory("RemoveComments").Returns(@" ");
1617-
yield return new TestCaseData(@"// bla bla /*comment within comments */ bla bla").SetCategory("RemoveComments").Returns(@" ");
1618-
yield return new TestCaseData(@"/* bla bla //comment within comments */").SetCategory("RemoveComments").Returns(@" ");
1619-
yield return new TestCaseData(@"// ""bla bla"" ").SetCategory("RemoveComments").Returns(@" ");
1620-
yield return new TestCaseData(@"/* ""bla bla"" */").SetCategory("RemoveComments").Returns(@" ");
1630+
yield return new TestCaseData("// /*comment within comments */").SetCategory("RemoveComments").Returns(" ");
1631+
yield return new TestCaseData("/* //comment within comments */").SetCategory("RemoveComments").Returns(" ");
1632+
yield return new TestCaseData("// bla bla /*comment within comments */ bla bla").SetCategory("RemoveComments").Returns(" ");
1633+
yield return new TestCaseData("/* bla bla //comment within comments */").SetCategory("RemoveComments").Returns(" ");
1634+
yield return new TestCaseData(@"// ""bla bla"" ").SetCategory("RemoveComments").Returns(" ");
1635+
yield return new TestCaseData(@"/* ""bla bla"" */").SetCategory("RemoveComments").Returns(" ");
16211636
yield return new TestCaseData(@"""// test """).SetCategory("RemoveComments").SetCategory("Not a comments").Returns(@"""// test """);
16221637
yield return new TestCaseData(@"""/* test */""").SetCategory("RemoveComments").SetCategory("Not a comments").Returns(@"""/* test */""");
16231638
yield return new TestCaseData(@"""bla bla // test """).SetCategory("RemoveComments").SetCategory("Not a comments").Returns(@"""bla bla // test """);

CodingSeb.ExpressionEvaluator.Tests/Resources.Designer.cs

Lines changed: 37 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodingSeb.ExpressionEvaluator.Tests/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,10 @@
319319
<data name="Script0067" type="System.Resources.ResXFileRef, System.Windows.Forms">
320320
<value>resources\script0067.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
321321
</data>
322+
<data name="Script0068" type="System.Resources.ResXFileRef, System.Windows.Forms">
323+
<value>resources\script0068.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
324+
</data>
325+
<data name="Script0069" type="System.Resources.ResXFileRef, System.Windows.Forms">
326+
<value>resources\script0069.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
327+
</data>
322328
</root>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* Script0068 */
2+
List<int> myList = new List<int>{1, 2, 3, 4};
3+
4+
int a = 0;
5+
6+
myList.ForEach(v => a += v);
7+
8+
return a;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* Script0069 */
2+
List<int> myList = new List<int>{1, 2, 3, 4};
3+
4+
string text = "";
5+
6+
myList.ForEach(v =>
7+
{
8+
text += v.ToString() + ";";
9+
});
10+
11+
return text;

CodingSeb.ExpressionEvaluator/CodingSeb.ExpressionEvaluator.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<Product>CodingSeb.ExpressionEvaluator</Product>
66
<Description>A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts</Description>
77
<Copyright>Copyright © Coding Seb 2017</Copyright>
8-
<Version>1.4.4.0</Version>
9-
<AssemblyVersion>1.4.4.0</AssemblyVersion>
10-
<FileVersion>1.4.4.0</FileVersion>
8+
<Version>1.4.5.0</Version>
9+
<AssemblyVersion>1.4.5.0</AssemblyVersion>
10+
<FileVersion>1.4.5.0</FileVersion>
1111
<OutputPath>bin\$(Configuration)\</OutputPath>
1212
<Authors>Coding Seb</Authors>
1313
<PackageId>CodingSeb.ExpressionEvaluator</PackageId>
@@ -18,7 +18,8 @@
1818
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1919
<PackageIconUrl>https://github.com/codingseb/ExpressionEvaluator/blob/master/Icon.png?raw=true</PackageIconUrl>
2020
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
21-
<PackageReleaseNotes>* Small correction in the text of some exception</PackageReleaseNotes>
21+
<PackageReleaseNotes>* myList.ForEach(v =&gt; ...) now working
22+
* Methods that has Action or Action&lt;...&gt; arguments now working</PackageReleaseNotes>
2223
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
2324
</PropertyGroup>
2425
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/******************************************************************************************************
22
Title : ExpressionEvaluator (https://github.com/codingseb/ExpressionEvaluator)
3-
Version : 1.4.4.0
3+
Version : 1.4.5.0
44
(if last digit (the forth) is not a zero, the version is an intermediate version and can be unstable)
55
66
Author : Coding Seb
@@ -2928,6 +2928,16 @@ protected virtual MethodInfo GetRealMethod(ref Type type, ref object obj, string
29282928
.MakeGenericMethod(parameterType.GetGenericArguments());
29292929
modifiedArgs[a] = Delegate.CreateDelegate(parameterType, de, encapsMethod);
29302930
}
2931+
else if(paramTypeName.StartsWith("Action")
2932+
&& modifiedArgs[a] is InternalDelegate)
2933+
{
2934+
InternalDelegate led = modifiedArgs[a] as InternalDelegate;
2935+
DelegateEncaps de = new DelegateEncaps(led);
2936+
MethodInfo encapsMethod = de.GetType()
2937+
.GetMethod($"Action{parameterType.GetGenericArguments().Length}")
2938+
.MakeGenericMethod(parameterType.GetGenericArguments());
2939+
modifiedArgs[a] = Delegate.CreateDelegate(parameterType, de, encapsMethod);
2940+
}
29312941
else if (paramTypeName.StartsWith("Converter")
29322942
&& modifiedArgs[a] is InternalDelegate)
29332943
{
@@ -3396,6 +3406,91 @@ public object CallFluidMethod(params object[] args)
33963406
return target;
33973407
}
33983408

3409+
public void Action0()
3410+
{
3411+
lambda();
3412+
}
3413+
3414+
public void Action1<T1>(T1 arg1)
3415+
{
3416+
lambda(arg1);
3417+
}
3418+
3419+
public void Action2<T1, T2>(T1 arg1, T2 arg2)
3420+
{
3421+
lambda(arg1, arg2);
3422+
}
3423+
3424+
public void Action3<T1, T2, T3>(T1 arg1, T2 arg2, T3 arg3)
3425+
{
3426+
lambda(arg1, arg2, arg3);
3427+
}
3428+
3429+
public void Action4<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
3430+
{
3431+
lambda(arg1, arg2, arg3, arg4);
3432+
}
3433+
3434+
public void Action5<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
3435+
{
3436+
lambda(arg1, arg2, arg3, arg4, arg5);
3437+
}
3438+
3439+
public void Action6<T1, T2, T3, T4, T5, T6>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
3440+
{
3441+
lambda(arg1, arg2, arg3, arg4, arg5, arg6);
3442+
}
3443+
3444+
public void Action7<T1, T2, T3, T4, T5, T6, T7>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
3445+
{
3446+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
3447+
}
3448+
3449+
public void Action8<T1, T2, T3, T4, T5, T6, T7, T8>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
3450+
{
3451+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
3452+
}
3453+
3454+
public void Action9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
3455+
{
3456+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
3457+
}
3458+
3459+
public void Action10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)
3460+
{
3461+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
3462+
}
3463+
3464+
public void Action11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11)
3465+
{
3466+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
3467+
}
3468+
3469+
public void Action12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12)
3470+
{
3471+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
3472+
}
3473+
3474+
public void Action13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13)
3475+
{
3476+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
3477+
}
3478+
3479+
public void Action14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14)
3480+
{
3481+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
3482+
}
3483+
3484+
public void Action15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15)
3485+
{
3486+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
3487+
}
3488+
3489+
public void Action16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16)
3490+
{
3491+
lambda(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
3492+
}
3493+
33993494
public TResult Func0<TResult>()
34003495
{
34013496
return (TResult)lambda();

0 commit comments

Comments
 (0)