Skip to content

Add support for Net 9 #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Setup .NET 9
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
Expand All @@ -36,4 +40,4 @@ jobs:
dotnet-version: 6.0.x

- name: Test
run: dotnet run -p build/build.csproj -- ci
run: dotnet run --project build/build.csproj -- ci
5 changes: 5 additions & 0 deletions .github/workflows/publish_lamar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.0.x

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion src/Aspect.Logger/Widget.Aspect.Logger.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

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

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down Expand Up @@ -44,6 +44,15 @@
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="[8.0.0,9.0.0)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="[9.0.0,10.0.0)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lamar.Microsoft.DependencyInjection\Lamar.Microsoft.DependencyInjection.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Lamar.AspNetCoreTests/Lamar.AspNetCoreTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/Lamar.Diagnostics/Lamar.Diagnostics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<Description>Adds diagnostic checks to the command line of your Lamar-enabled ASP.Net Core app</Description>
<Version>13.1.0</Version>
<Version>13.2.0</Version>
<Authors>Jeremy D. Miller</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>Lamar.Diagnostics</AssemblyName>
<PackageId>Lamar.Diagnostics</PackageId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Lamar Adapter for HostBuilder Integration</Description>
<Version>13.1.0</Version>
<Version>13.2.0</Version>
<Authors>Jeremy D. Miller</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>Lamar.Microsoft.DependencyInjection</AssemblyName>
<PackageId>Lamar.Microsoft.DependencyInjection</PackageId>
Expand All @@ -17,14 +17,20 @@
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="[9.0.0]" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="[9.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[9.0.0]" />
<PackageReference Include="Microsoft.Extensions.Options" Version="[9.0.0]" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Options" Version="[8.0.0]" />
</ItemGroup>


<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="[6.0.0,9.0.0)" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="[6.0.0,9.0.0)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;

using Shouldly;
using StructureMap.Testing.Widget;
using Xunit;
Expand Down Expand Up @@ -42,7 +44,7 @@ public void fix_for_391_dont_resolve_collections_with_not_registered_type()
{
var containerWithNoRegistrations = Container.Empty();

containerWithNoRegistrations.IsService(typeof(IEnumerable<ConcreteClass>)).ShouldBeFalse();
containerWithNoRegistrations.IsService(typeof(IEnumerable<ConcreteClass>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IReadOnlyCollection<ConcreteClass>)).ShouldBeFalse();
containerWithNoRegistrations.IsService(typeof(IList<ConcreteClass>)).ShouldBeFalse();
containerWithNoRegistrations.IsService(typeof(List<ConcreteClass>)).ShouldBeFalse();
Expand All @@ -58,6 +60,50 @@ public void fix_for_391_dont_resolve_collections_with_not_registered_type()
containerWithRegistrations.IsService(typeof(List<ConcreteClass>)).ShouldBeTrue();
}

[Fact]
public void fix_for_405_add_support_for_net9()
{
var containerWithNoRegistrations = Container.Empty();

containerWithNoRegistrations.IsService(typeof(IEnumerable<object>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<string>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<int>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<int?>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<float>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<float?>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<double>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<double?>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<decimal>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<decimal?>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<DateTime>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<DateTime?>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<DateOnly?>)).ShouldBeTrue();
containerWithNoRegistrations.IsService(typeof(IEnumerable<DateOnly?>)).ShouldBeTrue();

containerWithNoRegistrations.IsService(typeof(IReadOnlyCollection<object>)).ShouldBeFalse();
containerWithNoRegistrations.IsService(typeof(IReadOnlyList<object>)).ShouldBeFalse();
containerWithNoRegistrations.IsService(typeof(IList<object>)).ShouldBeFalse();
containerWithNoRegistrations.IsService(typeof(List<object>)).ShouldBeFalse();

List<int> integerList = new List<int>();

var containerWithRegistrations = Container.For(services =>
{
services.ForConcreteType<ConcreteClass>();
services.For<IEnumerable<int>>().Use(integerList);
});

containerWithRegistrations.IsService(typeof(IEnumerable<ConcreteClass>)).ShouldBeTrue();
containerWithRegistrations.IsService(typeof(IReadOnlyCollection<ConcreteClass>)).ShouldBeTrue();
containerWithRegistrations.IsService(typeof(IReadOnlyList<ConcreteClass>)).ShouldBeTrue();
containerWithRegistrations.IsService(typeof(IList<ConcreteClass>)).ShouldBeTrue();
containerWithRegistrations.IsService(typeof(List<ConcreteClass>)).ShouldBeTrue();

containerWithRegistrations.IsService(typeof(IEnumerable<int>)).ShouldBeTrue();

containerWithRegistrations.GetInstance<IEnumerable<int>>().ShouldBeSameAs(integerList);
}

public interface IService
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lamar.Testing/Lamar.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Lamar/Lamar.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Fast ASP.Net Core compatible IoC Tool, Successor to StructureMap</Description>
<Version>13.1.0</Version>
<Version>13.2.0</Version>
<Authors>Jeremy D. Miller</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>Lamar</AssemblyName>
<PackageId>Lamar</PackageId>
Expand Down
4 changes: 2 additions & 2 deletions src/Lamar/ServiceGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ internal ServiceFamily TryToCreateMissingFamilyWithNetCoreRules(Type serviceType

private Type getServiceTypeThatTakesCollectionsIntoAccount(Type serviceType)
{
if (!typeof(IEnumerable).IsAssignableFrom(serviceType) || serviceType.GetGenericArguments().Length != 1)
if (!typeof(IEnumerable).IsAssignableFrom(serviceType) || serviceType.GetGenericArguments().Length != 1 || serviceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
return serviceType;

Type type = serviceType.GetGenericArguments().Single();
Expand All @@ -507,7 +507,7 @@ private Type getServiceTypeThatTakesCollectionsIntoAccount(Type serviceType)

return isTypeRegistered ? serviceType : type;
}

internal void ClearPlanning()
{
_chain.Clear();
Expand Down
2 changes: 1 addition & 1 deletion src/LamarWithAspNetCore3/LamarWithAspNetCore3.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/MinimalApiTests/MinimalApiTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>

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

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<AssemblyName>StructureMap.Testing.ExeWidget</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>StructureMap.Testing.ExeWidget</PackageId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<AssemblyName>StructureMap.Testing.GenericWidgets</AssemblyName>
<PackageId>StructureMap.Testing.GenericWidgets</PackageId>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<AssemblyName>StructureMap.Testing.Widget</AssemblyName>
<PackageId>StructureMap.Testing.Widget</PackageId>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<AssemblyName>StructureMap.Testing.Widget2</AssemblyName>
<PackageId>StructureMap.Testing.Widget2</PackageId>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<AssemblyName>StructureMap.Testing.Widget3</AssemblyName>
<PackageId>StructureMap.Testing.Widget3</PackageId>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<AssemblyName>StructureMap.Testing.Widget4</AssemblyName>
<PackageId>StructureMap.Testing.Widget4</PackageId>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.5' ">1.6.0</NetStandardImplicitPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
<AssemblyName>StructureMap.Testing.Widget5</AssemblyName>
<PackageId>StructureMap.Testing.Widget5</PackageId>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down
2 changes: 1 addition & 1 deletion src/Widget.Core/Widget.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Widget.Instance/Widget.Instance.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Widget.Registration/Widget.Registration.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading