From 3fc28a35783e9fd5e846f35de20036fb918b69dd Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Fri, 29 Jan 2021 20:41:30 +0100 Subject: [PATCH] Added .NET 5.0 support --- readme.md | 4 ++-- src/Server/BrokerControllerBase.cs | 2 +- src/Server/MvcBuilderExtensions.cs | 2 +- src/Server/Server.csproj | 6 +++++- src/UnitTests/FactsBase.cs | 2 +- src/UnitTests/UnitTests.csproj | 5 ++++- src/build.ps1 | 2 +- src/build.sh | 2 +- src/test.ps1 | 2 +- src/test.sh | 2 +- template/MyServiceBroker.csproj | 2 +- template/build.ps1 | 2 +- 12 files changed, 20 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index 6348506..5af34dc 100644 --- a/readme.md +++ b/readme.md @@ -13,7 +13,7 @@ The **[Client Library](#client-library)** allows you to call Service Brokers tha [![OpenServiceBroker.Server](https://img.shields.io/nuget/v/OpenServiceBroker.Server.svg)](https://www.nuget.org/packages/OpenServiceBroker.Server/) -Set up a regular ASP.NET Core 2.1 or 3.1 project and add the NuGet package [`OpenServiceBroker.Server`](https://www.nuget.org/packages/OpenServiceBroker.Server/). Then implement the following interfaces: +Set up a regular ASP.NET Core 2.1, 3.1 or 5.0 project and add the NuGet package [`OpenServiceBroker.Server`](https://www.nuget.org/packages/OpenServiceBroker.Server/). Then implement the following interfaces: - [`ICatalogService`](src/Server/Catalogs/ICatalogService.cs) (optionally also [`IETagProvider`](src/Server/Catalogs/IETagProvider.cs) and/or [`ILastModifiedProvider`](src/Server/Catalogs/ILastModifiedProvider.cs) on the same class) - either [`IServiceInstanceBlocking`](src/Server/Instances/IServiceInstanceBlocking.cs) or [`IServiceInstanceDeferred`](src/Server/Instances/IServiceInstanceDeferred.cs) or both - either [`IServiceBindingBlocking`](src/Server/Bindings/IServiceBindingBlocking.cs) or [`IServiceBindingDeferred`](src/Server/Bindings/IServiceBindingDeferred.cs) or both @@ -33,7 +33,7 @@ services.AddControllers() .AddOpenServiceBroker(); ``` -You can use the **[project template](template/)** to quickly set up a pre-configured ASP.NET Core 3.1 project with `OpenServiceBroker.Server`. +You can use the **[project template](template/)** to quickly set up a pre-configured ASP.NET Core 5.0 project with `OpenServiceBroker.Server`. ### Versioning diff --git a/src/Server/BrokerControllerBase.cs b/src/Server/BrokerControllerBase.cs index 6efeead..1c5842e 100644 --- a/src/Server/BrokerControllerBase.cs +++ b/src/Server/BrokerControllerBase.cs @@ -106,7 +106,7 @@ protected OriginatingIdentity? OriginatingIdentity { get { - string headerValue = Request.Headers[OriginatingIdentity.HttpHeaderName].FirstOrDefault(); + string? headerValue = Request.Headers[OriginatingIdentity.HttpHeaderName].FirstOrDefault(); return string.IsNullOrEmpty(headerValue) ? null : OriginatingIdentity.Parse(headerValue); } } diff --git a/src/Server/MvcBuilderExtensions.cs b/src/Server/MvcBuilderExtensions.cs index 0b8aeb7..b00d798 100644 --- a/src/Server/MvcBuilderExtensions.cs +++ b/src/Server/MvcBuilderExtensions.cs @@ -20,7 +20,7 @@ public static IMvcBuilder AddOpenServiceBroker(this IMvcBuilder builder) { builder.AddApplicationPart(typeof(CatalogController).Assembly); -#if NETCOREAPP3_1 +#if !NETSTANDARD2_0 builder.AddNewtonsoftJson(); #endif diff --git a/src/Server/Server.csproj b/src/Server/Server.csproj index fb68762..bd5acaf 100644 --- a/src/Server/Server.csproj +++ b/src/Server/Server.csproj @@ -5,7 +5,7 @@ OpenServiceBroker.Server OpenServiceBroker 8.0 - netstandard2.0;netcoreapp3.1 + netstandard2.0;netcoreapp3.1;net5.0 True True $(NoWarn);1591 @@ -49,5 +49,9 @@ + + + + diff --git a/src/UnitTests/FactsBase.cs b/src/UnitTests/FactsBase.cs index c3d46fc..8f6e782 100644 --- a/src/UnitTests/FactsBase.cs +++ b/src/UnitTests/FactsBase.cs @@ -26,7 +26,7 @@ protected FactsBase() .AddMvc() .AddOpenServiceBroker()) .Configure(x => x.UseMvc())); -#elif NETCOREAPP3_1 +#else .ConfigureServices(x => x.AddScoped(_ => Mock.Object) .AddControllers() diff --git a/src/UnitTests/UnitTests.csproj b/src/UnitTests/UnitTests.csproj index f4c311d..5db61da 100644 --- a/src/UnitTests/UnitTests.csproj +++ b/src/UnitTests/UnitTests.csproj @@ -5,7 +5,7 @@ OpenServiceBroker.UnitTests OpenServiceBroker 8.0 - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 Library False False @@ -32,6 +32,9 @@ + + + diff --git a/src/build.ps1 b/src/build.ps1 index c45f2fb..0099dbe 100644 --- a/src/build.ps1 +++ b/src/build.ps1 @@ -6,7 +6,7 @@ function Run-DotNet { if (Get-Command dotnet -ErrorAction SilentlyContinue) { dotnet @args } else { - ..\0install.ps1 run --batch --version 3.1..!3.2 https://apps.0install.net/dotnet/core-sdk.xml @args + ..\0install.ps1 run --batch --version 5.0..!5.1 https://apps.0install.net/dotnet/core-sdk.xml @args } if ($LASTEXITCODE -ne 0) {throw "Exit Code: $LASTEXITCODE"} } diff --git a/src/build.sh b/src/build.sh index 8ac46f9..6de7115 100755 --- a/src/build.sh +++ b/src/build.sh @@ -6,7 +6,7 @@ cd `dirname $0` if command -v dotnet > /dev/null 2> /dev/null; then dotnet="dotnet" else - dotnet="../0install.sh run --version 3.1..!3.2 https://apps.0install.net/dotnet/core-sdk.xml" + dotnet="../0install.sh run --version 5.0..!5.1 https://apps.0install.net/dotnet/core-sdk.xml" fi # Build diff --git a/src/test.ps1 b/src/test.ps1 index 0bb2242..85276f5 100644 --- a/src/test.ps1 +++ b/src/test.ps1 @@ -5,7 +5,7 @@ function Run-DotNet { if (Get-Command dotnet -ErrorAction SilentlyContinue) { dotnet @args } else { - ..\0install.ps1 run --batch --version 3.1..!3.2 https://apps.0install.net/dotnet/core-sdk.xml @args + ..\0install.ps1 run --batch --version 5.0..!5.1 https://apps.0install.net/dotnet/core-sdk.xml @args } if ($LASTEXITCODE -ne 0) {throw "Exit Code: $LASTEXITCODE"} } diff --git a/src/test.sh b/src/test.sh index 987d896..a928af3 100755 --- a/src/test.sh +++ b/src/test.sh @@ -6,7 +6,7 @@ cd `dirname $0` if command -v dotnet > /dev/null 2> /dev/null; then dotnet="dotnet" else - dotnet="../0install.sh run --version 3.1..!3.2 https://apps.0install.net/dotnet/core-sdk.xml" + dotnet="../0install.sh run --version 5.0..!5.1 https://apps.0install.net/dotnet/core-sdk.xml" fi # Unit tests diff --git a/template/MyServiceBroker.csproj b/template/MyServiceBroker.csproj index a3e8d78..bf5db93 100644 --- a/template/MyServiceBroker.csproj +++ b/template/MyServiceBroker.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 enable True $(NoWarn);1591 diff --git a/template/build.ps1 b/template/build.ps1 index 02f34e9..4361a4b 100644 --- a/template/build.ps1 +++ b/template/build.ps1 @@ -6,7 +6,7 @@ function Run-DotNet { if (Get-Command dotnet -ErrorAction SilentlyContinue) { dotnet @args } else { - ..\0install.ps1 run --batch --version 3.1..!3.2 https://apps.0install.net/dotnet/core-sdk.xml @args + ..\0install.ps1 run --batch --version 5.0..!5.1 https://apps.0install.net/dotnet/core-sdk.xml @args } if ($LASTEXITCODE -ne 0) {throw "Exit Code: $LASTEXITCODE"} }