Skip to content

Commit bfc3e6a

Browse files
authored
Merge pull request #68 from codingseb/dev
Dev
2 parents 86fb575 + 3da856a commit bfc3e6a

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,12 +1153,32 @@ public static IEnumerable<TestCaseData> TestCasesForWithCustomVariablesExpressio
11531153
yield return new TestCaseData("string.IsNullOrEmpty(nullVar) || nullVar.StartsWith(\"ABC\") == false", onInstanceVariables, true).SetCategory("Instance Property,Or Conditional").Returns(true);
11541154
yield return new TestCaseData("!string.IsNullOrEmpty(nullVar) && nullVar.Length < 2", onInstanceVariables, true).SetCategory("Instance Property,And Conditional").Returns(false);
11551155
yield return new TestCaseData("string.IsNullOrEmpty(nullVar) || nullVar.Length < 2", onInstanceVariables, true).SetCategory("Instance Property,Or Conditional").Returns(true);
1156-
yield return new TestCaseData("true || 1/0 == 0", onInstanceVariables, true).SetCategory("Instance Property,Or Conditional").Returns(true);
1156+
yield return new TestCaseData("true || 1/0 == 0", onInstanceVariables, true).SetCategory("Instance Property,Or Conditional").Returns(true);
11571157
yield return new TestCaseData("false && true || true", onInstanceVariables, true).SetCategory("Instance Property,Or Conditional,And Conditional,Precedence check").Returns(true);
11581158
yield return new TestCaseData("true || true && false", onInstanceVariables, true).SetCategory("Instance Property,Or Conditional,And Conditional,Precedence check").Returns(true);
11591159
yield return new TestCaseData("false && nullVar.What ? nullVar.Text : \"Hello\"", onInstanceVariables, true).SetCategory("Instance Property,Ternary operator, And Conditional").Returns("Hello");
11601160
yield return new TestCaseData("false && (false && nullVar.What ? nullVar.boolValue : true) ? nullVar.Text : \"Hello\"", onInstanceVariables, true).SetCategory("Instance Property,Ternary operator, And Conditional").Returns("Hello");
11611161

1162+
#endregion
1163+
1164+
#region ExpandoObject
1165+
1166+
dynamic MyDynamic = new System.Dynamic.ExpandoObject();
1167+
MyDynamic.NullValue = null;
1168+
MyDynamic.Number = 11;
1169+
1170+
Dictionary<string, object> ExpandoObjectVariables = new Dictionary<string, object>()
1171+
{
1172+
{ "expObj", MyDynamic },
1173+
};
1174+
1175+
yield return new TestCaseData("expObj.Number", ExpandoObjectVariables, true).SetCategory("ExpandoObject").SetCategory("Instance Property").Returns(11);
1176+
1177+
#region bug #67
1178+
yield return new TestCaseData("expObj.NullValue", ExpandoObjectVariables, true).SetCategory("ExpandoObject").SetCategory("Instance Property").Returns(null);
1179+
yield return new TestCaseData("expObj.NullValue ?? \"A\"", ExpandoObjectVariables, true).SetCategory("ExpandoObject").SetCategory("Instance Property").Returns("A");
1180+
#endregion
1181+
11621182

11631183
#endregion
11641184

CodingSeb.ExpressionEvaluator/CodingSeb.ExpressionEvaluator.csproj

Lines changed: 4 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.15.0</Version>
9-
<AssemblyVersion>1.4.15.0</AssemblyVersion>
10-
<FileVersion>1.4.15.0</FileVersion>
8+
<Version>1.4.16.0</Version>
9+
<AssemblyVersion>1.4.16.0</AssemblyVersion>
10+
<FileVersion>1.4.16.0</FileVersion>
1111
<OutputPath>bin\$(Configuration)\</OutputPath>
1212
<Authors>Coding Seb</Authors>
1313
<PackageId>CodingSeb.ExpressionEvaluator</PackageId>
@@ -18,7 +18,7 @@
1818
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1919
<PackageIconUrl>https://github.com/codingseb/ExpressionEvaluator/blob/master/Icon.png?raw=true</PackageIconUrl>
2020
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
21-
<PackageReleaseNotes>* Add a Hack to better manage overloaded Linq methods define in Enumerable (Sum, Average, Min and Max...)</PackageReleaseNotes>
21+
<PackageReleaseNotes>* Bug Correction : When a ExpandoObject had a Property set to null an exception was thown that no property was found</PackageReleaseNotes>
2222
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
2323
<RepositoryUrl>https://github.com/codingseb/ExpressionEvaluator</RepositoryUrl>
2424
</PropertyGroup>

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 2 additions & 2 deletions
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.15.0
3+
Version : 1.4.16.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
@@ -2117,7 +2117,7 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
21172117
}
21182118
}
21192119

2120-
if (varValue == null && pushVarValue)
2120+
if (!isDynamic && varValue == null && pushVarValue)
21212121
{
21222122
varValue = ((dynamic)member).GetValue(obj);
21232123

0 commit comments

Comments
 (0)