Skip to content

Commit

Permalink
new framework targets
Browse files Browse the repository at this point in the history
  • Loading branch information
msmolka committed Dec 15, 2024
1 parent 242e562 commit 5b986e8
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 54 deletions.
36 changes: 13 additions & 23 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,21 @@ jobs:

strategy:
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
steps:
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '3.1.x'
- name: Setup .NET 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
9.0.x
- name: Checkout
uses: actions/checkout@v2
- name: Build with dotnet for .NET CORE 3.1
run: dotnet build ./src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/ZNetCS.AspNetCore.Logging.EntityFrameworkCore.csproj --configuration Release --framework netcoreapp3.1
- name: Build with dotnet for .NET 5.0
run: dotnet build ./src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/ZNetCS.AspNetCore.Logging.EntityFrameworkCore.csproj --configuration Release --framework net5.0
- name: Build with dotnet for .NET 6.0
run: dotnet build ./src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/ZNetCS.AspNetCore.Logging.EntityFrameworkCore.csproj --configuration Release --framework net6.0
- name: Test with dotnet for .NET CORE 3.1
run: dotnet test ./test/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest.csproj --framework netcoreapp3.1
- name: Test with dotnet for .NET 5.0
run: dotnet test ./test/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest.csproj --framework net5.0
uses: actions/checkout@v4
- name: Build
run: dotnet build ./src/ZNetCS.AspNetCore.Logging.EntityFrameworkCore/ZNetCS.AspNetCore.Logging.EntityFrameworkCore.csproj --configuration Release
- name: Test with dotnet for .NET 6.0
run: dotnet test ./test/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest.csproj --framework net6.0
run: dotnet test ./test/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest/ZNetCS.AspNetCore.Logging.EntityFrameworkCoreTest.csproj --configuration Release
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ When you install the package, it should be added to your `.csproj`. Alternativel

```xml
<ItemGroup>
<PackageReference Include="ZNetCS.AspNetCore.Logging.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="ZNetCS.AspNetCore.Logging.EntityFrameworkCore" Version="9.0.0" />
</ItemGroup>
```

Expand Down
5 changes: 5 additions & 0 deletions ZNetCS.AspNetCore.Logging.EntityFrameworkCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{AF9B71
stylecop.json = stylecop.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pipelines", "pipelines", "{C8D4A1FB-8EC8-4367-8DFD-301523638B26}"
ProjectSection(SolutionItems) = preProject
.github\workflows\dotnetcore.yml = .github\workflows\dotnetcore.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
10 changes: 5 additions & 5 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Version>6.0.0</Version>
<PackageReleaseNotes>Breaking Change: Drop support for netstandard and .net framework. Code refactoring. Dependency update. Nullable enable.</PackageReleaseNotes>
<Version>9.0.0</Version>
<PackageReleaseNotes>Added support for .net core 7, 8, and 9</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -43,12 +43,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all"/>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all"/>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ public EntityFrameworkLogger(

#region ILogger

/// <inheritdoc/>
public virtual IDisposable BeginScope<TState>(TState state) => NoopDisposable.Instance;

/// <inheritdoc/>
public virtual bool IsEnabled(LogLevel logLevel)
{
Expand All @@ -200,6 +197,11 @@ public virtual bool IsEnabled(LogLevel logLevel)
return (logLevel != LogLevel.None) && this.filter(this.Name, logLevel);
}

/// <inheritdoc />
#pragma warning disable CS8633
public IDisposable BeginScope<TState>(TState state) where TState : notnull => NoopDisposable.Instance;
#pragma warning restore CS8633

/// <inheritdoc/>
public virtual void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
Expand Down Expand Up @@ -252,7 +254,7 @@ public virtual void Log<TState>(LogLevel logLevel, EventId eventId, TState state
protected virtual void WriteMessage(string message, LogLevel logLevel, int eventId)
{
// create separate scope for DbContextOptions and DbContext
using IServiceScope? scope = this.serviceProvider.CreateScope();
using IServiceScope scope = this.serviceProvider.CreateScope();

// create separate DbContext for adding log
// normally we should rely on scope context, but in rare scenarios when DbContext is
Expand Down Expand Up @@ -292,7 +294,7 @@ protected virtual void WriteMessage(string message, LogLevel logLevel, int event
private TLog DefaultCreator(int logLevel, int eventId, string logName, string message)
{
// create separate scope for Scope registered dependencies.
using IServiceScope? scope = this.serviceProvider.CreateScope();
using IServiceScope scope = this.serviceProvider.CreateScope();
var log = ActivatorUtilities.CreateInstance<TLog>(scope.ServiceProvider);

log.TimeStamp = DateTimeOffset.Now;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,31 @@

<PropertyGroup>
<AssemblyName>ZNetCS.AspNetCore.Logging.EntityFrameworkCore</AssemblyName>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.22"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.32"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.13"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.17"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.36"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Copyright>Marcin Smółka</Copyright>
<Authors>Marcin Smółka</Authors>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand All @@ -15,40 +15,58 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.22" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.22" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.22" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.32" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.32" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.32" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.13" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.137" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.17" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.36" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.36" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.36" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.20" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.11" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 5b986e8

Please sign in to comment.