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

Add support for EF Core 9 #54

Merged
merged 6 commits into from
Nov 13, 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
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> 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);

Check warning on line 34 in src/NeinLinq.EntityFrameworkCore/EntityQueryCompilerAdapter.cs

View check run for this annotation

Codecov / codecov/patch

src/NeinLinq.EntityFrameworkCore/EntityQueryCompilerAdapter.cs#L34

Added line #L34 was not covered by tests
#else
=> throw new NotSupportedException(".NET 9.0 or greater only.");

Check warning on line 36 in src/NeinLinq.EntityFrameworkCore/EntityQueryCompilerAdapter.cs

View check run for this annotation

Codecov / codecov/patch

src/NeinLinq.EntityFrameworkCore/EntityQueryCompilerAdapter.cs#L36

Added line #L36 was not covered by tests
#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 ExecuteAsync<TResult>(Expression query, CancellationToken cancellationToken)
=> throw new NotSupportedException();

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

Check warning on line 50 in src/NeinLinq.EntityFrameworkCore/EntityQueryProviderAdapter.cs

View check run for this annotation

Codecov / codecov/patch

src/NeinLinq.EntityFrameworkCore/EntityQueryProviderAdapter.cs#L50

Added line #L50 was not covered by tests
}
}

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