Skip to content

Commit 3656130

Browse files
authored
Merge pull request #169 from nekosaur/fix/bubble-container-string-return
fix: addition of null and bubble container
2 parents 4829467 + ce637be commit 3656130

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json;
1+
using Microsoft.CSharp.RuntimeBinder;
2+
using Newtonsoft.Json;
23
using NUnit.Framework;
34
using Shouldly;
45
using System;
@@ -1837,6 +1838,15 @@ public void Evaluate_DoubleDoubleQuotesInEscapedStringThrowException()
18371838

18381839
evaluator.Evaluate("@\"Hello \"\" Joe\"").ShouldBe(@"Hello "" Joe");
18391840
}
1841+
1842+
[Test]
1843+
[Category("Bug")]
1844+
public void Evaluate_NullAdditionShouldThrowExceptionNotReturnString()
1845+
{
1846+
var evaluator = new ExpressionEvaluator();
1847+
1848+
Should.Throw<RuntimeBinderException>(() => evaluator.Evaluate("(null + null) + null"));
1849+
}
18401850

18411851
//[Test]
18421852
//[Category("Bug")]

CodingSeb.ExpressionEvaluator/CodingSeb.ExpressionEvaluator.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
2727
<RepositoryUrl>https://github.com/codingseb/ExpressionEvaluator</RepositoryUrl>
2828
<GenerateDocumentationFile>true</GenerateDocumentationFile>
29+
<PackageReadmeFile>README.md</PackageReadmeFile>
2930
</PropertyGroup>
3031
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3132
<DebugType>full</DebugType>
@@ -53,5 +54,9 @@
5354
<Pack>True</Pack>
5455
<PackagePath></PackagePath>
5556
</None>
57+
<None Include="..\README.md">
58+
<Pack>True</Pack>
59+
<PackagePath>\</PackagePath>
60+
</None>
5661
</ItemGroup>
5762
</Project>

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,11 +3296,11 @@ void EvaluateFirstPreviousUnaryOp(int j)
32963296
{
32973297
list[i] = operatorEvalutationsDict[eOp](left, right);
32983298

3299-
if (left is BubbleExceptionContainer && right is string)
3299+
if (left is BubbleExceptionContainer && right is string or null)
33003300
{
33013301
list[i] = left; //Bubble up the causing error
33023302
}
3303-
else if (right is BubbleExceptionContainer && left is string)
3303+
else if (right is BubbleExceptionContainer && left is string or null)
33043304
{
33053305
list[i] = right; //Bubble up the causing error
33063306
}

0 commit comments

Comments
 (0)