Skip to content

Commit

Permalink
Added .NET 5.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Jan 29, 2021
1 parent 3e29875 commit 3fc28a3
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Server/BrokerControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Server/MvcBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion src/Server/Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyName>OpenServiceBroker.Server</AssemblyName>
<RootNamespace>OpenServiceBroker</RootNamespace>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand Down Expand Up @@ -49,5 +49,9 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.11" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.11" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/UnitTests/FactsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected FactsBase()
.AddMvc()
.AddOpenServiceBroker())
.Configure(x => x.UseMvc()));
#elif NETCOREAPP3_1
#else
.ConfigureServices(x
=> x.AddScoped(_ => Mock.Object)
.AddControllers()
Expand Down
5 changes: 4 additions & 1 deletion src/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyName>OpenServiceBroker.UnitTests</AssemblyName>
<RootNamespace>OpenServiceBroker</RootNamespace>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<OutputType>Library</OutputType>
<IsPackable>False</IsPackable>
<DeterministicSourcePaths>False</DeterministicSourcePaths>
Expand All @@ -32,6 +32,9 @@
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.9" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.2" />
</ItemGroup>

<!-- Mark as unit test project -->
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
}
Expand Down
2 changes: 1 addition & 1 deletion src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion template/MyServiceBroker.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion template/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
}
Expand Down

0 comments on commit 3fc28a3

Please sign in to comment.