Skip to content

Commit 7a98d33

Browse files
committed
QoL Update
Add dotnet 9 & 10 as targets, update all used packages to their latest versions, and other minor QoL improvements
1 parent 1715b0f commit 7a98d33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+122
-57
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[*.cs]
2-
csharp_style_namespace_declarations=file_scoped:suggestion
2+
csharp_style_namespace_declarations=file_scoped:suggestion
3+
4+
# IDE0130: Namespace does not match folder structure
5+
dotnet_diagnostic.IDE0130.severity = none

.github/workflows/Publish OCPI.Net.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
- name: Checkout
2121
uses: actions/checkout@v2
2222

23+
- name: Setup dotnet
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: '10.x'
27+
2328
- name: Verify commit
2429
run: |
2530
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*

.github/workflows/Tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v2
17+
18+
- name: Setup dotnet
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '10.x'
1722

1823
- name: Install dependencies
1924
run: dotnet restore

OCPI.Net.sln

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.3.32804.467
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.0.11217.181 d18.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{91D87FDC-D1F0-483B-BB83-C24BD6A4699E}"
77
EndProject
@@ -25,6 +25,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OCPI.Net.Validation", "src\
2525
EndProject
2626
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OCPI.Net.Controllers", "src\OCPI.Net.Controllers\OCPI.Net.Controllers.csproj", "{46317B20-B640-4DD3-B70D-11F0A01BB11B}"
2727
EndProject
28+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{E1000500-0DF0-4430-BEFF-4741D5D64E9C}"
29+
ProjectSection(SolutionItems) = preProject
30+
.github\FUNDING.yml = .github\FUNDING.yml
31+
EndProjectSection
32+
EndProject
33+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{4A4418CF-DBD9-41A5-8389-E0ECA6CA9259}"
34+
ProjectSection(SolutionItems) = preProject
35+
.github\workflows\docs.yml = .github\workflows\docs.yml
36+
.github\workflows\Publish OCPI.Net.yml = .github\workflows\Publish OCPI.Net.yml
37+
.github\workflows\Tests.yml = .github\workflows\Tests.yml
38+
EndProjectSection
39+
EndProject
2840
Global
2941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3042
Debug|Any CPU = Debug|Any CPU
@@ -76,6 +88,7 @@ Global
7688
{F1752473-C636-4FE1-8D33-651C8B0953CA} = {91D87FDC-D1F0-483B-BB83-C24BD6A4699E}
7789
{609C4BF6-9DF2-4E9A-9993-0E372488B01F} = {91D87FDC-D1F0-483B-BB83-C24BD6A4699E}
7890
{46317B20-B640-4DD3-B70D-11F0A01BB11B} = {91D87FDC-D1F0-483B-BB83-C24BD6A4699E}
91+
{4A4418CF-DBD9-41A5-8389-E0ECA6CA9259} = {E1000500-0DF0-4430-BEFF-4741D5D64E9C}
7992
EndGlobalSection
8093
GlobalSection(ExtensibilityGlobals) = postSolution
8194
SolutionGuid = {1815709D-17EC-48E3-9911-103827F87498}

sample/OCPI.Net.Sample/OCPI.Net.Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<RootNamespace>OCPI.Sample</RootNamespace>

src/OCPI.Net.Contracts/OCPI.Net.Contracts.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>OCPI.Contracts</RootNamespace>

src/OCPI.Net.Controllers/Models/OcpiControllerBase.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@ public OkObjectResult OcpiOk([ActionResultObjectValue] object? value)
1616
{
1717
if (value is null) return base.Ok(new OcpiResponse());
1818

19-
if (value is PageResult valuePage)
19+
if (value is PageResult)
2020
{
21-
ConfigurePageResult(valuePage);
22-
return base.Ok(new OcpiResponse(valuePage.Data));
21+
throw new InvalidOperationException("This method was deprecated for PageResult types. Use OcpiOk<T>(PageResult<T> value) instead.");
2322
}
2423

2524
return base.Ok(new OcpiResponse(value));
2625
}
2726

27+
[NonAction]
28+
public OkObjectResult OcpiOk<T>([ActionResultObjectValue] PageResult<T> value)
29+
{
30+
ConfigurePageResult(value);
31+
return base.Ok(new OcpiResponse(value.Items));
32+
}
33+
2834
[NonAction]
2935
public void OcpiValidate<T>(T value, OcpiVersion forOcpiVersion)
3036
{
@@ -71,12 +77,17 @@ public void SetMaxLimit(PageRequest pageRequest, int max)
7177
HttpContext.Items["OcpiRequestMaxLimitValue"] = max;
7278
}
7379

74-
private void ConfigurePageResult(PageResult pageResult)
80+
private void ConfigurePageResult<T>(PageResult<T> pageResult)
7581
{
7682
if (HttpContext is null) return;
7783

84+
if (pageResult is not PageResult<T, OcpiPageRequest> typedPageResult)
85+
{
86+
throw new NotSupportedException("Unexpected PageRequest type.");
87+
}
88+
7889
var paginationService = GetRequiredService<PageResponseService>();
79-
paginationService.ConfigureResponse(pageResult);
90+
paginationService.ConfigureResponse(typedPageResult);
8091
}
8192

8293
private TService GetRequiredService<TService>()

src/OCPI.Net.Controllers/OCPI.Net.Controllers.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>OCPI</RootNamespace>

src/OCPI.Net.Controllers/Services/PageResponseService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ internal class PageResponseService(IHttpContextAccessor httpContextAccessor, Ocp
88
{
99
private readonly HttpContext _httpContext = httpContextAccessor.HttpContext!;
1010

11-
public void ConfigureResponse(PageResult pageResult)
11+
public void ConfigureResponse<TData, TRequest>(PageResult<TData, TRequest> pageResult)
12+
where TRequest : OcpiPageRequest
1213
{
1314
if (_httpContext is null) return;
1415

@@ -21,7 +22,8 @@ public void ConfigureResponse(PageResult pageResult)
2122
AddNextPageLink(pageResult);
2223
}
2324

24-
private void AddNextPageLink(PageResult pageResult)
25+
private void AddNextPageLink<TData, TRequest>(PageResult<TData, TRequest> pageResult)
26+
where TRequest : OcpiPageRequest
2527
{
2628
var fetched = pageResult.Request!.Offset!.Value + pageResult.Count!.Value;
2729
var limit = pageResult.Request!.Limit!.Value;

src/OCPI.Net.Core/OCPI.Net.Core.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>OCPI</RootNamespace>
@@ -20,8 +20,8 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="BitzArt.EnumToMemberValue" Version="1.0.0" />
24-
<PackageReference Include="BitzArt.Pagination" Version="1.14.0" />
23+
<PackageReference Include="BitzArt.EnumToMemberValue" Version="1.2.0" />
24+
<PackageReference Include="BitzArt.Pagination" Version="1.20.0" />
2525
</ItemGroup>
2626

2727
<ItemGroup>

0 commit comments

Comments
 (0)