From eb127bd729f136a0c01a6622df7035853548e8a8 Mon Sep 17 00:00:00 2001 From: Alex Meyer-Gleaves Date: Tue, 21 Sep 2021 23:45:45 +1000 Subject: [PATCH 1/9] Add "Open in Code" badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 730f137..af405be 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ASP.NET Core support for multitenant DI via [Autofac.Multitenant](https://github.com/autofac/Autofac.Multitenant). -[![Build status](https://ci.appveyor.com/api/projects/status/u6epu5sc9f9sgav3?svg=true)](https://ci.appveyor.com/project/Autofac/autofac-aspnetcore-multitenant) [![codecov](https://codecov.io/gh/Autofac/Autofac.AspNetCore.Multitenant/branch/develop/graph/badge.svg)](https://codecov.io/gh/Autofac/Autofac.AspNetCore.Multitenant) +[![Build status](https://ci.appveyor.com/api/projects/status/u6epu5sc9f9sgav3?svg=true)](https://ci.appveyor.com/project/Autofac/autofac-aspnetcore-multitenant) [![codecov](https://codecov.io/gh/Autofac/Autofac.AspNetCore.Multitenant/branch/develop/graph/badge.svg)](https://codecov.io/gh/Autofac/Autofac.AspNetCore.Multitenant) [![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/autofac/Autofac.AspNetCore.Multitenant) Please file issues and pull requests for this package in this repository rather than in the Autofac core repo. From e855d05ff1b743b8d826c965a1eebb864ce4419d Mon Sep 17 00:00:00 2001 From: Alex Meyer-Gleaves Date: Wed, 22 Sep 2021 22:55:04 +1000 Subject: [PATCH 2/9] Update MyGet key --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 60048a1..50049e5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,7 +33,7 @@ deploy: - provider: NuGet server: https://www.myget.org/F/autofac/api/v2/package api_key: - secure: rCUEY75fXN0wxtMy6QL4jCrLdaYbxIBzIXWeN+wEu/XDpyqimzreOc5AH5jMd5ah + secure: xUXExgVAagrdEicCjSxsQVrwiLo2TtnfqMbYB9Cauq2cpbm/EVz957PBK0v/GEYq skip_symbols: true symbol_server: https://www.myget.org/F/autofac/symbols/api/v2/package artifact: MyGet From 89854dec8efd9360abfbcb041fd9fe8662138703 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Sat, 13 Nov 2021 10:43:47 -0800 Subject: [PATCH 3/9] Disable warnings about netcoreapp2.1. --- .vscode/extensions.json | 7 +++---- .../Sandbox.AspNetCore2_1_To_2_2.csproj | 2 ++ .../Autofac.Integration.AspNetCore.Multitenant.csproj | 2 +- .../Autofac.Integration.AspNetCore.Multitenant.Test.csproj | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index aacd11f..5710952 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,9 @@ { "recommendations": [ - "ms-dotnettools.csharp", - "formulahendry.dotnet-test-explorer", - "editorconfig.editorconfig", - "shd101wyy.markdown-preview-enhanced", "davidanson.vscode-markdownlint", + "editorconfig.editorconfig", + "formulahendry.dotnet-test-explorer", + "ms-dotnettools.csharp", "stkb.rewrap" ] } diff --git a/samples/Sandbox.AspNetCore2_1_To_2_2/Sandbox.AspNetCore2_1_To_2_2.csproj b/samples/Sandbox.AspNetCore2_1_To_2_2/Sandbox.AspNetCore2_1_To_2_2.csproj index efdd08a..3a07f77 100644 --- a/samples/Sandbox.AspNetCore2_1_To_2_2/Sandbox.AspNetCore2_1_To_2_2.csproj +++ b/samples/Sandbox.AspNetCore2_1_To_2_2/Sandbox.AspNetCore2_1_To_2_2.csproj @@ -1,6 +1,8 @@ netcoreapp2.1 + + false Sandbox $(NoWarn);CS1591;SA1600 true diff --git a/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj b/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj index 1c7b066..75d7d7e 100644 --- a/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj +++ b/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj @@ -81,4 +81,4 @@ - \ No newline at end of file + diff --git a/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj b/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj index 85fe007..a521416 100644 --- a/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj +++ b/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj @@ -2,6 +2,8 @@ netcoreapp2.1;netcoreapp3.1;net5.0 + + false $(NoWarn);CS1591;SA1600 ../../Autofac.snk true @@ -59,4 +61,4 @@ - \ No newline at end of file + From 99c7f4b806505aa924e85147444fc0b3c8a361a7 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Sat, 13 Nov 2021 11:22:00 -0800 Subject: [PATCH 4/9] Launch sandbox apps using VS Code. --- .vscode/launch.json | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f10151e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,52 @@ +{ + "configurations": [ + { + "cwd": "${workspaceFolder}", + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://localhost:5555" + }, + "launchBrowser": { + "enabled": false + }, + "name": "Sandbox 2.1-2.2", + "preLaunchTask": "build", + "program": "${workspaceFolder}/samples/Sandbox.AspNetCore2_1_To_2_2/bin/Debug/netcoreapp2.1/Sandbox.AspNetCore2_1_To_2_2.dll", + "request": "launch", + "stopAtEntry": false, + "type": "coreclr" + }, + { + "cwd": "${workspaceFolder}", + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://localhost:5555" + }, + "launchBrowser": { + "enabled": false + }, + "name": "Sandbox 2-3.1", + "preLaunchTask": "build", + "program": "${workspaceFolder}/samples/Sandbox.AspNetCore3_To_3_1/bin/Debug/netcoreapp3.1/Sandbox.AspNetCore3_To_3_1.dll", + "request": "launch", + "stopAtEntry": false, + "type": "coreclr" + }, + { + "cwd": "${workspaceFolder}", + "env": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://localhost:5555" + }, + "launchBrowser": { + "enabled": false + }, + "name": "Sandbox 5", + "preLaunchTask": "build", + "program": "${workspaceFolder}/samples/Sandbox.AspNetCore5/bin/Debug/net5.0/Sandbox.AspNetCore5.dll", + "request": "launch", + "stopAtEntry": false, + "type": "coreclr" + } + ] +} From 113fec7be7dbf9821a786fd59332b9a38fea49a2 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Sat, 13 Nov 2021 11:22:16 -0800 Subject: [PATCH 5/9] No HTTPS redirect on sandbox. --- samples/Sandbox.AspNetCore2_1_To_2_2/Startup.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/Sandbox.AspNetCore2_1_To_2_2/Startup.cs b/samples/Sandbox.AspNetCore2_1_To_2_2/Startup.cs index 7faaa81..67bbd10 100644 --- a/samples/Sandbox.AspNetCore2_1_To_2_2/Startup.cs +++ b/samples/Sandbox.AspNetCore2_1_To_2_2/Startup.cs @@ -25,7 +25,6 @@ public void ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app) { - app.UseHttpsRedirection(); app.UseMvc(); } @@ -34,4 +33,4 @@ public void ConfigureContainer(ContainerBuilder builder) ContainerSetup.SetupContainer(builder); } } -} \ No newline at end of file +} From 59f0ec260e56054cb41e3961c1a639cd925a3766 Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Sat, 13 Nov 2021 11:35:45 -0800 Subject: [PATCH 6/9] Align VS and VS Code launch settings. --- .../Properties/launchSettings.json | 10 +++++----- .../Properties/launchSettings.json | 9 +++++---- .../Sandbox.AspNetCore5/Properties/launchSettings.json | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/samples/Sandbox.AspNetCore2_1_To_2_2/Properties/launchSettings.json b/samples/Sandbox.AspNetCore2_1_To_2_2/Properties/launchSettings.json index 6bb4753..df9730d 100644 --- a/samples/Sandbox.AspNetCore2_1_To_2_2/Properties/launchSettings.json +++ b/samples/Sandbox.AspNetCore2_1_To_2_2/Properties/launchSettings.json @@ -2,13 +2,13 @@ "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "Sandbox.AspNetCore2_1": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "api/values", "applicationUrl": "http://localhost:5555", + "commandName": "Project", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "launchBrowser": true, + "launchUrl": "api/values" } } -} \ No newline at end of file +} diff --git a/samples/Sandbox.AspNetCore3_To_3_1/Properties/launchSettings.json b/samples/Sandbox.AspNetCore3_To_3_1/Properties/launchSettings.json index cd4df08..3e88659 100644 --- a/samples/Sandbox.AspNetCore3_To_3_1/Properties/launchSettings.json +++ b/samples/Sandbox.AspNetCore3_To_3_1/Properties/launchSettings.json @@ -1,13 +1,14 @@ { + "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "Sandbox.Sandbox.AspNetCore3_To_3_1": { + "applicationUrl": "http://localhost:5555", "commandName": "Project", - "launchBrowser": true, - "launchUrl": "api/values", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://localhost:35115" + "launchBrowser": true, + "launchUrl": "api/values" } } -} \ No newline at end of file +} diff --git a/samples/Sandbox.AspNetCore5/Properties/launchSettings.json b/samples/Sandbox.AspNetCore5/Properties/launchSettings.json index d754e62..696a8e1 100644 --- a/samples/Sandbox.AspNetCore5/Properties/launchSettings.json +++ b/samples/Sandbox.AspNetCore5/Properties/launchSettings.json @@ -1,13 +1,14 @@ { + "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "Sandbox.AspNetCore5": { + "applicationUrl": "http://localhost:5555", "commandName": "Project", - "launchBrowser": true, - "launchUrl": "api/values", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "http://localhost:35116" + "launchBrowser": true, + "launchUrl": "api/values" } } } From 65c358e8e27f082fa8c1438d5d6c83fdf4f52e6f Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Sat, 13 Nov 2021 11:40:29 -0800 Subject: [PATCH 7/9] Move the sample README up a level for better discovery. --- .vscode/settings.json | 4 +++ samples/README.md | 36 ++++++++++++++++++++ samples/Sandbox.AspNetCore3_To_3_1/README.md | 28 --------------- 3 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 samples/README.md delete mode 100644 samples/Sandbox.AspNetCore3_To_3_1/README.md diff --git a/.vscode/settings.json b/.vscode/settings.json index 863b0e2..db4154b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,8 @@ { + "cSpell.words": [ + "autofac", + "multitenant" + ], "dotnet-test-explorer.runInParallel": true, "dotnet-test-explorer.testProjectPath": "test/**/*.Test.csproj" } diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 0000000..a9d0c36 --- /dev/null +++ b/samples/README.md @@ -0,0 +1,36 @@ +# Sample ASP.NET Core Multitenant Applications + +Each of the 'sandbox' applications shows, in the respective framework version, the functionality of Autofac.AspNetCore.Multitenant in action. You can launch them from Visual Studio or VS Code with the settings in this project; or you can run from the command line with `dotnet run`. + +## Try It Out + +You can see different dependencies used by querying the `api/values` route: + +```sh +# Get the default value - will show `base` since there's no tenant ID. +curl http://localhost:5555/api/values + +# Get some tenant-specific values - will show the tenant ID due to overrides. +curl http://localhost:5555/api/values?tenant=a +curl http://localhost:5555/api/values?tenant=b + +# Only tenant a and b have overrides. Tenant c will show `base` again. +curl http://localhost:5555/api/values?tenant=c +``` + +## Points of Interest + +### Program.cs + +When using the `WebHostBuilder` the `UseAutofacMultitenantRequestServices` extension is used to tie the multitenant container to the request lifetime scope generation process. + +**If you comment out the `UseAutofacMultitenantRequestServices` line it'll stop working** and you'll only ever see `base`. This illustrates why this package is required. + +## Startup.cs + +In `ConfigureServices` we... + +- Create a tenant ID strategy. +- Set up the multitenant container. +- Store the multitenant container in a place that the request services middleware can access it later. +- Return an `AutofacServiceProvider` so services can be resolved normally. diff --git a/samples/Sandbox.AspNetCore3_To_3_1/README.md b/samples/Sandbox.AspNetCore3_To_3_1/README.md deleted file mode 100644 index 1d0a68e..0000000 --- a/samples/Sandbox.AspNetCore3_To_3_1/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Sandbox - -This demo shows the multitenant ASP.NET Core support in action. - -## Program.cs -When using the `WebHostBuilder` the `UseAutofacMultitenantRequestServices` extension is used to tie the multitenant container to the request lifetime scope generation process. - -## Startup.cs -In `ConfigureServices` we... - -- Create a tenant ID strategy. -- Set up the multitenant container. -- Store the multitenant container in a place that the request services middleware can access it later. -- Return an `AutofacServiceProvider` so services can be resolved normally. - -## Trying It Out - -Build and launch the site. There is only one route in the site: `/api/values` - -When you hit `/api/values` you should get `base` to indicate the base dependency is getting used. - -Pass in a tenant ID on the query string to change tenant. - -- `/api/values?tenant=a` should yield `a` -- `/api/values?tenant=b` should yield `b` -- Any other value for the tenant ID should yield `base` because only tenant `a` and `b` are configured with specific overrides. - -**If you comment out the `UseAutofacMultitenantRequestServices` line it'll stop working** and you'll only ever see `base`. This illustrates why this package is required. \ No newline at end of file From 61a1ed7becdc283b17e434af12b20b908fa0445e Mon Sep 17 00:00:00 2001 From: alsami Date: Sun, 14 Nov 2021 08:31:12 +0100 Subject: [PATCH 8/9] feat: add support for .NET6 --- Autofac.AspNetCore.Multitenant.sln | 2 +- appveyor.yml | 4 +-- build/Autofac.Build.psm1 | 32 ++++++------------- global.json | 3 +- .../Program.cs | 0 .../Properties/launchSettings.json | 0 .../Sandbox.AspNetCore5_To_6.csproj} | 2 +- .../Startup.cs | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 ....Integration.AspNetCore.Multitenant.csproj | 6 ++-- ...cMultitenantServiceCollectionExtensions.cs | 3 -- ...utofacMultitenantServiceProviderFactory.cs | 5 --- ...ofacMultitenantWebHostBuilderExtensions.cs | 2 -- .../MultitenantRequestServicesMiddleware.cs | 8 +++-- ...gration.AspNetCore.Multitenant.Test.csproj | 22 ++++++++++--- ...itenantServiceCollectionExtensionsTests.cs | 4 --- ...ultitenantWebHostBuilderExtensionsTests.cs | 2 -- 18 files changed, 41 insertions(+), 54 deletions(-) rename samples/{Sandbox.AspNetCore5 => Sandbox.AspNetCore5_To_6}/Program.cs (100%) rename samples/{Sandbox.AspNetCore5 => Sandbox.AspNetCore5_To_6}/Properties/launchSettings.json (100%) rename samples/{Sandbox.AspNetCore5/Sandbox.AspNetCore5.csproj => Sandbox.AspNetCore5_To_6/Sandbox.AspNetCore5_To_6.csproj} (93%) rename samples/{Sandbox.AspNetCore5 => Sandbox.AspNetCore5_To_6}/Startup.cs (100%) rename samples/{Sandbox.AspNetCore5 => Sandbox.AspNetCore5_To_6}/appsettings.Development.json (100%) rename samples/{Sandbox.AspNetCore5 => Sandbox.AspNetCore5_To_6}/appsettings.json (100%) diff --git a/Autofac.AspNetCore.Multitenant.sln b/Autofac.AspNetCore.Multitenant.sln index 2ded2b2..fe66537 100644 --- a/Autofac.AspNetCore.Multitenant.sln +++ b/Autofac.AspNetCore.Multitenant.sln @@ -41,7 +41,7 @@ ProjectSection(SolutionItems) = preProject build\stylecop.json = build\stylecop.json EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox.AspNetCore5", "samples\Sandbox.AspNetCore5\Sandbox.AspNetCore5.csproj", "{B64B6D62-AD07-49BE-AF65-3E4C92284AD5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox.AspNetCore5_To_6", "samples\Sandbox.AspNetCore5_To_6\Sandbox.AspNetCore5_To_6.csproj", "{B64B6D62-AD07-49BE-AF65-3E4C92284AD5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/appveyor.yml b/appveyor.yml index 50049e5..04cea5f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,9 @@ image: Ubuntu -version: 5.0.0.{build} +version: 5.1.0.{build} dotnet_csproj: - version_prefix: '5.0.0' + version_prefix: '5.1.0' patch: true file: 'src\**\*.csproj' diff --git a/build/Autofac.Build.psm1 b/build/Autofac.Build.psm1 index 348c801..bf730a0 100644 --- a/build/Autofac.Build.psm1 +++ b/build/Autofac.Build.psm1 @@ -34,26 +34,6 @@ function Install-DotNetCli { [string] $Version = "Latest" ) - - if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue)) { - $installedVersions = dotnet --list-sdks - foreach ($sdkListLine in $installedVersions) - { - $splitParts = $sdkListLine.Split(" "); - - $versionPart = $splitParts[0]; - - $globalInstallLocation = $splitParts[1].Replace("[", "").Replace("]", "") - - if ($versionPart -eq $Version) - { - Write-Message ".NET Core SDK version $Version is already installed in $globalInstallLocation" - Add-Path "$globalInstallLocation" - return; - } - } - } - Write-Message "Installing .NET SDK version $Version" $callerPath = Split-Path $MyInvocation.PSCommandPath @@ -93,11 +73,19 @@ function Add-Path { [string] $Path ) - $pathValues = $env:PATH.Split(";"); + + $pathSeparator = ":"; + + if ($IsWindows) { + $pathSeparator = ";"; + } + + $pathValues = $env:PATH.Split($pathSeparator); if ($pathValues -Contains $Path) { return; } - $env:PATH = "$Path;$env:PATH" + + $env:PATH = "${Path}${pathSeparator}$env:PATH" } <# diff --git a/global.json b/global.json index 22bc2bb..7951aa5 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,11 @@ { "sdk": { - "version": "5.0.100", + "version": "6.0.100", "rollForward": "latestFeature" }, "additionalSdks": [ + "5.0.403", "2.1.811", "3.1.302" ] diff --git a/samples/Sandbox.AspNetCore5/Program.cs b/samples/Sandbox.AspNetCore5_To_6/Program.cs similarity index 100% rename from samples/Sandbox.AspNetCore5/Program.cs rename to samples/Sandbox.AspNetCore5_To_6/Program.cs diff --git a/samples/Sandbox.AspNetCore5/Properties/launchSettings.json b/samples/Sandbox.AspNetCore5_To_6/Properties/launchSettings.json similarity index 100% rename from samples/Sandbox.AspNetCore5/Properties/launchSettings.json rename to samples/Sandbox.AspNetCore5_To_6/Properties/launchSettings.json diff --git a/samples/Sandbox.AspNetCore5/Sandbox.AspNetCore5.csproj b/samples/Sandbox.AspNetCore5_To_6/Sandbox.AspNetCore5_To_6.csproj similarity index 93% rename from samples/Sandbox.AspNetCore5/Sandbox.AspNetCore5.csproj rename to samples/Sandbox.AspNetCore5_To_6/Sandbox.AspNetCore5_To_6.csproj index b0f205d..783a8df 100644 --- a/samples/Sandbox.AspNetCore5/Sandbox.AspNetCore5.csproj +++ b/samples/Sandbox.AspNetCore5_To_6/Sandbox.AspNetCore5_To_6.csproj @@ -1,6 +1,6 @@ - net5.0 + net6.0 Sandbox $(NoWarn);CS1591;SA1600 true diff --git a/samples/Sandbox.AspNetCore5/Startup.cs b/samples/Sandbox.AspNetCore5_To_6/Startup.cs similarity index 100% rename from samples/Sandbox.AspNetCore5/Startup.cs rename to samples/Sandbox.AspNetCore5_To_6/Startup.cs diff --git a/samples/Sandbox.AspNetCore5/appsettings.Development.json b/samples/Sandbox.AspNetCore5_To_6/appsettings.Development.json similarity index 100% rename from samples/Sandbox.AspNetCore5/appsettings.Development.json rename to samples/Sandbox.AspNetCore5_To_6/appsettings.Development.json diff --git a/samples/Sandbox.AspNetCore5/appsettings.json b/samples/Sandbox.AspNetCore5_To_6/appsettings.json similarity index 100% rename from samples/Sandbox.AspNetCore5/appsettings.json rename to samples/Sandbox.AspNetCore5_To_6/appsettings.json diff --git a/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj b/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj index 75d7d7e..c87aedf 100644 --- a/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj +++ b/src/Autofac.Integration.AspNetCore.Multitenant/Autofac.Integration.AspNetCore.Multitenant.csproj @@ -4,7 +4,7 @@ ASP.NET Core support for multitenant DI via Autofac.Multitenant. 0.0.1 - netstandard2.0;netcoreapp3.1;net5.0 + netstandard2.0;netcoreapp3.1;net5.0;net6.0 true true Autofac.Integration.AspNetCore.Multitenant @@ -47,7 +47,7 @@ - + All @@ -58,7 +58,7 @@ All - + All diff --git a/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceCollectionExtensions.cs b/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceCollectionExtensions.cs index 5a7dfd5..8e39439 100644 --- a/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceCollectionExtensions.cs +++ b/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceCollectionExtensions.cs @@ -2,10 +2,7 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using System; -using Autofac; using Autofac.Integration.AspNetCore.Multitenant; -using Autofac.Multitenant; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; diff --git a/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceProviderFactory.cs b/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceProviderFactory.cs index 3a53cf1..adf2a97 100644 --- a/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceProviderFactory.cs +++ b/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantServiceProviderFactory.cs @@ -2,15 +2,10 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using System; -using System.Collections.Generic; -using System.Reflection; using Autofac; -using Autofac.Builder; using Autofac.Extensions.DependencyInjection; -using Autofac.Integration.AspNetCore.Multitenant; using Autofac.Integration.AspNetCore.Multitenant.Properties; using Autofac.Multitenant; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Hosting diff --git a/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantWebHostBuilderExtensions.cs b/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantWebHostBuilderExtensions.cs index 0dcb118..8a28286 100644 --- a/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantWebHostBuilderExtensions.cs +++ b/src/Autofac.Integration.AspNetCore.Multitenant/AutofacMultitenantWebHostBuilderExtensions.cs @@ -2,8 +2,6 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using System; -using Autofac; -using Autofac.Multitenant; namespace Microsoft.AspNetCore.Hosting { diff --git a/src/Autofac.Integration.AspNetCore.Multitenant/MultitenantRequestServicesMiddleware.cs b/src/Autofac.Integration.AspNetCore.Multitenant/MultitenantRequestServicesMiddleware.cs index db7369b..a019c7d 100644 --- a/src/Autofac.Integration.AspNetCore.Multitenant/MultitenantRequestServicesMiddleware.cs +++ b/src/Autofac.Integration.AspNetCore.Multitenant/MultitenantRequestServicesMiddleware.cs @@ -58,12 +58,14 @@ public async Task Invoke(HttpContext context) { var autofacFeature = RequestServicesFeatureFactory.CreateFeature(context, _multitenantContainer.Resolve()); - if (autofacFeature is IDisposable disp) + if (autofacFeature is IDisposable disposable) { - context.Response.RegisterForDispose(disp); + context.Response.RegisterForDispose(disposable); } - existingFeature = context.Features.Get(); +#pragma warning disable SA1009 + existingFeature = context.Features.Get()!; +#pragma warning restore context.Features.Set(autofacFeature); await _next.Invoke(context); diff --git a/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj b/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj index a521416..e76a85b 100644 --- a/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj +++ b/test/Autofac.Integration.AspNetCore.Multitenant.Test/Autofac.Integration.AspNetCore.Multitenant.Test.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;netcoreapp3.1;net5.0 + netcoreapp2.1;netcoreapp3.1;net5.0;net6.0 false $(NoWarn);CS1591;SA1600 @@ -28,8 +28,8 @@ - - + + all runtime; build; native; contentfiles; analyzers @@ -38,8 +38,20 @@ All - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + diff --git a/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantServiceCollectionExtensionsTests.cs b/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantServiceCollectionExtensionsTests.cs index 84e00e6..402e132 100644 --- a/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantServiceCollectionExtensionsTests.cs +++ b/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantServiceCollectionExtensionsTests.cs @@ -2,12 +2,9 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using System; -using Autofac.Integration.AspNetCore.Multitenant.Properties; -using Autofac.Multitenant; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Moq; using Xunit; namespace Autofac.Integration.AspNetCore.Multitenant.Test @@ -43,7 +40,6 @@ public void AddAutofacMultitenantRequestServices_AddsStartupFilter() [Fact] public void AddAutofacMultitenantRequestServices_NullBuilder() { - var mtc = new MultitenantContainer(Mock.Of(), new ContainerBuilder().Build()); Assert.Throws(() => AutofacMultitenantServiceCollectionExtensions.AddAutofacMultitenantRequestServices(null!)); } } diff --git a/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantWebHostBuilderExtensionsTests.cs b/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantWebHostBuilderExtensionsTests.cs index 4565b49..e30fd44 100644 --- a/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantWebHostBuilderExtensionsTests.cs +++ b/test/Autofac.Integration.AspNetCore.Multitenant.Test/AutofacMultitenantWebHostBuilderExtensionsTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using System; -using Autofac.Multitenant; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; @@ -52,7 +51,6 @@ public void UseAutofacMultitenantRequestServices_AddsStartupFilter() [Fact] public void UseAutofacMultitenantRequestServices_NullBuilder() { - var mtc = new MultitenantContainer(Mock.Of(), new ContainerBuilder().Build()); Assert.Throws(() => AutofacMultitenantWebHostBuilderExtensions.UseAutofacMultitenantRequestServices(null!)); } } From f5a276c027b05bb3c9a7a2ac992851e1e15abbbc Mon Sep 17 00:00:00 2001 From: Travis Illig Date: Sun, 14 Nov 2021 09:32:17 -0800 Subject: [PATCH 9/9] Update for .NET 6 changes. --- .vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f10151e..e672f56 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,9 +41,9 @@ "launchBrowser": { "enabled": false }, - "name": "Sandbox 5", + "name": "Sandbox 5-6", "preLaunchTask": "build", - "program": "${workspaceFolder}/samples/Sandbox.AspNetCore5/bin/Debug/net5.0/Sandbox.AspNetCore5.dll", + "program": "${workspaceFolder}/samples/Sandbox.AspNetCore5_To_6/bin/Debug/net6.0/Sandbox.AspNetCore5_To_6.dll", "request": "launch", "stopAtEntry": false, "type": "coreclr"