Skip to content

Commit a35580f

Browse files
authored
Merge pull request #69 from codingseb/dev
Dev
2 parents bfc3e6a + ad09e44 commit a35580f

File tree

6 files changed

+44
-8
lines changed

6 files changed

+44
-8
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorScriptEvaluateTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,23 @@ public static IEnumerable<TestCaseData> TestCasesForScriptEvaluateTests
570570
yield return new TestCaseData("x >>= 2;",
571571
evaluator0011,
572572
new Action(() => evaluator0011.Variables["x"].ShouldBe(5)),
573-
new Action(() => evaluator0011.Variables["x"].ShouldBe(1)), null)
573+
new Action(() => evaluator0011.Variables["x"].ShouldBe(1)),
574+
null)
574575
.SetCategory("Script")
575576
.SetCategory("Variable assignation")
576577
.SetCategory(">>=")
577578
.Returns(1);
578579

580+
yield return new TestCaseData(Resources.Script0071,
581+
null,
582+
null,
583+
null,
584+
null)
585+
.SetCategory("Script")
586+
.SetCategory("Variable assignation")
587+
.SetCategory("??=")
588+
.Returns("First Null-coalescing assignation");
589+
579590
#endregion
580591

581592
#region Array content assignation

CodingSeb.ExpressionEvaluator.Tests/Resources.Designer.cs

Lines changed: 16 additions & 1 deletion
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,7 @@
328328
<data name="Script0070" type="System.Resources.ResXFileRef, System.Windows.Forms">
329329
<value>resources\script0070.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
330330
</data>
331+
<data name="Script0071" type="System.Resources.ResXFileRef, System.Windows.Forms">
332+
<value>resources\script0071.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
333+
</data>
331334
</root>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* Script0071 */
2+
var myVar = null;
3+
4+
myVar ??= "First Null-coalescing assignation";
5+
myVar ??= "Second Null-coalescing assignation";
6+
7+
return myVar;

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.16.0</Version>
9-
<AssemblyVersion>1.4.16.0</AssemblyVersion>
10-
<FileVersion>1.4.16.0</FileVersion>
8+
<Version>1.4.17.0</Version>
9+
<AssemblyVersion>1.4.17.0</AssemblyVersion>
10+
<FileVersion>1.4.17.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>* Bug Correction : When a ExpandoObject had a Property set to null an exception was thown that no property was found</PackageReleaseNotes>
21+
<PackageReleaseNotes>* Add support for Null-coalescing assignation operator ??=</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
@@ -30,7 +30,7 @@ public partial class ExpressionEvaluator
3030

3131
protected const string primaryTypesRegexPattern = @"(?<=^|[^\p{L}_])(?<primaryType>object|string|bool[?]?|byte[?]?|char[?]?|decimal[?]?|double[?]?|short[?]?|int[?]?|long[?]?|sbyte[?]?|float[?]?|ushort[?]?|uint[?]?|ulong[?]?|void)(?=[^a-zA-Z_]|$)";
3232

33-
protected static readonly Regex varOrFunctionRegEx = new Regex(@"^((?<sign>[+-])|(?<prefixOperator>[+][+]|--)|(?<varKeyword>var)\s+|(?<dynamicKeyword>dynamic)\s+|(?<inObject>(?<nullConditional>[?])?\.)?)(?<name>[\p{L}_](?>[\p{L}_0-9]*))(?>\s*)((?<assignationOperator>(?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>]))|(?<postfixOperator>([+][+]|--)(?![\p{L}_0-9]))|((?<isgeneric>[<](?>([\p{L}_](?>[\p{L}_0-9]*)|(?>\s+)|[,\.])+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?<isfunction>[(])?))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
33+
protected static readonly Regex varOrFunctionRegEx = new Regex(@"^((?<sign>[+-])|(?<prefixOperator>[+][+]|--)|(?<varKeyword>var)\s+|(?<dynamicKeyword>dynamic)\s+|(?<inObject>(?<nullConditional>[?])?\.)?)(?<name>[\p{L}_](?>[\p{L}_0-9]*))(?>\s*)((?<assignationOperator>(?<assignmentPrefix>[+\-*/%&|^]|<<|>>|\?\?)?=(?![=>]))|(?<postfixOperator>([+][+]|--)(?![\p{L}_0-9]))|((?<isgeneric>[<](?>([\p{L}_](?>[\p{L}_0-9]*)|(?>\s+)|[,\.])+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?<isfunction>[(])?))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
3434

3535
protected const string numberRegexOrigPattern = @"^(?<sign>[+-])?([0-9][0-9_{1}]*[0-9]|\d)(?<hasdecimal>{0}?([0-9][0-9_]*[0-9]|\d)(e[+-]?([0-9][0-9_]*[0-9]|\d))?)?(?<type>ul|[fdulm])?";
3636
protected string numberRegexPattern;
@@ -39,7 +39,7 @@ public partial class ExpressionEvaluator
3939
protected static readonly Regex stringBeginningRegex = new Regex("^(?<interpolated>[$])?(?<escaped>[@])?[\"]", RegexOptions.Compiled);
4040
protected static readonly Regex internalCharRegex = new Regex(@"^['](\\[\\'0abfnrtv]|[^'])[']", RegexOptions.Compiled);
4141
protected static readonly Regex indexingBeginningRegex = new Regex(@"^[?]?\[", RegexOptions.Compiled);
42-
protected static readonly Regex assignationOrPostFixOperatorRegex = new Regex(@"^(?>\s*)((?<assignmentPrefix>[+\-*/%&|^]|<<|>>)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![\p{L}_0-9])))");
42+
protected static readonly Regex assignationOrPostFixOperatorRegex = new Regex(@"^(?>\s*)((?<assignmentPrefix>[+\-*/%&|^]|<<|>>|\?\?)?=(?![=>])|(?<postfixOperator>([+][+]|--)(?![\p{L}_0-9])))");
4343
protected static readonly Regex genericsDecodeRegex = new Regex("(?<name>[^,<>]+)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?", RegexOptions.Compiled);
4444
protected static readonly Regex genericsEndOnlyOneTrim = new Regex(@"(?>\s*)[>](?>\s*)$", RegexOptions.Compiled);
4545

0 commit comments

Comments
 (0)