Skip to content

Commit

Permalink
Try previews of .NET/EF 9
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoelman committed Oct 10, 2024
1 parent b09dc7e commit e1aa16a
Show file tree
Hide file tree
Showing 40 changed files with 119 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2024.2.5",
"version": "2024.3.0-eap03",
"commands": [
"jb"
],
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
dotnet-quality: 'preview'
- name: Show installed versions
shell: pwsh
run: |
Expand Down Expand Up @@ -166,6 +168,8 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
dotnet-quality: 'preview'
- name: Git checkout
uses: actions/checkout@v4
- name: Restore tools
Expand Down Expand Up @@ -221,6 +225,8 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
dotnet-quality: 'preview'
- name: Git checkout
uses: actions/checkout@v4
with:
Expand All @@ -233,6 +239,9 @@ jobs:
dotnet restore
- name: CleanupCode (on PR diff)
if: github.event_name == 'pull_request'
# env:
# # Workaround for https://github.com/dotnet/runtime/issues/64103
# COMPlus_ReadyToRun: 0
shell: pwsh
run: |
# Not using the environment variables for SHAs, because they may be outdated. This may happen on force-push after the build is queued, but before it starts.
Expand All @@ -244,6 +253,9 @@ jobs:
dotnet regitlint -s JsonApiDotNetCore.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="JADNC Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
- name: CleanupCode (on branch)
if: github.event_name == 'push' || github.event_name == 'release'
# env:
# # Workaround for https://github.com/dotnet/runtime/issues/64103
# COMPlus_ReadyToRun: 0
shell: pwsh
run: |
Write-Output "Running code cleanup on all files."
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
dotnet-version: |
6.0.x
8.0.x
9.0.x
dotnet-quality: 'preview'
- name: Git checkout
uses: actions/checkout@v4
- name: Initialize CodeQL
Expand Down
9 changes: 8 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
Expand Down Expand Up @@ -38,6 +38,12 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn);NU5104;NU1608</NoWarn>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<NuGetAuditMode>direct</NuGetAuditMode>
</PropertyGroup>

<PropertyGroup Condition="$(MSBuildProjectName.EndsWith('Tests'))">
<NoWarn>$(NoWarn);CA1707;CA1062</NoWarn>
</PropertyGroup>
Expand All @@ -55,6 +61,7 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.2.*" PrivateAssets="All" />
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.*" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0-preview.24454.1" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CSharpGuidelinesAnalyzer.config" Visible="False" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
<add key="npgsql" value="https://www.myget.org/F/npgsql/api/v3/index.json" />
<add key="npgsql-next" value="https://www.myget.org/F/npgsql-vnext/api/v3/index.json" />
<add key="pomelo-nightly"
value="https://pkgs.dev.azure.com/pomelo-efcore/Pomelo.EntityFrameworkCore.MySql/_packaging/pomelo-efcore-public/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
2 changes: 1 addition & 1 deletion benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/QueryString/QueryStringParserBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public QueryStringParserBenchmarks()

var request = new JsonApiRequest
{
PrimaryResourceType = resourceGraph.GetResourceType(typeof(QueryableResource)),
PrimaryResourceType = resourceGraph.GetResourceType<QueryableResource>(),
IsCollection = true
};

Expand Down
16 changes: 16 additions & 0 deletions package-versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,27 @@
<XunitVisualStudioVersion>2.8.*</XunitVisualStudioVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0'">
<!-- Published dependencies (only update on major version change) -->
<EntityFrameworkCoreFrozenVersion>9.0.0-rtm.24508.5</EntityFrameworkCoreFrozenVersion>

<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
<AspNetCoreVersion>9.0.*-*</AspNetCoreVersion>
<EntityFrameworkCoreVersion>$(EntityFrameworkCoreFrozenVersion)</EntityFrameworkCoreVersion>
<EntityFrameworkCorePostgreSQLVersion>9.0.0-rc.2-ci.20240930T080442</EntityFrameworkCorePostgreSQLVersion>
<EntityFrameworkCorePomeloVersion>9.0.0-*</EntityFrameworkCorePomeloVersion>
<SystemTextJsonVersion>$(AspNetCoreVersion)</SystemTextJsonVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<!-- Published dependencies (only update on major version change) -->
<EntityFrameworkCoreFrozenVersion>8.0.0</EntityFrameworkCoreFrozenVersion>

<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->
<AspNetCoreVersion>8.0.*</AspNetCoreVersion>
<EntityFrameworkCoreVersion>8.0.*</EntityFrameworkCoreVersion>
<EntityFrameworkCorePostgreSQLVersion>$(EntityFrameworkCoreVersion)</EntityFrameworkCorePostgreSQLVersion>
<EntityFrameworkCorePomeloVersion>$(EntityFrameworkCoreVersion)</EntityFrameworkCorePomeloVersion>
<SystemTextJsonVersion>$(AspNetCoreVersion)</SystemTextJsonVersion>
</PropertyGroup>

Expand All @@ -38,6 +52,8 @@
<AspNetCoreVersion>6.0.*</AspNetCoreVersion>
<DateOnlyTimeOnlyVersion>2.1.*</DateOnlyTimeOnlyVersion>
<EntityFrameworkCoreVersion>7.0.*</EntityFrameworkCoreVersion>
<EntityFrameworkCorePostgreSQLVersion>$(EntityFrameworkCoreVersion)</EntityFrameworkCorePostgreSQLVersion>
<EntityFrameworkCorePomeloVersion>$(EntityFrameworkCoreVersion)</EntityFrameworkCorePomeloVersion>
<SystemTextJsonVersion>8.0.*</SystemTextJsonVersion>
</PropertyGroup>
</Project>
7 changes: 4 additions & 3 deletions src/Examples/DapperExample/DapperExample.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand All @@ -14,8 +14,9 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="$(DapperVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EntityFrameworkCorePostgreSQLVersion)" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="$(EntityFrameworkCorePomeloVersion)" />
</ItemGroup>
</Project>
9 changes: 7 additions & 2 deletions src/Examples/DapperExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@
}
case DatabaseProvider.MySql:
{
builder.Services.AddMySql<AppDbContext>(connectionString, ServerVersion.AutoDetect(connectionString),
optionsAction: options => SetDbContextDebugOptions(options));
#if NET9_0_OR_GREATER
ServerVersion serverVersion = await ServerVersion.AutoDetectAsync(connectionString);
#else
ServerVersion serverVersion = ServerVersion.AutoDetect(connectionString);
#endif

builder.Services.AddMySql<AppDbContext>(connectionString, serverVersion, optionsAction: options => SetDbContextDebugOptions(options));

break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public async Task DeleteAsync(TResource? resourceFromDatabase, [DisallowNull] TI
await _resourceDefinitionAccessor.OnWritingAsync(placeholderResource, WriteOperationKind.DeleteResource, cancellationToken);

var deleteBuilder = new DeleteResourceStatementBuilder(_dataModelService);
DeleteNode deleteNode = deleteBuilder.Build(ResourceType, placeholderResource.Id!);
DeleteNode deleteNode = deleteBuilder.Build(ResourceType, placeholderResource.Id);
CommandDefinition sqlCommand = _dapperFacade.GetSqlCommand(deleteNode, cancellationToken);

await ExecuteInTransactionAsync(async transaction =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand All @@ -13,6 +13,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EntityFrameworkCorePostgreSQLVersion)" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Examples/GettingStarted/GettingStarted.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand All @@ -13,6 +13,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EntityFrameworkCoreVersion)" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(EntityFrameworkCorePostgreSQLVersion)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/ReportsExample/ReportsExample.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\..\package-versions.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netstandard1.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0;netstandard2.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RootNamespace>JsonApiDotNetCore</RootNamespace>
Expand Down Expand Up @@ -31,17 +31,17 @@

<!-- We multi-target against NetStandard solely to enable consumers to share their models project with .NET Framework code. -->

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<Using Remove="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<Compile Remove="**/*.cs" />
<Compile Include="**/*.shared.cs" />
<Compile Include="**/*.netstandard.cs" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.0' ">
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
<Compile Remove="**/*.netstandard.cs" />
<None Include="**/*.netstandard.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/JsonApiDotNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Middleware/TraceLogWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public override void Write(Utf8JsonWriter writer, TWrapper value, JsonSerializer

internal sealed partial class TraceLogWriter<T>(ILoggerFactory loggerFactory) : TraceLogWriter
{
private readonly ILogger _logger = loggerFactory.CreateLogger(typeof(T));
private readonly ILogger _logger = loggerFactory.CreateLogger<T>();

public void LogMethodStart(object? parameters = null, [CallerMemberName] string memberName = "")
{
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Queries/QueryLayerComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public QueryLayer ComposeForUpdate<TId>([DisallowNull] TId id, ResourceType prim
{
ArgumentGuard.NotNull(primaryResourceType);

IImmutableSet<IncludeElementExpression> includeElements = _targetedFields.Relationships
ImmutableHashSet<IncludeElementExpression> includeElements = _targetedFields.Relationships
.Select(relationship => new IncludeElementExpression(relationship)).ToImmutableHashSet();

AttrAttribute primaryIdAttribute = GetIdAttribute(primaryResourceType);
Expand Down
2 changes: 1 addition & 1 deletion test/AnnotationTests/AnnotationTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\package-versions.props" />
Expand Down
2 changes: 1 addition & 1 deletion test/DapperTests/DapperTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\package-versions.props" />
Expand Down
2 changes: 1 addition & 1 deletion test/DiscoveryTests/DiscoveryTests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
</PropertyGroup>

<Import Project="..\..\package-versions.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>

PropertyInfo? property = typeof(WorkItem).GetProperty(nameof(Identifiable<object>.Id));
property.ShouldNotBeNull();
property.PropertyType.Should().Be(typeof(int));
property.PropertyType.Should().Be<int>();
}

[Fact]
Expand Down Expand Up @@ -162,7 +162,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>

PropertyInfo? property = typeof(UserAccount).GetProperty(nameof(Identifiable<object>.Id));
property.ShouldNotBeNull();
property.PropertyType.Should().Be(typeof(long));
property.PropertyType.Should().Be<long>();
}

[Fact]
Expand Down Expand Up @@ -207,7 +207,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>

PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable<object>.Id));
property.ShouldNotBeNull();
property.PropertyType.Should().Be(typeof(Guid));
property.PropertyType.Should().Be<Guid>();
}

[Fact]
Expand Down
Loading

0 comments on commit e1aa16a

Please sign in to comment.