Skip to content

Commit

Permalink
Update csharp to .NET9 (#8138)
Browse files Browse the repository at this point in the history
* Update .NET version to 9.0
Update carter version to 9.0.0
Update carter code corresponding to the latest version of carter

* Update codebehind version to 3.9.2

* Update fastendpoint version to 5.33.0
Update fastendpoint code

* Update GenHTTP version to 9.4.0

* Update Simplify.Web version to 5.1.0

* Update csharp dockerfile to build .net9

---------

Co-authored-by: jeff.jf.wu <[email protected]>
  • Loading branch information
wuuer and jeff.jf.wu authored Jan 9, 2025
1 parent 2ac9a14 commit ac6f9d5
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 40 deletions.
4 changes: 2 additions & 2 deletions csharp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 as build
FROM mcr.microsoft.com/dotnet/sdk:9.0 as build

WORKDIR /usr/src/app

Expand All @@ -10,7 +10,7 @@ RUN dotnet restore
COPY . .
RUN dotnet publish -c release -o out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
FROM mcr.microsoft.com/dotnet/aspnet:9.0

WORKDIR /usr/src/app

Expand Down
2 changes: 1 addition & 1 deletion csharp/aspnet-minimal-api/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
framework:
website: docs.microsoft.com/en-us/aspnet/index
version: 8.0
version: 9.0
2 changes: 1 addition & 1 deletion csharp/aspnet-minimal-api/web.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion csharp/aspnet-mvc/web.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
8 changes: 5 additions & 3 deletions csharp/carter/HomeModule.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
namespace web
{
using Carter;
using System.Threading.Tasks;
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;

public class HomeModule : CarterModule
{
public HomeModule()
public override void AddRoutes(IEndpointRouteBuilder app)
{
Get("/", (req, res) => Task.CompletedTask);
app.MapGet("/", () => Task.CompletedTask);
}
}
}
16 changes: 8 additions & 8 deletions csharp/carter/UserModule.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
namespace web
{
using Carter;
using Carter.Request;
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;

public class UserModule : CarterModule
{
public UserModule()
public override void AddRoutes(IEndpointRouteBuilder app)
{
Get("/user/{id}", async(req, res) =>
app.MapGet("/user/{id}", async ([FromRoute] string id) =>
{
var id = req.RouteValues.As<string>("id");
await res.WriteAsync(id);
return id;
});

Post("/user", (req, res) => Task.CompletedTask);
app.MapPost("/user", () => Task.CompletedTask);
}
}
}
2 changes: 1 addition & 1 deletion csharp/carter/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
framework:
github: CarterCommunity/Carter
version: 5.2
version: 9.0
4 changes: 2 additions & 2 deletions csharp/carter/web.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>web</AssemblyName>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Carter" Version="5.2.*" />
<PackageReference Include="Carter" Version="9.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion csharp/codebehind/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
framework:
website: elanat.net
version: 3.6
version: 3.9.2
6 changes: 3 additions & 3 deletions csharp/codebehind/web.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CodeBehind" Version="3.6.*" />
<PackageReference Include="CodeBehind" Version="3.9.2" />
</ItemGroup>

</Project>
14 changes: 7 additions & 7 deletions csharp/fastendpoints/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,47 @@
app.UseFastEndpoints();
app.Run();

public class Home : Endpoint<object, object>
public class Home : EndpointWithoutRequest
{
public override void Configure()
{
Get("/");
AllowAnonymous();
}

public override Task HandleAsync(object _, CancellationToken __)
public override Task HandleAsync(CancellationToken __)
{
HttpContext.Response.StatusCode = StatusCodes.Status200OK;
return HttpContext.Response.WriteAsync("");
}
}

public class UserById : Endpoint<object, object>
public class UserById : EndpointWithoutRequest
{
public override void Configure()
{
Get("/user/{id}");
AllowAnonymous();
}

public override Task HandleAsync(object _, CancellationToken __)
public override Task HandleAsync(CancellationToken __)
{
HttpContext.Response.StatusCode = StatusCodes.Status200OK;
return HttpContext.Response.WriteAsync(
HttpContext.Request.RouteValues["id"].ToString());
}
}

public class User : Endpoint<object, object>
public class User : EndpointWithoutRequest
{
public override void Configure()
{
Post("/user");
AllowAnonymous();
Describe(x => x.Accepts<object>("*/*"));
Description(x => x.Accepts<object>("*/*"));
}

public override Task HandleAsync(object _, CancellationToken __)
public override Task HandleAsync(CancellationToken __)
{
HttpContext.Response.StatusCode = StatusCodes.Status200OK;
return HttpContext.Response.WriteAsync("");
Expand Down
2 changes: 1 addition & 1 deletion csharp/fastendpoints/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
framework:
website: fast-endpoints.com
version: 3.1
version: 5.33.0
4 changes: 2 additions & 2 deletions csharp/fastendpoints/web.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="3.1.*" />
<PackageReference Include="FastEndpoints" Version="5.33.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion csharp/genhttp/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
framework:
github: Kaliumhexacyanoferrat/GenHTTP
version: 9.1
version: 9.4
6 changes: 3 additions & 3 deletions csharp/genhttp/web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>

<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>web</AssemblyName>
<OutputType>Exe</OutputType>
Expand All @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GenHTTP.Core.Kestrel" Version="9.1.*" />
<PackageReference Include="GenHTTP.Modules.Functional" Version="9.1.*" />
<PackageReference Include="GenHTTP.Core.Kestrel" Version="9.4.0" />
<PackageReference Include="GenHTTP.Modules.Functional" Version="9.4.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion csharp/simplify.web/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
framework:
website: web.simplifynet.dev
version: 5.0
version: 5.1
4 changes: 2 additions & 2 deletions csharp/simplify.web/web.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Simplify.Web" Version="5.0.*" />
<PackageReference Include="Simplify.Web" Version="5.1.0" />
</ItemGroup>
</Project>

0 comments on commit ac6f9d5

Please sign in to comment.