diff --git a/.gitignore b/.gitignore index 690319694..17b24b246 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .vs _ReSharper*/ *.csproj.ReSharper +.cr # Build output build/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 11bf9f3fc..7c4a75654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Add fast lookup to check for already registered types. (@sqeezy, #618) - Change target framework from .NET Standard 1.6 to 2.0 (@generik0, #572) - Castle.Windsor.Extensions.DependencyInjection: Change Microsoft.Extensions.Logging dependencies to their abstract counterparts (@ikkentim, #626, #624) +- Add `net6.0` as a target (@Jevonius, #621) Bugfixes: - Castle.Windsor.Extensions.DependencyInjection: support parallel containers (@rvdginste, @generik0, #563, #577) diff --git a/README.md b/README.md index 6596c3126..30f33418d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ See the [releases](https://github.com/castleproject/Windsor/releases). ## License -Castle Windsor is © 2004-2020 Castle Project. It is free software, and may be redistributed under the terms of the [Apache 2.0](http://opensource.org/licenses/Apache-2.0) license. +Castle Windsor is © 2004-2022 Castle Project. It is free software, and may be redistributed under the terms of the [Apache 2.0](http://opensource.org/licenses/Apache-2.0) license. ## NuGet Preview Feed @@ -28,7 +28,7 @@ https://ci.appveyor.com/nuget/windsor-qkry8n2r6yak The following conditional compilation symbols are currently defined for Windsor: -Symbol | .NET 4.5 | .NET Standard +Symbol | .NET 4.6.2 | .NET Standard / 6 ----------------------------------- | ------------------ | ------------------ `CASTLE_SERVICES_LOGGING` | :white_check_mark: | :no_entry_sign: `FEATURE_APPDOMAIN` | :white_check_mark: | :no_entry_sign: @@ -58,7 +58,7 @@ Symbol | .NET 4.5 | .NET Standard * `FEATURE_SYSTEM_CONFIGURATION` - enables features that use `System.Configuration` and the `ConfigurationManager`. * `FEATURE_URIMEMBERS` - enables code that uses `Uri.SchemeDelimiter`. -The following conditional compilation symbols are defined for tests only under .NET 4.5: +The following conditional compilation symbols are defined for tests only under .NET 4.6.2: * `FEATURE_CODEDOM` - enables code that uses `System.CodeDom`. * `FEATURE_CONSOLETRACELISTENER` - enables code that requires `System.Diagnostics.ConsoleTraceListener`. * `FEATURE_THREADABORT` - enables code that uses `Thread.Abort()`. diff --git a/appveyor.yml b/appveyor.yml index f0aa02d6e..415eaa3f1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -image: Visual Studio 2019 +image: Visual Studio 2022 build: verbosity: minimal diff --git a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj index 7e31d0e49..5512330db 100644 --- a/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj +++ b/src/Castle.Facilities.AspNet.Mvc.Tests/Castle.Facilities.AspNet.Mvc.Tests.csproj @@ -16,10 +16,10 @@ - + - - + + diff --git a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj index d1040d355..fef2d0db9 100644 --- a/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj +++ b/src/Castle.Facilities.AspNet.SystemWeb.Tests/Castle.Facilities.AspNet.SystemWeb.Tests.csproj @@ -19,10 +19,10 @@ - - - - + + + + diff --git a/src/Castle.Facilities.AspNet.SystemWeb.Tests/PerWebRequestTestCase.cs b/src/Castle.Facilities.AspNet.SystemWeb.Tests/PerWebRequestTestCase.cs index a858fb68b..dfd658ecb 100644 --- a/src/Castle.Facilities.AspNet.SystemWeb.Tests/PerWebRequestTestCase.cs +++ b/src/Castle.Facilities.AspNet.SystemWeb.Tests/PerWebRequestTestCase.cs @@ -27,14 +27,6 @@ namespace Castle.Facilities.AspNet.SystemWeb.Tests [TestFixture] public class PerWebRequestTestCase { - private FakePerWebRequestLifestyleModule fakeModule; - - [OneTimeSetUp] - public void SetUpFixture() - { - fakeModule = new FakePerWebRequestLifestyleModule(); - } - [Test] public void Should_be_able_to_register_using_attribute_for_per_web_request_lifestyle() { @@ -56,6 +48,8 @@ public void Should_be_able_to_register_using_component_registration_extension_fo [Test] public void Should_be_able_to_register_resolve_and_release_per_web_request_lifestyle_component_using_fake_module() { + var fakeModule = new FakePerWebRequestLifestyleModule(); + var container = new WindsorContainer(); container.Register(Component.For().LifestylePerWebRequest().Named("P")); diff --git a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj index 12a4af1d1..4bf6854af 100644 --- a/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj +++ b/src/Castle.Facilities.AspNet.WebApi.Tests/Castle.Facilities.AspNet.WebApi.Tests.csproj @@ -16,10 +16,10 @@ - + - - + + diff --git a/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj b/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj index 908c77125..4efbaf31d 100644 --- a/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj +++ b/src/Castle.Facilities.AspNetCore.Tests/Castle.Facilities.AspNetCore.Tests.csproj @@ -6,9 +6,9 @@ - - - + + + diff --git a/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj b/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj index 57da9624a..ba41b5204 100644 --- a/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj +++ b/src/Castle.Facilities.Logging/Castle.Facilities.Logging.csproj @@ -1,7 +1,7 @@  - net462;netstandard2.0 + net462;netstandard2.0;net6.0 diff --git a/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj b/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj index 7422bbe76..3d0cf68e7 100644 --- a/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj +++ b/src/Castle.Facilities.WcfIntegration.Tests/Castle.Facilities.WcfIntegration.Tests.csproj @@ -12,10 +12,10 @@ - + - - + + diff --git a/src/Castle.Windsor.Extensions.DependencyInjection.Tests/Castle.Windsor.Extensions.DependencyInjection.Tests.csproj b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/Castle.Windsor.Extensions.DependencyInjection.Tests.csproj index e7e207b0b..6ef705103 100644 --- a/src/Castle.Windsor.Extensions.DependencyInjection.Tests/Castle.Windsor.Extensions.DependencyInjection.Tests.csproj +++ b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/Castle.Windsor.Extensions.DependencyInjection.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net6.0 false @@ -11,8 +11,7 @@ - - + @@ -20,6 +19,16 @@ + + + + + + + + + + diff --git a/src/Castle.Windsor.Extensions.DependencyInjection.Tests/SkippableDependencyInjectionSpecificationTests.cs b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/SkippableDependencyInjectionSpecificationTests.cs new file mode 100644 index 000000000..12537699c --- /dev/null +++ b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/SkippableDependencyInjectionSpecificationTests.cs @@ -0,0 +1,52 @@ +/* + * Based upon: https://github.com/dotnet/runtime/blob/v6.0.9/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/SkippableDependencyInjectionSpecificationTests.cs + * + * Why is this necessary? + * ---------------------- + * There is one test (SingletonServiceCanBeResolvedFromScope - https://github.com/dotnet/runtime/blob/v6.0.9/src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/DependencyInjectionSpecificationTests.cs#L125-L155) + * that relies on a behaviour that Windsor doesn't share with MEDI, that of Scopes being their own `IServiceProvider`. + * When you create a new Scope in Windsor, it uses the same ServiceProvider that's passed in, + * whereas in MEDI, a Scope is a ServiceProvider in its own right. + * + * Compare: + * Castle.Windsor.Extensions.DependencyInjection.Scope.ServiceScope + * with: + * Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope (https://github.com/dotnet/runtime/blob/v6.0.9/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ServiceProviderEngineScope.cs) + * + * Specifically, how the `ServiceProvider` property is implemented. + */ + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Diagnostics; +using System.Linq; + +namespace Microsoft.Extensions.DependencyInjection.Specification +{ + public abstract class SkippableDependencyInjectionSpecificationTests : DependencyInjectionSpecificationTests + { + public string[] SkippedTests => new[] { "SingletonServiceCanBeResolvedFromScope" }; + +#if NET6_0_OR_GREATER + public override bool SupportsIServiceProviderIsService => false; +#endif + + protected sealed override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection) + { + foreach (var stackFrame in new StackTrace(1).GetFrames().Take(2)) + { + if (SkippedTests.Contains(stackFrame.GetMethod().Name)) + { + // We skip tests by returning MEDI service provider that we know passes the test + return serviceCollection.BuildServiceProvider(); + } + } + + return CreateServiceProviderImpl(serviceCollection); + } + + protected abstract IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection); + } +} \ No newline at end of file diff --git a/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderCustomWindsorContainerTests.cs b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderCustomWindsorContainerTests.cs index e253d8661..00ece5738 100644 --- a/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderCustomWindsorContainerTests.cs +++ b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderCustomWindsorContainerTests.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2020 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ namespace Castle.Windsor.Extensions.DependencyInjection.Tests using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Specification; - public class WindsorScopedServiceProviderCustomWindsorContainerTests : DependencyInjectionSpecificationTests + public class WindsorScopedServiceProviderCustomWindsorContainerTests : SkippableDependencyInjectionSpecificationTests { - protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection) + protected override IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection) { var factory = new WindsorServiceProviderFactory(new WindsorContainer()); var container = factory.CreateBuilder(serviceCollection); diff --git a/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderTests.cs b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderTests.cs index ffbab940d..c335dd163 100644 --- a/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderTests.cs +++ b/src/Castle.Windsor.Extensions.DependencyInjection.Tests/WindsorScopedServiceProviderTests.cs @@ -1,4 +1,4 @@ -// Copyright 2004-2020 Castle Project - http://www.castleproject.org/ +// Copyright 2004-2022 Castle Project - http://www.castleproject.org/ // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ namespace Castle.Windsor.Extensions.DependencyInjection.Tests using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Specification; - public class WindsorScopedServiceProviderTests : DependencyInjectionSpecificationTests + public class WindsorScopedServiceProviderTests : SkippableDependencyInjectionSpecificationTests { - protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection) + protected override IServiceProvider CreateServiceProviderImpl(IServiceCollection serviceCollection) { var factory = new WindsorServiceProviderFactory(); var container = factory.CreateBuilder(serviceCollection); diff --git a/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj b/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj index a4de6786f..39e554100 100644 --- a/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj +++ b/src/Castle.Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net6.0 9.0 @@ -19,13 +19,19 @@ Castle.Windsor.Extensions.DependencyInjection - + + + + + + + - + diff --git a/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj b/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj index d89336682..88fb0f84d 100644 --- a/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj +++ b/src/Castle.Windsor.Extensions.Hosting/Castle.Windsor.Extensions.Hosting.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net6.0 9.0 @@ -19,8 +19,12 @@ Castle.Windsor.Extensions.Hosting - - + + + + + + diff --git a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj index 2bab0e782..d93ffb775 100644 --- a/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj +++ b/src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj @@ -1,7 +1,7 @@  - net462;netcoreapp3.1 + net462;netcoreapp3.1;net6.0 @@ -44,9 +44,9 @@ - - - + + + @@ -56,7 +56,7 @@ - + @@ -74,4 +74,3 @@ - diff --git a/src/Castle.Windsor/Castle.Windsor.csproj b/src/Castle.Windsor/Castle.Windsor.csproj index 3269bfd52..650d028a1 100644 --- a/src/Castle.Windsor/Castle.Windsor.csproj +++ b/src/Castle.Windsor/Castle.Windsor.csproj @@ -1,7 +1,7 @@  - net462;netstandard2.0 + net462;netstandard2.0;net6.0 @@ -33,8 +33,12 @@ - - - + + + + + + +