Skip to content

Commit

Permalink
feat: .net7.0 support (#604)
Browse files Browse the repository at this point in the history
Support for .NET 7.0
  • Loading branch information
AndrewTriesToCode committed Oct 23, 2022
1 parent 0628b0f commit 4d7d54d
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 26 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/linux-7.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Linux (.NET 7.0)

on:
push:
branches: [main]
pull_request_target:

jobs:
os-tests:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
env:
DOTNET_INSTALL_DIR: /usr/share/dotnet
- name: test Finbuckle.MultiTenanant
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test

26 changes: 26 additions & 0 deletions .github/workflows/macos-7.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: MacOS (.NET 7.0)

on:
push:
branches: [main]
pull_request_target:

jobs:
os-tests:
runs-on: macos-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
- name: test Finbuckle.MultiTenanant
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test
2 changes: 1 addition & 1 deletion .github/workflows/nuget-push-public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '7.0.x'
env:
DOTNET_INSTALL_DIR: /usr/share/dotnet
- name: Create the package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '7.0.x'
env:
DOTNET_INSTALL_DIR: /usr/share/dotnet
- name: build and test
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/windows-7.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Windows (.NET 7.0)

on:
push:
branches: [main]
pull_request_target:

jobs:
os-tests:
runs-on: windows-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
env:
DOTNET_INSTALL_DIR: 'C:\Program Files\dotnet'
- name: test Finbuckle.MultiTenanant
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f net7.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test
7 changes: 0 additions & 7 deletions global.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<Title>Finbuckle.MultiTenant.AspNetCore</Title>
<Description>ASP.NET Core support for Finbuckle.MultiTenant.</Description>
<Nullable>enable</Nullable>
Expand All @@ -13,6 +13,12 @@
</ItemGroup>

<Choose>
<When Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.*-*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net6.0' ">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netstandard2.1</TargetFrameworks>
<Title>Finbuckle.MultiTenant.EntityFrameworkCore</Title>
<Description>Entity Framework Core support for Finbuckle.MultiTenant.</Description>
<Nullable>enable</Nullable>
Expand All @@ -13,6 +13,13 @@
</ItemGroup>

<Choose>
<When Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="7.0.*-*" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.*-*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net6.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public FinbuckleMultiTenantBuilder<TTenantInfo> WithPerTenantNamedOptions<TOptio
private static MultiTenantOptionsManager<TOptions> BuildOptionsManager<TOptions>(IServiceProvider sp)
where TOptions : class, new()
{
var cache = ActivatorUtilities.CreateInstance(sp, typeof(MultiTenantOptionsCache<TOptions, TTenantInfo>));
var cache = (IOptionsMonitorCache<TOptions>)ActivatorUtilities.CreateInstance(sp, typeof(MultiTenantOptionsCache<TOptions, TTenantInfo>));
return (MultiTenantOptionsManager<TOptions>)
ActivatorUtilities.CreateInstance(sp, typeof(MultiTenantOptionsManager<TOptions>), new[] { cache });
ActivatorUtilities.CreateInstance(sp, typeof(MultiTenantOptionsManager<TOptions>), cache);
}

/// <summary>
Expand Down
13 changes: 12 additions & 1 deletion src/Finbuckle.MultiTenant/Finbuckle.MultiTenant.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netstandard2.1</TargetFrameworks>
<Title>Finbuckle.MultiTenant</Title>
<Description>Main library package for Finbuckle.MultiTenant.</Description>
<Nullable>enable</Nullable>
Expand All @@ -12,6 +12,17 @@
</ItemGroup>

<Choose>
<When Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="7.0.*-*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net6.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Moq;
Expand Down Expand Up @@ -418,6 +419,7 @@ public void ConfigurePerTenantAuthenticationConventions_UseDefaultChallengeSchem
public void ConfigurePerTenantAuthentication_UseOpenIdConnectConvention()
{
var services = new ServiceCollection();
services.AddSingleton<IConfiguration>((new ConfigurationBuilder()).Build()); // net7.0+
services.AddOptions();
services.AddAuthentication().AddOpenIdConnect();
services.AddMultiTenant<TestTenantInfo>()
Expand Down Expand Up @@ -448,6 +450,7 @@ public void ConfigurePerTenantAuthentication_UseOpenIdConnectConvention()
public void ConfigurePerTenantAuthenticationConventions_UseOpenIdConnectConvention()
{
var services = new ServiceCollection();
services.AddSingleton<IConfiguration>((new ConfigurationBuilder()).Build()); // net7.0+
services.AddOptions();
services.AddAuthentication().AddOpenIdConnect();
services.AddMultiTenant<TestTenantInfo>()
Expand Down Expand Up @@ -478,6 +481,7 @@ public void ConfigurePerTenantAuthenticationConventions_UseOpenIdConnectConventi
public void ConfigurePerTenantAuthenticationConventions_UseDefaultOpenIdConnectOptionsIfNoTenantProp()
{
var services = new ServiceCollection();
services.AddSingleton<IConfiguration>((new ConfigurationBuilder()).Build()); // net7.0+
var defaultValue = "https://defaultValue";
services.AddOptions().AddAuthentication()
.AddOpenIdConnect(options =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -17,16 +17,22 @@
</ItemGroup>

<Choose>
<When Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.*-*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net6.0' ">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.8" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.28" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.*" />
</ItemGroup>
</When>
</Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public class DynamicModelCacheKeyFactory : IModelCacheKeyFactory
{
public object Create(DbContext context)
{
// Needed for tests that change the model.
return new object();
}

public object Create(DbContext context, bool designTime)
{
return new object();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public class Post
public class DynamicModelCacheKeyFactory : IModelCacheKeyFactory
{
public object Create(DbContext context)
{
return new object();
}

public object Create(DbContext context, bool designTime)
{
// Needed for tests that change the model.
return new object();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -12,6 +12,12 @@
</ItemGroup>

<Choose>
<When Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="7.0.*-*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net6.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.8" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public class Post
public class DynamicModelCacheKeyFactory : IModelCacheKeyFactory
{
public object Create(DbContext context)
{
return new object();
}

public object Create(DbContext context, bool designTime)
{
return new Object(); // Never cache!
}
Expand Down
21 changes: 14 additions & 7 deletions test/Finbuckle.MultiTenant.Test/Finbuckle.MultiTenant.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -13,18 +13,25 @@
</ItemGroup>

<Choose>
<When Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="7.0.*-*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net6.0' ">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.*" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.*" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="6.0.*" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.28" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.28" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="3.1.28" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.*" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.*" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="3.1.*" />
</ItemGroup>
</When>
</Choose>
Expand Down

0 comments on commit 4d7d54d

Please sign in to comment.