Skip to content

Commit

Permalink
Use target frameworks net7 and net8, and use respective major version…
Browse files Browse the repository at this point in the history
… of NuGet packages
  • Loading branch information
sorensenmatias committed Mar 3, 2024
1 parent 510c6bd commit 5a5486d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Tests/Hosting/HostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void ApplicationBuilder_BasicReporting()
duplicates.Should().Contain("ServiceProviderValidationExtensions.Tests.Hosting.HostTests+IMyService is registered 2 times");
}

#if NET8_0_OR_GREATER
[Fact]
public void EmptyApplicationBuilder_TriggersValidation()
{
Expand All @@ -91,6 +92,7 @@ public void EmptyApplicationBuilder_TriggersValidation()
.ThrowExactly<ServiceProviderValidationException>()
.WithMessage("ServiceProvider validation failed with the following errors:\r\n\r\nService IMyService is exclusive, but is registered 2 times.");
}
#endif

public interface IMyService
{
Expand Down
11 changes: 8 additions & 3 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
<PropertyGroup>
<AssemblyName>ServiceProviderValidationExtensions.Tests</AssemblyName>
<RootNamespace>ServiceProviderValidationExtensions.Tests</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<LangVersion>11.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<LangVersion>11.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

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

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
</ItemGroup>

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


<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions tests/Hosting/HostFullReportingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void ConfigureReporting(ReportConfigurer rb)
rb.OnDuplicateService(
dsc => duplicateServiceReports.Add($"{dsc.ServiceType.DisplayName} is registered {dsc.ImplementationTypes.Count} times"),
c => c.Except(typeof(IConfigureOptions<>))
#if NET8_0_OR_GREATER
.Except(typeof(IStartupValidator))
#endif
.Except(typeof(IOptionsChangeTokenSource<>))
.Except<ILoggerProvider>());
}
Expand Down

0 comments on commit 5a5486d

Please sign in to comment.