Skip to content

Commit

Permalink
feat: add .NET 6 support (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewTriesToCode authored Nov 8, 2021
1 parent 52ce1df commit a2d0416
Show file tree
Hide file tree
Showing 26 changed files with 234 additions and 158 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/linux-3.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ jobs:
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet 3.1.x
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
dotnet-version: '6.0'
include-prerelease: true
env:
DOTNET_INSTALL_DIR: /usr/share/dotnet
- name: test Finbuckle.MultiTenanant
run: dotnet test -f netcoreapp3.1
working-directory: ./test/Finbuckle.MultiTenant.Test
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/linux-5.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ jobs:
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet 5.0.x
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: '6.0'
include-prerelease: true
env:
DOTNET_INSTALL_DIR: /usr/share/dotnet
- name: test Finbuckle.MultiTenanant
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f .net5.0
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f .net5.0
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test

29 changes: 14 additions & 15 deletions .github/workflows/pr-check.yml → .github/workflows/linux-6.0.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
name: Pull Request Checks
name: Linux (.NET 6.0)

on: [workflow_dispatch]
on:
push:
branches: [main]
pull_request:

jobs:
os-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet 5.0.x
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: setup dotnet 3.1.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
dotnet-version: '6.0'
include-prerelease: true
env:
DOTNET_INSTALL_DIR: /usr/share/dotnet
- name: test Finbuckle.MultiTenanant
run: dotnet test
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test

5 changes: 3 additions & 2 deletions .github/workflows/macos-3.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ jobs:
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet 3.1.x
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
dotnet-version: '6.0'
include-prerelease: true
- name: test Finbuckle.MultiTenanant
run: dotnet test -f netcoreapp3.1
working-directory: ./test/Finbuckle.MultiTenant.Test
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/macos-5.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ jobs:
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet 5.0.x
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: '6.0'
include-prerelease: true
- name: test Finbuckle.MultiTenanant
run: dotnet test -f .net5.0
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f .net5.0
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f .net5.0
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test
27 changes: 27 additions & 0 deletions .github/workflows/macos-6.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: MacOS (.NET 6.0)

on:
push:
branches: [main]
pull_request:

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: '6.0'
include-prerelease: true
- name: test Finbuckle.MultiTenanant
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test
7 changes: 5 additions & 2 deletions .github/workflows/windows-3.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ jobs:
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet 3.1.x
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
dotnet-version: '6.0'
include-prerelease: true
env:
DOTNET_INSTALL_DIR: 'C:\Program Files\dotnet'
- name: test Finbuckle.MultiTenanant
run: dotnet test -f netcoreapp3.1
working-directory: ./test/Finbuckle.MultiTenant.Test
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/windows-5.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ jobs:
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: setup dotnet 5.0.x
- name: setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
dotnet-version: '6.0'
include-prerelease: true
env:
DOTNET_INSTALL_DIR: 'C:\Program Files\dotnet'
- name: test Finbuckle.MultiTenanant
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f net5.0
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f net5.0
run: dotnet test -f net5.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test
29 changes: 29 additions & 0 deletions .github/workflows/windows-6.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Windows (.NET 6.0)

on:
push:
branches: [main]
pull_request:

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: '6.0'
include-prerelease: true
env:
DOTNET_INSTALL_DIR: 'C:\Program Files\dotnet'
- name: test Finbuckle.MultiTenanant
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.Test
- name: test Finbuckle.MultiTenanant.AspNetCore
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.AspNetCore.Test
- name: test Finbuckle.MultiTenanant.EntityFrameworkCore
run: dotnet test -f net6.0
working-directory: ./test/Finbuckle.MultiTenant.EntityFrameworkCore.Test
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@

Finbuckle.MultiTenant is open source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation. See [https://www.finbuckle.com/multitenant](https://www.finbuckle.com/multitenant) for more details and documentation.


## Main Build and Test Status

![Build Status Linux 3.1](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/linux-3.1.yml/badge.svg)
![Build Status MacOS 3.1](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/macos-3.1.yml/badge.svg?)
![Build Status Windows 3.1](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/windows-3.1.yml/badge.svg)
![Build Status Linux 6.0](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/linux-6.0.yml/badge.svg)
![Build Status MacOS 6.0](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/macos-6.0.yml/badge.svg)
![Build Status Windows 6.0](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/windows-6.0.yml/badge.svg)

![Build Status Linux 5.0](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/linux-5.0.yml/badge.svg)
![Build Status MacOS 5.0](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/macos-5.0.yml/badge.svg)
![Build Status Windows 5.0](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/windows-5.0.yml/badge.svg)

![Build Status Linux 3.1](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/linux-3.1.yml/badge.svg)
![Build Status MacOS 3.1](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/macos-3.1.yml/badge.svg?)
![Build Status Windows 3.1](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/windows-3.1.yml/badge.svg)

## License

This project uses the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0). See [LICENSE](LICENSE) file for license information.
Expand Down Expand Up @@ -71,10 +74,9 @@ Finally, in the `Configure` method call `UseMultiTenant()` to register the middl
public void Configure(IApplicationBuilder app)
{
...
app.UseMultiTenant(); // Before UseMvc!
app.UseMultiTenant(); // Before UseEndpoints!
...
//app.UseMvc(); // for .NET Core 3.1
app.UseEndpoints(...); // for .NET 5.0+
app.UseEndpoints(...);
}
```

Expand Down Expand Up @@ -102,13 +104,13 @@ See [Stores](https://www.finbuckle.com/MultiTenant/Docs/Stores) for more informa

Finbuckle.MultiTenant comes with a collection of strategies and store types that can be mixed and matched in various ways.

`app.UseEndPoints`
`app.MultiTenant()`

This line configures the middleware which resolves the tenant using the registered strategies, stores, and other settings. Be sure to call it before calling `UseEndpoints` and other middleware which will use per-tenant functionality, e.g. `UseAuthentication`.
This line configures the middleware which resolves the tenant using the registered strategies, stores, and other settings. Be sure to call it before calling `UseEndpoints()` and other middleware which will use per-tenant functionality, e.g. `UseAuthentication()`.

### Basic Usage

With the services and middleware configured, access information for the current tenant from the `TenantInfo` property on the `MultiTenantContext` object accessed from the `GetMultiTenantContext<T>` extension method:
With the services and middleware configured, access information for the current tenant from the `TenantInfo` property on the `MultiTenantContext<T>` object accessed from the `GetMultiTenantContext<T>` extension method:

```cs
var tenantInfo = HttpContext.GetMultiTenantContext<TenantInfo>().TenantInfo;
Expand Down
4 changes: 2 additions & 2 deletions docs/EFCore.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ for the current tenant.

## Deriving from MultiTenantDbContext
This approach is easier bit requires inheriting from `MultiTenantDbContext` which
may not alway be possible. It is simply a pre-configured implementation of
may not always be possible. It is simply a pre-configured implementation of
`IMultiTenantDbContext` with the helper methods as described below in
(Adding MultiTenant Functionality to an Existing DbContext)
[#adding-multitenant-functionality-to-an-existing-dbcontext]
Expand Down Expand Up @@ -359,7 +359,7 @@ By default attempting to add or update an entity with a different `TenantId` pro

## Tenant Not Set Mode

If the `TenantId` on an entity is manually set to null the default behavior is to overwrite the `TenantId` for adde entities or to throw a `MultiTenantException` for updated entities. This occurs during a call to `SaveChanges` or `SaveChangesAsync`. This behavior can be changed by setting the `TenantNotSetMode' property on the database context:
If the `TenantId` on an entity is manually set to null the default behavior is to overwrite the `TenantId` for added entities or to throw a `MultiTenantException` for updated entities. This occurs during a call to `SaveChanges` or `SaveChangesAsync`. This behavior can be changed by setting the `TenantNotSetMode' property on the database context:

* TenantNotSetMode.Throw - For added entities the null `TenantId` will be overwritten to match the database context's current `TenantInfo`. For updated entities a `MultiTenantException` is thrown (default).
* TenantNotSetMode.Overwrite - The entity's `TenantId` is overwritten to match the database context's current `TenantInfo`.
6 changes: 3 additions & 3 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ See [Stores](Stores) for more information.

Finbuckle.MultiTenant comes with a collection of strategies and store types that can be mixed and matched in various ways.

`app.UseEndPoints`
`app.UseMultiTenant()`

This line configures the middleware which resolves the tenant using the registered strategies, stores, and other settings. Be sure to call it before calling `UseEndpoints` and other middleware which will use per-tenant functionality, e.g. `UseAuthentication`.
This line configures the middleware which resolves the tenant using the registered strategies, stores, and other settings. Be sure to call it before calling `UseEndpoints()` and other middleware which will use per-tenant functionality, e.g. `UseAuthentication()`.

## Basic Usage

With the services and middleware configured, access information for the current tenant from the `TenantInfo` property on the `MultiTenantContext` object accessed from the `GetMultiTenantContext<T>` extension method:
With the services and middleware configured, access information for the current tenant from the `TenantInfo` property on the `MultiTenantContext<T>` object accessed from the `GetMultiTenantContext<T>` extension method:

```cs
var tenantInfo = HttpContext.GetMultiTenantContext<TenantInfo>().TenantInfo;
Expand Down
4 changes: 2 additions & 2 deletions docs/Stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ The configuration section should use this JSON format shown below. Any fields in
},
"Tenants": [
{
"Id": "unique-id-0ff4adaf",
"Id": "unique-id-0ff4daf",
"Identifier": "tenant-1",
"Name": "Tenant 1 Company Name",
"ACustomProperty": "VIP Customer"
Expand Down Expand Up @@ -278,7 +278,7 @@ deserialization.
Each tenant info instance is actually stored twice in the cache, once using the
Tenant Id as the key and another using the Tenant Identifier as the key. Calls
to `TryAddAsync`, `TryUpdateAsync`, and `TryRemoveAsync` will keep these dual
cache entries synched.
cache entries synced.

This store does not implement `GetAllAsync`.

Expand Down
Loading

0 comments on commit a2d0416

Please sign in to comment.