Skip to content

Commit

Permalink
.net 8.0 migration
Browse files Browse the repository at this point in the history
nuget upd
github actions upd
readme upd
  • Loading branch information
NikolayKorsakov committed Dec 19, 2024
1 parent a160634 commit 3339596
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 112 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
uses: actions/checkout@v2

- name: install dotnet
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: '3.1.x'
dotnet-version: 8.0.x

- name: install packages
run: dotnet restore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
uses: actions/checkout@v2

- name: install dotnet
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: '3.1.x'
dotnet-version: 8.0.x

- name: install packages
run: dotnet restore
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@master

- name: install dotnet
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.x
dotnet-version: 8.0.x

- name: build
run: dotnet build
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ A detailed overview on how to contribute can be found in the [contributing guide
Make sure you have installed all of the following prerequisites on your development machine:

- Git - [Download & Install Git](https://git-scm.com/downloads). OSX and Linux machines typically have this already installed.
- .NET Core (version 3.1 or higher) - [Download & Install .NET Core](https://dotnet.microsoft.com/download/dotnet-core/3.1).
- .NET (version 8.0 or higher) - [Download & Install .NET Core](https://dotnet.microsoft.com/download/dotnet/8.0).
## General folders layout

Expand All @@ -116,4 +116,4 @@ Make sure you have installed all of the following prerequisites on your developm

# Maintainers

[github.maintain@byndyusoft.com](mailto:github.maintain@byndyusoft.com)
[github.maintain@byndyusoft.com](mailto:github.maintain@byndyusoft.com)
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
57 changes: 35 additions & 22 deletions example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
using Microsoft.AspNetCore.Hosting;
using Asp.Versioning;
using Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack.Swagger;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack
{
/// <summary>
/// Program
/// </summary>
public static class Program
{
/// <summary>
/// Main
/// </summary>
public static void Main(string[] args)
var builder = WebApplication.CreateBuilder(args);

var services = builder.Services;
services
.AddApiVersioning(
options =>
{
CreateHostBuilder(args).Build().Run();
options.DefaultApiVersion = ApiVersion.Default;
options.AssumeDefaultVersionWhenUnspecified = true;
options.ReportApiVersions = true;
}

private static IHostBuilder CreateHostBuilder(string[] args)
)
.AddApiExplorer(
options =>
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
}
}
}
);

services.AddSwagger();

services
.AddMvcCore()
.AddMessagePackFormatters()
.AddFormatterMappings();
services.AddControllers();

var app = builder.Build();
if (app.Environment.IsProduction() == false)
app.UseSwaggerWithApiVersionDescriptionProvider();

app.MapControllers();
app.UseRouting();
app.Run();
54 changes: 0 additions & 54 deletions example/Startup.cs

This file was deleted.

11 changes: 6 additions & 5 deletions example/Swagger/ApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Asp.Versioning.ApiExplorer;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.SwaggerUI;

namespace Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack.Swagger
Expand All @@ -12,10 +13,10 @@ public static class ApplicationBuilderExtensions
/// <summary>
/// UseSwagger
/// </summary>
public static IApplicationBuilder UseSwagger(
this IApplicationBuilder builder,
IApiVersionDescriptionProvider apiVersionDescriptionProvider)
public static IApplicationBuilder UseSwaggerWithApiVersionDescriptionProvider(
this IApplicationBuilder builder)
{
var apiVersionDescriptionProvider = builder.ApplicationServices.GetService<IApiVersionDescriptionProvider>()!;
builder.UseSwagger()
.UseSwaggerUI(options =>
{
Expand Down
4 changes: 2 additions & 2 deletions example/Swagger/ConfigureSwaggerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.IO;
using System.Reflection;
using Asp.Versioning.ApiExplorer;

namespace Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack.Swagger
{
Expand Down
17 changes: 11 additions & 6 deletions src/Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<IsPackable>true</IsPackable>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<RootNamespace>Microsoft.AspNetCore.Mvc</RootNamespace>
<Version>0.3.1</Version>
<Version>0.4.0</Version>
<PackageId>Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack</PackageId>
<Title>Byndyusoft.AspNetCore.Mvc.Formatters.MessagePack</Title>
<Authors>Byndyusoft</Authors>
Expand All @@ -14,17 +14,22 @@
<RepositoryType>git</RepositoryType>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<None Include="..\icon.png" Pack="true" PackagePath="icon.png" />

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Byndyusoft.Net.Http.MessagePack" Version="0.5.1" />
<PackageReference Include="Byndyusoft.Net.Http.MessagePack" Version="0.6.0" />
</ItemGroup>

<ItemGroup>
<None Include="..\icon.png" Pack="true" PackagePath="icon.png" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Formatters/MessagePackOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ internal MessagePackOutputFormatter(MessagePackSerializerOptions serializerOptio
{
SerializerOptions = Guard.NotNull(serializerOptions, nameof(serializerOptions));

SupportedMediaTypes.Add(MessagePackDefaults.MediaTypes.ApplicationXMessagePack);
SupportedMediaTypes.Add(MessagePackDefaults.MediaTypes.ApplicationMessagePack);
SupportedMediaTypes.Add(MessagePackDefaults.MediaTypes.ApplicationXMessagePack);
}


Expand Down
2 changes: 1 addition & 1 deletion src/MvcMessagePackOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public MvcMessagePackOptions()
_allowInputFormatterExceptionMessages =
new CompatibilitySwitch<bool>(nameof(AllowInputFormatterExceptionMessages));

SupportedMediaTypes.Add(MessagePackDefaults.MediaTypes.ApplicationXMessagePack);
SupportedMediaTypes.Add(MessagePackDefaults.MediaTypes.ApplicationMessagePack);
SupportedMediaTypes.Add(MessagePackDefaults.MediaTypes.ApplicationXMessagePack);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Byndyusoft.AspNetCore.Mvc.Formatters</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 3339596

Please sign in to comment.