Skip to content

Commit b30eb35

Browse files
committed
feat!: updated for dotnet 9
1 parent 9b49e7b commit b30eb35

16 files changed

Lines changed: 175 additions & 215 deletions

ExpressionEngine/ExpressionEngine.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net8.0;net48;net462</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0;net48;net462</TargetFrameworks>
55

66
<PackageId>Delegate.ExpressionEngine</PackageId>
77
<Authors>Delegate A/S,thygesteffensen</Authors>
@@ -26,19 +26,20 @@
2626

2727
</ItemGroup>
2828

29-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
30-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
29+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
30+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
3131

3232
</ItemGroup>
3333

3434
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
35-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
35+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
3636

3737
</ItemGroup>
3838

3939
<ItemGroup>
40-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
40+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
4141
<PackageReference Include="Sprache" Version="2.3.1" />
42+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
4243
</ItemGroup>
4344

4445
<ItemGroup>

ExpressionEngine/Functions/Implementations/StringFunctions/FormatNumberFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Globalization;
1+
using System.Globalization;
22
using System.Threading.Tasks;
33
using ExpressionEngine.Functions.Base;
44
using ExpressionEngine.Functions.CustomException;

Test/Expression/GenericExpressionTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Threading.Tasks;
22
using ExpressionEngine;
33
using ExpressionEngine.Functions.Base;
4-
using NUnit.Framework;
4+
using NUnit.Framework;using NUnit.Framework.Legacy;
55

66
namespace Test.Expression
77
{
@@ -18,7 +18,7 @@ public async Task TestFunction(IFunction func, string name,
1818
{
1919
var result = await func.ExecuteFunction(parameters);
2020

21-
Assert.AreEqual(expected, result);
21+
ClassicAssert.AreEqual(expected, result);
2222
}
2323
}
2424
}

Test/Expression/StringFunctionTests.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Threading.Tasks;
33
using ExpressionEngine;
44
using ExpressionEngine.Functions.Implementations.StringFunctions;
5-
using NUnit.Framework;
5+
using NUnit.Framework;using NUnit.Framework.Legacy;
6+
using NUnit.Framework.Legacy;
67

78
namespace Test.Expression
89
{
@@ -188,15 +189,15 @@ public async Task GuidFunctionTest()
188189

189190
var result1 = await func.ExecuteFunction();
190191

191-
Assert.AreEqual(36, result1.GetValue<string>().Length);
192+
ClassicAssert.AreEqual(36, result1.GetValue<string>().Length);
192193

193194
var result2 = await func.ExecuteFunction(new ValueContainer("N"));
194195

195-
Assert.AreEqual(32, result2.GetValue<string>().Length);
196+
ClassicAssert.AreEqual(32, result2.GetValue<string>().Length);
196197

197198
var result3 = await func.ExecuteFunction(new ValueContainer("B"));
198199

199-
Assert.AreEqual(38, result3.GetValue<string>().Length);
200+
ClassicAssert.AreEqual(38, result3.GetValue<string>().Length);
200201
}
201202

202203
[Test]
@@ -209,13 +210,13 @@ public async Task SplitFunctionTest()
209210

210211
var array = result1.GetValue<List<ValueContainer>>();
211212

212-
Assert.AreEqual(5, array.Count);
213+
ClassicAssert.AreEqual(5, array.Count);
213214

214-
Assert.AreEqual("This is ", array[0].GetValue<string>());
215-
Assert.AreEqual(" a ", array[1].GetValue<string>());
216-
Assert.AreEqual(" ", array[2].GetValue<string>());
217-
Assert.AreEqual("litted ", array[3].GetValue<string>());
218-
Assert.AreEqual(" string", array[4].GetValue<string>());
215+
ClassicAssert.AreEqual("This is ", array[0].GetValue<string>());
216+
ClassicAssert.AreEqual(" a ", array[1].GetValue<string>());
217+
ClassicAssert.AreEqual(" ", array[2].GetValue<string>());
218+
ClassicAssert.AreEqual("litted ", array[3].GetValue<string>());
219+
ClassicAssert.AreEqual(" string", array[4].GetValue<string>());
219220
}
220221
}
221222
}

Test/ExpressionGrammarTest.cs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Threading.Tasks;
33
using ExpressionEngine;
44
using ExpressionEngine.Functions.Base;
55
using ExpressionEngine.Functions.CustomException;
66
using Microsoft.Extensions.DependencyInjection;
7-
using NUnit.Framework;
7+
using NUnit.Framework;using NUnit.Framework.Legacy;
8+
using NUnit.Framework.Legacy;
89

910
namespace Test
1011
{
@@ -48,7 +49,7 @@ public async Task IndicesTest()
4849

4950
var result = await _expressionGrammar.EvaluateToString(expressionString);
5051

51-
Assert.AreEqual("value", result);
52+
ClassicAssert.AreEqual("value", result);
5253
}
5354

5455
[Test]
@@ -58,16 +59,16 @@ public async Task BooleanTest()
5859

5960
await _expressionGrammar.EvaluateToValueContainer(expressionString);
6061

61-
Assert.NotNull(_dummyFunction.Parameters);
62-
Assert.AreEqual(2, _dummyFunction.Parameters.Length);
62+
ClassicAssert.NotNull(_dummyFunction.Parameters);
63+
ClassicAssert.AreEqual(2, _dummyFunction.Parameters.Length);
6364
var param1 = _dummyFunction.Parameters[0];
6465
var param2 = _dummyFunction.Parameters[1];
65-
Assert.NotNull(param1);
66-
Assert.NotNull(param2);
67-
Assert.AreEqual(ValueType.Boolean, param1.Type());
68-
Assert.AreEqual(ValueType.Boolean, param2.Type());
69-
Assert.AreEqual(true, param1.GetValue<bool>());
70-
Assert.AreEqual(false, param2.GetValue<bool>());
66+
ClassicAssert.NotNull(param1);
67+
ClassicAssert.NotNull(param2);
68+
ClassicAssert.AreEqual(ValueType.Boolean, param1.Type());
69+
ClassicAssert.AreEqual(ValueType.Boolean, param2.Type());
70+
ClassicAssert.AreEqual(true, param1.GetValue<bool>());
71+
ClassicAssert.AreEqual(false, param2.GetValue<bool>());
7172
}
7273

7374
[Test]
@@ -79,8 +80,8 @@ public async Task NullConditional()
7980

8081
var result = await _expressionGrammar.EvaluateToValueContainer(expressionString);
8182

82-
Assert.NotNull(result);
83-
Assert.AreEqual(ValueType.Null, result.Type());
83+
ClassicAssert.NotNull(result);
84+
ClassicAssert.AreEqual(ValueType.Null, result.Type());
8485
}
8586

8687
[Test]
@@ -90,10 +91,10 @@ public async Task IndexOnNonObject()
9091

9192
const string expressionString = "@dummyFunction()?.name1";
9293

93-
var exception = Assert.ThrowsAsync<InvalidTemplateException>(async () =>
94+
var exception = ClassicAssert.ThrowsAsync<InvalidTemplateException>(async () =>
9495
await _expressionGrammar.EvaluateToValueContainer(expressionString));
9596

96-
Assert.AreEqual("Unable to process template language expressions in action 'Compose' inputs " +
97+
ClassicAssert.AreEqual("Unable to process template language expressions in action 'Compose' inputs " +
9798
"at line 'x' and column 'y': 'The template language expression 'dummyFunction()?.name1' cannot be " +
9899
"evaluated because property 'name1' cannot be selected. Property selection is not supported on values " +
99100
"of type 'String'.", exception.Message);
@@ -112,21 +113,21 @@ public async Task NegativeNumbers()
112113

113114
if (functionOutput != null && functionOutput.Type() == ValueType.String)
114115
{
115-
Assert.AreNotEqual(expressionString, functionOutput.GetValue<string>());
116+
ClassicAssert.AreNotEqual(expressionString, functionOutput.GetValue<string>());
116117
}
117118

118119
var functionParameters = _dummyFunction.Parameters;
119120

120-
Assert.AreEqual(4, functionParameters.Length);
121-
Assert.AreEqual(ValueType.Integer, functionParameters[0].Type());
122-
Assert.AreEqual(ValueType.Float, functionParameters[1].Type());
123-
Assert.AreEqual(ValueType.Integer, functionParameters[2].Type());
124-
Assert.AreEqual(ValueType.Float, functionParameters[3].Type());
121+
ClassicAssert.AreEqual(4, functionParameters.Length);
122+
ClassicAssert.AreEqual(ValueType.Integer, functionParameters[0].Type());
123+
ClassicAssert.AreEqual(ValueType.Float, functionParameters[1].Type());
124+
ClassicAssert.AreEqual(ValueType.Integer, functionParameters[2].Type());
125+
ClassicAssert.AreEqual(ValueType.Float, functionParameters[3].Type());
125126

126-
Assert.AreEqual(expectedOutput1, functionParameters[0]);
127-
Assert.AreEqual(expectedOutput2, functionParameters[1]);
128-
Assert.AreEqual(expectedOutput3, functionParameters[2]);
129-
Assert.AreEqual(expectedOutput4, functionParameters[3]);
127+
ClassicAssert.AreEqual(expectedOutput1, functionParameters[0]);
128+
ClassicAssert.AreEqual(expectedOutput2, functionParameters[1]);
129+
ClassicAssert.AreEqual(expectedOutput3, functionParameters[2]);
130+
ClassicAssert.AreEqual(expectedOutput4, functionParameters[3]);
130131
}
131132
}
132133

Test/FunctionDefinitionTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using System;
1+
using System;
22
using System.Threading.Tasks;
33
using ExpressionEngine;
44
using ExpressionEngine.Functions.CustomException;
55
using Microsoft.Extensions.DependencyInjection;
6-
using NUnit.Framework;
6+
using NUnit.Framework;using NUnit.Framework.Legacy;
7+
using NUnit.Framework.Legacy;
78

89
namespace Test
910
{
@@ -27,21 +28,21 @@ public async Task TestFunctionDef()
2728

2829
var actualResult = await ee.Parse("@concat(addAndConcat(), '!')");
2930

30-
Assert.AreEqual(expectedResult, actualResult);
31+
ClassicAssert.AreEqual(expectedResult, actualResult);
3132
}
3233

3334
[TestCase]
3435
public void TestFunctionException()
3536
{
3637
const string expectedMessage = "fromFunctionName cannot end in ()";
3738

38-
var exception = Assert.Throws<ArgumentError>(() =>
39+
var exception = ClassicAssert.Throws<ArgumentError>(() =>
3940
{
4041
_serviceCollection.AddFunctionDefinition("addAndConcat()", "concat('result of 1+1 is: ', add(1,1))");
4142
});
4243

43-
Assert.NotNull(exception);
44-
Assert.AreEqual(expectedMessage,exception.Message);
44+
ClassicAssert.NotNull(exception);
45+
ClassicAssert.AreEqual(expectedMessage,exception.Message);
4546
}
4647
}
4748
}

Test/IndexTest.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using ExpressionEngine;
44
using ExpressionEngine.Functions.Base;
55
using Microsoft.Extensions.DependencyInjection;
6-
using NUnit.Framework;
6+
using NUnit.Framework;using NUnit.Framework.Legacy;
77

88
namespace Test
99
{
@@ -40,8 +40,8 @@ public async Task Test()
4040

4141
var output = await ee.ParseToValueContainer(str);
4242

43-
Assert.AreEqual(ValueType.Boolean, output.Type());
44-
Assert.AreEqual(true, output.GetValue<bool>());
43+
ClassicAssert.AreEqual(ValueType.Boolean, output.Type());
44+
ClassicAssert.AreEqual(true, output.GetValue<bool>());
4545
}
4646

4747
[Test]
@@ -52,8 +52,8 @@ public async Task Test1()
5252

5353
var output = await ee.ParseToValueContainer(str);
5454

55-
Assert.AreEqual(ValueType.Boolean, output.Type());
56-
Assert.AreEqual(true, output.GetValue<bool>());
55+
ClassicAssert.AreEqual(ValueType.Boolean, output.Type());
56+
ClassicAssert.AreEqual(true, output.GetValue<bool>());
5757
}
5858

5959
[Test]
@@ -64,8 +64,8 @@ public async Task Test2()
6464

6565
var output = await ee.ParseToValueContainer(str);
6666

67-
Assert.AreEqual(ValueType.Boolean, output.Type());
68-
Assert.AreEqual(true, output.GetValue<bool>());
67+
ClassicAssert.AreEqual(ValueType.Boolean, output.Type());
68+
ClassicAssert.AreEqual(true, output.GetValue<bool>());
6969
}
7070

7171
[Test]
@@ -76,8 +76,8 @@ public async Task Test3()
7676

7777
var output = await ee.ParseToValueContainer(str);
7878

79-
Assert.AreEqual(ValueType.Boolean, output.Type());
80-
Assert.AreEqual(true, output.GetValue<bool>());
79+
ClassicAssert.AreEqual(ValueType.Boolean, output.Type());
80+
ClassicAssert.AreEqual(true, output.GetValue<bool>());
8181
}
8282

8383
[Test]
@@ -88,8 +88,8 @@ public async Task Test4()
8888

8989
var output = await ee.ParseToValueContainer(str);
9090

91-
Assert.AreEqual(ValueType.Boolean, output.Type());
92-
Assert.AreEqual(true, output.GetValue<bool>());
91+
ClassicAssert.AreEqual(ValueType.Boolean, output.Type());
92+
ClassicAssert.AreEqual(true, output.GetValue<bool>());
9393
}
9494

9595

@@ -101,8 +101,8 @@ public async Task Test5()
101101

102102
var output = await ee.ParseToValueContainer(str);
103103

104-
Assert.AreEqual(ValueType.Object, output.Type());
105-
Assert.AreEqual("John Doe", output.AsDict()["name"].GetValue<string>());
104+
ClassicAssert.AreEqual(ValueType.Object, output.Type());
105+
ClassicAssert.AreEqual("John Doe", output.AsDict()["name"].GetValue<string>());
106106
}
107107

108108
[Test]
@@ -113,8 +113,8 @@ public async Task Test6()
113113

114114
var output = await ee.ParseToValueContainer(str);
115115

116-
Assert.AreEqual(ValueType.String, output.Type());
117-
Assert.AreEqual("John Doe", output.GetValue<string>());
116+
ClassicAssert.AreEqual(ValueType.String, output.Type());
117+
ClassicAssert.AreEqual("John Doe", output.GetValue<string>());
118118
}
119119

120120
[Test]
@@ -125,8 +125,8 @@ public async Task Test7()
125125

126126
var output = await ee.ParseToValueContainer(str);
127127

128-
Assert.AreEqual(ValueType.Object, output.Type());
129-
Assert.AreEqual("John Doe", output.AsDict()["name"].GetValue<string>());
128+
ClassicAssert.AreEqual(ValueType.Object, output.Type());
129+
ClassicAssert.AreEqual("John Doe", output.AsDict()["name"].GetValue<string>());
130130

131131
var t = new ValueContainer();
132132
}
@@ -140,8 +140,8 @@ public async Task Test8()
140140

141141
var output = await ee.ParseToValueContainer(str);
142142

143-
Assert.AreEqual(ValueType.String, output.Type());
144-
Assert.AreEqual("John Doe", output.GetValue<string>());
143+
ClassicAssert.AreEqual(ValueType.String, output.Type());
144+
ClassicAssert.AreEqual("John Doe", output.GetValue<string>());
145145
}
146146

147147
[Test]
@@ -152,8 +152,8 @@ public async Task Test9()
152152

153153
var output = await ee.ParseToValueContainer(str);
154154

155-
Assert.AreEqual(ValueType.String, output.Type());
156-
Assert.AreEqual("John Doe", output.GetValue<string>());
155+
ClassicAssert.AreEqual(ValueType.String, output.Type());
156+
ClassicAssert.AreEqual("John Doe", output.GetValue<string>());
157157
}
158158
}
159159
}

0 commit comments

Comments
 (0)