Skip to content

Commit

Permalink
Add support for EF Core 9 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelheer authored Nov 13, 2024
1 parent 36b6d55 commit 48d0145
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/everything.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
framework: [ 'net8.0', 'net6.0' ]
framework: [ 'net9.0', 'net8.0', 'net6.0' ]
include:
- os: windows-latest
framework: net48
Expand All @@ -20,6 +20,7 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Run tests (${{ matrix.framework }})
run: dotnet test --configuration Release --framework ${{ matrix.framework }} --results-directory test-results --settings test.runsettings
- name: Publish coverage
Expand All @@ -39,6 +40,7 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Create packages (w/o version suffix)
run: dotnet pack --configuration Release --include-symbols --property:PackageOutputPath=${{ runner.temp }}\pkg
if: startsWith(github.ref, 'refs/tags/v') == true
Expand Down
11 changes: 3 additions & 8 deletions build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project>

<PropertyGroup>
<LangVersion>12.0</LangVersion>
<AnalysisMode>All</AnalysisMode>
<LangVersion>13.0</LangVersion>
<Nullable>Enable</Nullable>
<VersionPrefix>7.1.0</VersionPrefix>
<VersionPrefix>7.2.0</VersionPrefix>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand All @@ -20,12 +21,6 @@
<Using Include="System.Threading.Tasks" />
</ItemGroup>

<PropertyGroup>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="CLSCompliantAttribute">
<_Parameter1>true</_Parameter1>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "8.0.400"
"version": "9.0.100"
}
}
2 changes: 1 addition & 1 deletion pack.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To support different LINQ implementations, the following flavours are available.
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>http://nein.tech/nein-linq</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>Allow static Expression injection for instance methods.</PackageReleaseNotes>
<PackageReleaseNotes>Added support for EF Core 9.</PackageReleaseNotes>
<PackageTags>LINQ;EF;IX</PackageTags>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PropertyGroup>
<DefaultNamespace>NeinLinq</DefaultNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/NeinLinq.Async/DynamicAsyncQueryable.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CA2263

namespace NeinLinq;

/// <summary>
Expand Down
11 changes: 9 additions & 2 deletions src/NeinLinq.EntityFrameworkCore/EntityQueryCompilerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NeinLinq;

#pragma warning disable CA1812, EF1001
#pragma warning disable CA1812, EF1001, EF9100

internal sealed class EntityQueryCompilerAdapter<TInnerCompiler> : IQueryCompiler
where TInnerCompiler : IQueryCompiler
Expand All @@ -29,11 +29,18 @@ public Func<QueryContext, TResult> CreateCompiledQuery<TResult>(Expression query
public Func<QueryContext, TResult> CreateCompiledAsyncQuery<TResult>(Expression query)
=> innerCompiler.CreateCompiledQuery<TResult>(RewriteQuery(query));

public Expression<Func<QueryContext, TResult>> PrecompileQuery<TResult>(Expression query, bool async)
#if NET9_0_OR_GREATER
=> innerCompiler.PrecompileQuery<TResult>(RewriteQuery(query), async);
#else
=> throw new NotSupportedException(".NET 9.0 or greater only.");
#endif

private readonly ExpressionVisitor cleaner
= new RewriteQueryCleaner();

private Expression RewriteQuery(Expression query)
=> options.Rewriters.Prepend(cleaner).Aggregate(query, (q, r) => r.Visit(q));
}

#pragma warning restore CA1812, EF1001
#pragma warning restore CA1812, EF1001, EF9100
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public TResult Execute<TResult>(Expression query)

public TResult ExecuteAsync<TResult>(Expression query, CancellationToken cancellationToken)
=> throw new NotSupportedException();

public Expression<Func<QueryContext, TResult>> PrecompileQuery<TResult>(Expression query, bool async)
=> throw new NotSupportedException();
}
}

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

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

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

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

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/NeinLinq/DynamicExpression.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CA2263

namespace NeinLinq;

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/NeinLinq/DynamicQuery.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CA2263

namespace NeinLinq;

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/NeinLinq/DynamicQueryable.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CA2263

namespace NeinLinq;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/NeinLinq/NeinLinq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net48' ">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

<PropertyGroup>
<DefaultNamespace>NeinLinq.Tests</DefaultNamespace>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
</ItemGroup>

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

namespace NeinLinq.Tests;

public class TestConfiguration : DbConfiguration, IDbConnectionFactory
internal class TestConfiguration : DbConfiguration, IDbConnectionFactory
{
public TestConfiguration()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
</ItemGroup>

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

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

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

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

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/NeinLinq.Tests/DynamicQueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private class Model
public OneTwo? OneTwoMaybe { get; set; }
}

public enum OneTwo
private enum OneTwo
{
Undefined = 0,
One = 1,
Expand Down
2 changes: 2 additions & 0 deletions test/NeinLinq.Tests/NullsafeQueryTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Xunit;

#pragma warning disable CA1859

namespace NeinLinq.Tests;

public class NullsafeQueryTest
Expand Down

0 comments on commit 48d0145

Please sign in to comment.