Skip to content
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

Enable net7 testing #130

Merged
merged 11 commits into from
Dec 2, 2022
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
10 changes: 6 additions & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
- name: Build
run: dotnet build src
- name: Test
Expand All @@ -48,12 +48,14 @@ jobs:
needs: build
strategy:
matrix:
sdk: [5.0.x, 6.0.x]
sdk: [6.0.x]
# https://github.com/microsoft/MSBuildSdks/issues/412
# sdk: [6.0.x, 7.0.x]
include:
- sdk: 5.0.x
tfm: net5.0
- sdk: 6.0.x
tfm: net6.0
#- sdk: 7.0.x
# tfm: net7.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,13 @@ When the scope is disposed all `IDisposable` and `IAsyncDisposable` services tha

### Generic registration attributes

You can use generic attributes to register services if your project targets `net6.0` and has `LangVersion` set to preview.
You can use generic attributes to register services if your project targets `net7.0` or `net6.0` and has `LangVersion` set to preview.

```xml
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<LangVersion>preview</TargetFrameworks>
<TargetFrameworks>net7.0</TargetFrameworks>
</PropertyGroup>

</Project>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"msbuild-sdks": {
"Microsoft.Build.Traversal": "3.0.23"
"Microsoft.Build.Traversal": "3.2.0"
}
}
7 changes: 4 additions & 3 deletions src/Jab.FunctionalTests.Common/Jab.FunctionalTest.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project>

<PropertyGroup>
<FunctionalTestTargetFrameworks Condition="'$(FunctionalTestTargetFrameworks)' != ''">$(FunctionalTestTargetFrameworks)</FunctionalTestTargetFrameworks>
<FunctionalTestTargetFrameworks>netcoreapp3.1;net5.0;net6.0;netstandard2.0</FunctionalTestTargetFrameworks>
<DefaultFunctionalTestTargetFrameworks>netcoreapp3.1;net6.0;net7.0;netstandard2.0</DefaultFunctionalTestTargetFrameworks>
<DefaultFunctionalTestTargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))" >$(DefaultFunctionalTestTargetFrameworks);net472</DefaultFunctionalTestTargetFrameworks>
<FunctionalTestTargetFrameworks Condition="'$(FunctionalTestTargetFrameworks)' == ''">$(DefaultFunctionalTestTargetFrameworks)</FunctionalTestTargetFrameworks>
<IsPackable>false</IsPackable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down Expand Up @@ -35,7 +36,7 @@

<Target Name="DefineJabPreview" BeforeTargets="CoreCompile" Condition="'$(FunctionalTestPackageVersion)' == ''">
<PropertyGroup>
<DefineConstants>$(DefineConstants);JAB_PREVIEW</DefineConstants>
<DefineConstants>$(DefineConstants);GENERIC_ATTRIBUTES</DefineConstants>
</PropertyGroup>
</Target>

Expand Down
10 changes: 5 additions & 5 deletions src/Jab.FunctionalTests.Common/Jab.FunctionalTests.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<Import Project="$(MSBuildThisFileDirectory)/Jab.FunctionalTest.props" />

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" Condition="'$(TargetFramework)' != 'netstandard2.0'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" Condition="'$(TargetFramework)' != 'netstandard2.0'">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.0.1-beta1.20623.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />

<ProjectReference Include="..\Jab.FunctionalTests.Module\Jab.FunctionalTests.Module.csproj" />
<Compile Include="$(MSBuildThisFileDirectory)\**\*.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Jab.Performance/Jab.Performance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
12 changes: 6 additions & 6 deletions src/Jab.Tests/Jab.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<ProjectReference Include="..\Jab\Jab.csproj" />

<Content Include="..\Jab\Attributes.cs" CopyToOutputDirectory="PreserveNewest" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.0.1-beta1.20623.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="1.1.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions src/Jab/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ScopedAttribute(Type serviceType, Type implementationType)
}
}

#if JAB_PREVIEW
#if GENERIC_ATTRIBUTES
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
internal class ImportAttribute<TModule> : ImportAttribute
{
Expand All @@ -112,7 +112,7 @@ public TransientAttribute() : base(typeof(TService))
}

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
internal class TransientAttribute<TService, TImpl> : TransientAttribute
internal class TransientAttribute<TService, TImpl> : TransientAttribute where TImpl: TService
{
public TransientAttribute() : base(typeof(TService), typeof(TImpl))
{
Expand All @@ -128,7 +128,7 @@ public ScopedAttribute() : base(typeof(TService))
}

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
internal class ScopedAttribute<TService, TImpl> : ScopedAttribute
internal class ScopedAttribute<TService, TImpl> : ScopedAttribute where TImpl: TService
{
public ScopedAttribute() : base(typeof(TService), typeof(TImpl))
{
Expand All @@ -145,7 +145,7 @@ public SingletonAttribute() : base(typeof(TService))
}

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
internal class SingletonAttribute<TService, TImpl> : SingletonAttribute
internal class SingletonAttribute<TService, TImpl> : SingletonAttribute where TImpl: TService
{
public SingletonAttribute() : base(typeof(TService), typeof(TImpl))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Jab/Properties/launchSettings.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Jab/build/Jab.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<DefineConstants Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND
($([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '7.0')) OR
($([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0')) AND '$(LangVersion)'=='preview'))">$(DefineConstants);JAB_PREVIEW</DefineConstants>
($([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0')) AND '$(LangVersion)'=='preview'))">$(DefineConstants);GENERIC_ATTRIBUTES</DefineConstants>
</PropertyGroup>
<Target Name="_JabMultiTargetRoslyn3"
Condition="'$(SupportsRoslynComponentVersioning)' != 'true'"
Expand Down