Skip to content

Commit

Permalink
Merge pull request #630 from Jevonius/add-net6
Browse files Browse the repository at this point in the history
Add `net6.0` support (per #621)
  • Loading branch information
jonorossi authored Nov 30, 2022
2 parents 13ff71f + bee7b2e commit 1c3d7d6
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.vs
_ReSharper*/
*.csproj.ReSharper
.cr

# Build output
build/
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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()`.
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: Visual Studio 2019
image: Visual Studio 2022

build:
verbosity: minimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="11.0.0" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="11.0.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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<PerWebRequestComponent>().LifestylePerWebRequest().Named("P"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.3" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="11.0.0" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

<ItemGroup>
<!-- This is an intentional upgrade to NUnit. This is the solution for https://github.com/castleproject/Windsor/issues/243 once we upgrade NUnit and make dotnet test a first class citizen-->
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.0.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\buildscripts\common.props"></Import>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="11.0.0" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>

<IsPackable>false</IsPackable>

Expand All @@ -11,15 +11,24 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Specification.Tests" Version="3.1.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.assert" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Specification.Tests" Version="3.1.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Specification.Tests" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Castle.Windsor.Extensions.DependencyInjection\Castle.Windsor.Extensions.DependencyInjection.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

Expand All @@ -19,13 +19,19 @@
<RootNamespace>Castle.Windsor.Extensions.DependencyInjection</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.3" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Castle.Windsor\Castle.Windsor.csproj" />
<ProjectReference Include="..\Castle.Windsor\Castle.Windsor.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

Expand All @@ -19,8 +19,12 @@
<RootNamespace>Castle.Windsor.Extensions.Hosting</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.3" />
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions src/Castle.Windsor.Tests/Castle.Windsor.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.1;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\buildscripts\common.props"></Import>
Expand Down Expand Up @@ -44,9 +44,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net462'">
Expand All @@ -56,7 +56,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Castle.Facilities.Logging\Castle.Facilities.Logging.csproj" />
<ProjectReference Include="..\Castle.Facilities.Logging\Castle.Facilities.Logging.csproj" />
<ProjectReference Include="..\Castle.Windsor\Castle.Windsor.csproj" />
</ItemGroup>

Expand All @@ -74,4 +74,3 @@
</PropertyGroup>

</Project>

12 changes: 8 additions & 4 deletions src/Castle.Windsor/Castle.Windsor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\buildscripts\common.props"></Import>
Expand Down Expand Up @@ -33,8 +33,12 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
</ItemGroup>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
</ItemGroup>

</Project>

0 comments on commit 1c3d7d6

Please sign in to comment.