diff --git a/.github/workflows/dotnet-test.yml b/.github/workflows/dotnet-test.yml new file mode 100644 index 0000000..e7034a0 --- /dev/null +++ b/.github/workflows/dotnet-test.yml @@ -0,0 +1,27 @@ +name: .NET + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore src + - name: Build Lib + run: dotnet build src/NReco.LambdaParser -property:TargetFrameworks=netstandard2.0 --no-restore + - name: Build Tests + run: dotnet build src/NReco.LambdaParser.Tests --no-restore + - name: Test + run: dotnet test src/NReco.LambdaParser.Tests --no-build --verbosity normal diff --git a/README.md b/README.md index a08c072..b534e09 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # NReco LambdaParser Runtime parser for string expressions (formulas, method calls, properties/fields/arrays accessors). `LambdaParser` builds dynamic LINQ expression tree and compiles it to the lambda delegate. Types are resolved at run-time like in dynamic languages. -[![NuGet Release](https://img.shields.io/nuget/v/NReco.LambdaParser.svg)](https://www.nuget.org/packages/NReco.LambdaParser/) | [![AppVeyor](https://img.shields.io/appveyor/ci/nreco/lambdaparser/master.svg)](https://ci.appveyor.com/project/nreco/lambdaparser) +[![NuGet Release](https://img.shields.io/nuget/v/NReco.LambdaParser.svg)](https://www.nuget.org/packages/NReco.LambdaParser/) | [![AppVeyor](https://img.shields.io/appveyor/ci/nreco/lambdaparser/master.svg)](https://ci.appveyor.com/project/nreco/lambdaparser) | ![Tests](https://github.com/nreco/data/actions/workflows/dotnet-test.yml/badge.svg) * can be used in *any* .NET app: net45 (legacy .NET Framework apps), netstandard1.3 (.NET Core apps), netstandard2.0 (all modern .NET apps). * any number of expression arguments (values can be provided as dictionary or by callback delegate) diff --git a/appveyor.yml b/appveyor.yml index 56fdbbe..9e08dd7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.{build} -os: Visual Studio 2019 +os: Visual Studio 2022 branches: only: diff --git a/src/NReco.LambdaParser.Tests/LambdaParserTests.cs b/src/NReco.LambdaParser.Tests/LambdaParserTests.cs index 199c7e9..6acc4ca 100644 --- a/src/NReco.LambdaParser.Tests/LambdaParserTests.cs +++ b/src/NReco.LambdaParser.Tests/LambdaParserTests.cs @@ -129,24 +129,30 @@ public void Eval() { Assert.Equal(new TimeSpan(1,0,0,0).Negate(), lambdaParser.Eval("oneDay - twoDays", varContext)); Assert.Equal(new TimeSpan(1,0,0,0).Negate(), lambdaParser.Eval("-twoDays + oneDay", varContext)); + + } + + [Fact] + public void OptionsParams() { //Use new invoker - lambdaParser = new LambdaParser(OptionsParamsInvokeMethod.Instance); + var lambdaParser = new LambdaParser(OptionsParamsInvokeMethod.Instance); + var varContext = getContext(); Assert.True((bool)lambdaParser.Eval("testObj.OptionalParam(true,true)", varContext)); - Assert.False((bool)lambdaParser.Eval("testObj.OptionalParam(true,true,false)", varContext)); + Assert.False((bool)lambdaParser.Eval("testObj.OptionalParam(true,true,false)", varContext)); - Assert.True((bool)lambdaParser.Eval("testObj.OptionalParam2(true,true)", varContext)); - Assert.False((bool)lambdaParser.Eval("testObj.OptionalParam2(true,true,true,\"fail\")", varContext)); + Assert.True((bool)lambdaParser.Eval("testObj.OptionalParam2(true,true)", varContext)); + Assert.False((bool)lambdaParser.Eval("testObj.OptionalParam2(true,true,true,\"fail\")", varContext)); - Assert.True((bool)lambdaParser.Eval("testObj.TestShadowMethod()", varContext)); + Assert.True((bool)lambdaParser.Eval("testObj.TestShadowMethod()", varContext)); Assert.True((bool)lambdaParser.Eval("testObj.TestShadowProperty", varContext)); - Assert.Equal("Test123ThisIsaTest",(string)lambdaParser.Eval("testObj.ParamMethodTest(\"Test\",123,\"This\",\"Is\",\"a\",\"Test\")", varContext)); - Assert.Equal("Today is Saturday, Day 9 of December",lambdaParser.Eval("testObj.Format(\"Today is {0}, Day {1} of {2}\",\"Saturday\",9,\"December\")", varContext)); - + Assert.Equal("Test123ThisIsaTest", (string)lambdaParser.Eval("testObj.ParamMethodTest(\"Test\",123,\"This\",\"Is\",\"a\",\"Test\")", varContext)); + Assert.Equal("Today is Saturday, Day 9 of December", lambdaParser.Eval("testObj.Format(\"Today is {0}, Day {1} of {2}\",\"Saturday\",9,\"December\")", varContext)); } + [Fact] public void SingleEqualSign() { var varContext = getContext(); diff --git a/src/NReco.LambdaParser.Tests/NReco.LambdaParser.Tests.csproj b/src/NReco.LambdaParser.Tests/NReco.LambdaParser.Tests.csproj index 3abe7e3..48210b6 100644 --- a/src/NReco.LambdaParser.Tests/NReco.LambdaParser.Tests.csproj +++ b/src/NReco.LambdaParser.Tests/NReco.LambdaParser.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 false @@ -10,9 +10,9 @@ - - - + + + \ No newline at end of file