Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: .net 8 and github issue 311 #313

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ on:

jobs:
test-linux:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: '0' # all
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v3
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '3.1.x'
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'
- name: Setup gitversion
run: dotnet tool install --global GitVersion.Tool
- name: Calculate version
Expand All @@ -32,18 +28,20 @@ jobs:
run: dotnet restore DynamicExpresso.sln
- name: Build
run: dotnet build DynamicExpresso.sln --no-restore -c Release /p:Version=${{steps.calc_version.outputs.PROJECT_VERSION}}
- name: Test .net core 3.1
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release --verbosity normal -f netcoreapp3.1
- name: Test .net core 7.0
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release --verbosity normal -f net7.0
- name: Test .net core 8.0
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release --verbosity normal -f net8.0
test-win:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore packages
run: dotnet restore DynamicExpresso.sln
- name: Build
Expand All @@ -52,3 +50,5 @@ jobs:
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release --verbosity normal -f net461
- name: Test .net 4.5
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release --verbosity normal -f net45
- name: Test .net core 8.0
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release --verbosity normal -f net8.0
16 changes: 7 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ on:
default: 'true'
jobs:
publish-nuget:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: "${{ github.event.inputs.ref }}"
fetch-depth: '0' # all
- name: Setup .NET Core 7.0
uses: actions/setup-dotnet@v3
- name: Setup .NET Core 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'
- name: Setup gitversion
run: dotnet tool install --global GitVersion.Tool
- name: Calculate version
Expand All @@ -35,10 +35,8 @@ jobs:
run: dotnet restore DynamicExpresso.sln
- name: Build
run: dotnet build DynamicExpresso.sln --no-restore -c Release /p:Version=${{steps.calc_version.outputs.PROJECT_VERSION}}
- name: Test .net core 3.1
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release /p:Version=${{steps.calc_version.outputs.PROJECT_VERSION}} --verbosity normal -f netcoreapp3.1
- name: Test .net core 7.0
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release /p:Version=${{steps.calc_version.outputs.PROJECT_VERSION}} --verbosity normal -f net7.0
- name: Test .net core 8.0
run: dotnet test DynamicExpresso.sln --no-build --no-restore -c Release /p:Version=${{steps.calc_version.outputs.PROJECT_VERSION}} --verbosity normal -f net8.0
- name: Setup nuget sources
run: dotnet nuget add source --name github "https://nuget.pkg.github.com/dynamicexpresso/index.json"
- name: Pack
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net5.0;netcoreapp3.1;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net5.0;net462</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
19 changes: 18 additions & 1 deletion test/DynamicExpresso.UnitTest/GithubIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static bool GetGFunction2(string arg)
Assert.Throws<ParseException>(() => interpreter.Eval("GFunction(arg)"));

// GFunction1 is used
// because gFunc1.Method.GetParameters()[0].HasDefaultValue == true
// because gFunc1.Method.GetParameters()[0].HasDefaultValue == true
// and gFunc2.Method.GetParameters()[0].HasDefaultValue == false
Assert.False((bool)interpreter.Eval("GFunction()"));
}
Expand Down Expand Up @@ -819,6 +819,23 @@ public void GitHub_Issue_305()
}

#endregion

[Test]
public void GitHub_Issue_311()
{
var a = "AABB";

var interpreter1 = new Interpreter();
interpreter1.SetVariable("a", a);
Assert.AreEqual("AA", interpreter1.Eval("a.Substring(0, 2)"));

var interpreter2 = new Interpreter().SetDefaultNumberType(DefaultNumberType.Decimal);
interpreter2.SetVariable("a", a);
// expected to throw because Substring is not defined for decimal
Assert.Throws<NoApplicableMethodException>(() => interpreter2.Eval("a.Substring(0, 2)"));
// It works if we cast to int
Assert.AreEqual("AA", interpreter2.Eval("a.Substring((int)0, (int)2)"));
}
}

internal static class GithubIssuesTestExtensionsMethods
Expand Down
2 changes: 1 addition & 1 deletion test/DynamicExpresso.UnitTest/MemberInvocationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void Indexer_Getter_MultiDimensional()
target.SetVariable("x", x);
var y = new MyTestService();
target.SetVariable("y", y);

Assert.AreEqual(x[1, 2], target.Eval("x[1, 2]"));
Assert.AreEqual(y[y.Today, 2], target.Eval("y[y.Today, 2]"));
Assert.AreEqual(y[y.Today], target.Eval("y[y.Today]"));
Expand Down
Loading