Skip to content

Commit

Permalink
feat: Support .NET 8.0 target
Browse files Browse the repository at this point in the history
Signed-off-by: sagilio <sagilio@outlook.com>
  • Loading branch information
sagilio committed Jul 9, 2023
1 parent 2884c22 commit 04b5605
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 249 deletions.
68 changes: 22 additions & 46 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,16 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET Core 3.1.x SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Setup .NET 5.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Setup .NET 6.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
include-prerelease: true

- name: Setup .NET 7.0.x SDK
uses: actions/setup-dotnet@v1
Expand Down Expand Up @@ -93,25 +89,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup .NET 3.1.x SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Setup .NET 5.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Setup .NET 6.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Setup .NET 7.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
include-prerelease: true

- name: Check .NET info
Expand Down Expand Up @@ -169,25 +155,15 @@ jobs:
- name: Check tags
run: git tag -l -n

- name: Setup .NET Core 3.1.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Setup .NET 5.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Setup .NET 6.0.x SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Setup .NET 7.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
include-prerelease: true

- name: Check .NET info
Expand Down
24 changes: 7 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,15 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET Core 3.1.x SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Setup .NET 5.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Setup .NET 6.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Setup .NET 7.0.x SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
include-prerelease: true

- name: Check .NET info
Expand Down
8 changes: 4 additions & 4 deletions Casbin.Benchmark/BuildInFunctionsBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace Casbin.Benchmark
{
[MemoryDiagnoser]
[BenchmarkCategory("Functions")]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.Net48)]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.NetCoreApp31, baseline: true)]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.Net60)]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.Net70)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net48)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net60, baseline: true)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net70)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net80)]
public class BuildInFunctionsBenchmark
{
public IEnumerable<object[]> KeyMatch4TestData() => new[]
Expand Down
4 changes: 2 additions & 2 deletions Casbin.Benchmark/Casbin.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection>
<TargetFrameworks>net7.0;net6.0;net5.0;netcoreapp3.1;net48</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net48</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.5"/>
</ItemGroup>

<ItemGroup>
Expand Down
29 changes: 17 additions & 12 deletions Casbin.Benchmark/DefaultPolicyManagerBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Casbin.Model;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Jobs;
using Casbin.Model;

namespace Casbin.Benchmark
{
[MemoryDiagnoser]
[BenchmarkCategory("Model")]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.Net48)]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.NetCoreApp31, baseline: true)]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.Net50)]
[SimpleJob(RunStrategy.Throughput, targetCount: 10, runtimeMoniker: RuntimeMoniker.Net60)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net48)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net60, baseline: true)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net70)]
[SimpleJob(RunStrategy.Throughput, RuntimeMoniker.Net80)]
public class DefaultPolicyManagerBenchmark
{
private readonly Enforcer _enforcer;
Expand All @@ -22,7 +22,8 @@ public class DefaultPolicyManagerBenchmark
public DefaultPolicyManagerBenchmark()
{
_enforcer = new Enforcer(TestHelper.GetTestFilePath("rbac_model.conf"));
_policyManager = (DefaultPolicyManager)_enforcer.Model.Sections.GetPolicyAssertion(PermConstants.DefaultPolicyType).PolicyManager;
_policyManager = (DefaultPolicyManager)_enforcer.Model.Sections
.GetPolicyAssertion(PermConstants.DefaultPolicyType).PolicyManager;
}

private string NowTestUserName { get; set; }
Expand All @@ -31,10 +32,10 @@ public DefaultPolicyManagerBenchmark()
private List<IPolicyValues> NowTestExistedPolicyList { get; set; } = new List<IPolicyValues>();
private List<IPolicyValues> NowTestNullPolicyList { get; set; } = new List<IPolicyValues>();

[Params(10, 100, 1000, 10000)]
public int NowPolicyCount { get; set; }
[Params(10, 100, 1000, 10000)] public int NowPolicyCount { get; set; }

[GlobalSetup(Targets = new[] {
[GlobalSetup(Targets = new[]
{
nameof(AddPolicyAsync), nameof(RemovePolicyAsync), nameof(UpdatePolicyAsync),
nameof(RemovePoliciesAsync), nameof(AddPoliciesAsync), nameof(UpdatePoliciesAsync)
})]
Expand All @@ -47,10 +48,13 @@ public void GlobalSetup()
int num = rd.Next(1000);
if (num == 0)
{
NowTestExistedPolicyList.Add(new PolicyValues<string, string, string>($"group{i}", $"obj{i / 10}", "read"));
NowTestNullPolicyList.Add(new PolicyValues<string, string, string>($"name{i}", $"data{i / 10}", "read"));
NowTestExistedPolicyList.Add(
new PolicyValues<string, string, string>($"group{i}", $"obj{i / 10}", "read"));
NowTestNullPolicyList.Add(
new PolicyValues<string, string, string>($"name{i}", $"data{i / 10}", "read"));
}
}

Console.WriteLine($"// Already set {NowPolicyCount} policies.");

NowTestUserName = $"name{NowPolicyCount / 2 + 1}";
Expand Down Expand Up @@ -78,7 +82,8 @@ public async Task RemovePolicyAsync()
[BenchmarkCategory("ModelManagement")]
public async Task UpdatePolicyAsync()
{
await _policyManager.UpdatePolicyAsync(NowTestPolicy, new PolicyValues<string, string, string>(NowTestUserName + "up", NowTestDataName + "up", "read"));
await _policyManager.UpdatePolicyAsync(NowTestPolicy,
new PolicyValues<string, string, string>(NowTestUserName + "up", NowTestDataName + "up", "read"));
}

[Benchmark]
Expand Down
Loading

0 comments on commit 04b5605

Please # to comment.