Skip to content

Commit

Permalink
Sync to EF 8.0.0-preview.7
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Aug 18, 2023
1 parent 9a94b91 commit 2380c06
Show file tree
Hide file tree
Showing 39 changed files with 450 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
pull_request:

env:
dotnet_sdk_version: '8.0.100-preview.2.23153.6'
dotnet_sdk_version: '8.0.100-preview.7.23376.3'
postgis_version: 3
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
- cron: '30 22 * * 6'

env:
dotnet_sdk_version: '8.0.100-preview.2.23153.6'
dotnet_sdk_version: '8.0.100-preview.7.23376.3'

jobs:
analyze:
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>8.0.0-preview.5</VersionPrefix>
<VersionPrefix>8.0.0-preview.7</VersionPrefix>
<LangVersion>preview</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>latest</AnalysisLevel>
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<EFCoreVersion>8.0.0-preview.4.23259.3</EFCoreVersion>
<MicrosoftExtensionsVersion>8.0.0-preview.4.23259.5</MicrosoftExtensionsVersion>
<EFCoreVersion>8.0.0-preview.7.23375.4</EFCoreVersion>
<MicrosoftExtensionsVersion>8.0.0-preview.7.23375.6</MicrosoftExtensionsVersion>
<NpgsqlVersion>8.0.0-preview.4</NpgsqlVersion>
</PropertyGroup>

Expand Down
1 change: 1 addition & 0 deletions EFCore.PG.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_USINGS_STMT/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_RAW_LITERAL_STRING/@EntryValue">DO_NOT_CHANGE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INITIALIZER_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100-preview.4.23260.5",
"version": "8.0.100-preview.7.23376.3",
"rollForward": "latestMajor",
"allowPrerelease": "true"
}
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.PG.NTS/EFCore.PG.NTS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite</AssemblyName>
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework Condition="'$(DeveloperBuild)' == 'True'">net8.0</TargetFramework>

<Authors>Shay Rojansky</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public virtual NpgsqlDbType NpgsqlDbType
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public NpgsqlGeometryTypeMapping(string storeType, bool isGeography) : base(converter: null, storeType)
public NpgsqlGeometryTypeMapping(string storeType, bool isGeography)
: base(converter: null, NpgsqlJsonGeometryWktReaderWriter.Instance, storeType)
=> _isGeography = isGeography;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text.Json;
using Microsoft.EntityFrameworkCore.Storage.Json;
using NetTopologySuite.Geometries;
using NetTopologySuite.IO;

// ReSharper disable once CheckNamespace
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal;

/// <summary>
/// Reads and writes JSON using the well-known-text format for <see cref="Geometry" /> values.
/// </summary>
public sealed class NpgsqlJsonGeometryWktReaderWriter : JsonValueReaderWriter<Geometry>
{
private static readonly WKTReader WktReader = new();

/// <summary>
/// The singleton instance of this stateless reader/writer.
/// </summary>
public static NpgsqlJsonGeometryWktReaderWriter Instance { get; } = new();

private NpgsqlJsonGeometryWktReaderWriter()
{
}

/// <inheritdoc />
public override Geometry FromJsonTyped(ref Utf8JsonReaderManager manager)
=> WktReader.Read(manager.CurrentReader.GetString());

/// <inheritdoc />
public override void ToJsonTyped(Utf8JsonWriter writer, Geometry value)
=> writer.WriteStringValue(value.ToText());
}
2 changes: 1 addition & 1 deletion src/EFCore.PG.NodaTime/EFCore.PG.NodaTime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime</AssemblyName>
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework Condition="'$(DeveloperBuild)' == 'True'">net8.0</TargetFramework>

<Authors>Shay Rojansky</Authors>
Expand Down
7 changes: 3 additions & 4 deletions src/EFCore.PG/EFCore.PG.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<PropertyGroup>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL</AssemblyName>
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL</RootNamespace>
<TargetFrameworks Condition="'$(DeveloperBuild)' != 'True'">net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFramework Condition="'$(DeveloperBuild)' == 'True'">net8.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<Authors>Shay Rojansky;Austin Drenski;Yoh Deadfall;</Authors>
<Description>PostgreSQL/Npgsql provider for Entity Framework Core.</Description>
Expand All @@ -23,7 +22,7 @@
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Shared\*.cs" />

Expand All @@ -50,5 +49,5 @@
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static PropertyBuilder UseHiLo(

name ??= NpgsqlModelExtensions.DefaultHiLoSequenceName;

var model = property.DeclaringEntityType.Model;
var model = property.DeclaringType.Model;

if (model.FindSequence(name, schema) is null)
{
Expand Down Expand Up @@ -90,7 +90,7 @@ public static PropertyBuilder<TProperty> UseHiLo<TProperty>(

return name is null
? null
: propertyBuilder.Metadata.DeclaringEntityType.Model.Builder.HasSequence(name, schema, fromDataAnnotation);
: propertyBuilder.Metadata.DeclaringType.Model.Builder.HasSequence(name, schema, fromDataAnnotation);
}

/// <summary>
Expand Down Expand Up @@ -191,7 +191,7 @@ public static PropertyBuilder<TProperty> UseSequence<TProperty>(

return name == null
? null
: propertyBuilder.Metadata.DeclaringEntityType.Model.Builder.HasSequence(name, schema, fromDataAnnotation);
: propertyBuilder.Metadata.DeclaringType.Model.Builder.HasSequence(name, schema, fromDataAnnotation);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static void SetHiLoSequenceSchema(this IMutableProperty property, string?
/// <returns> The sequence to use, or <see langword="null" /> if no sequence exists in the model. </returns>
public static IReadOnlySequence? FindHiLoSequence(this IReadOnlyProperty property)
{
var model = property.DeclaringEntityType.Model;
var model = property.DeclaringType.Model;

var sequenceName = property.GetHiLoSequenceName()
?? model.GetHiLoSequenceName();
Expand All @@ -169,7 +169,7 @@ public static void SetHiLoSequenceSchema(this IMutableProperty property, string?
/// <returns> The sequence to use, or <see langword="null" /> if no sequence exists in the model. </returns>
public static IReadOnlySequence? FindHiLoSequence(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
{
var model = property.DeclaringEntityType.Model;
var model = property.DeclaringType.Model;

var sequenceName = property.GetHiLoSequenceName(storeObject)
?? model.GetHiLoSequenceName();
Expand Down Expand Up @@ -352,7 +352,7 @@ public static void SetSequenceSchema(this IMutableProperty property, string? sch
/// <returns>The sequence to use, or <see langword="null" /> if no sequence exists in the model.</returns>
public static IReadOnlySequence? FindSequence(this IReadOnlyProperty property)
{
var model = property.DeclaringEntityType.Model;
var model = property.DeclaringType.Model;

var sequenceName = property.GetSequenceName()
?? model.GetSequenceNameSuffix();
Expand All @@ -371,7 +371,7 @@ public static void SetSequenceSchema(this IMutableProperty property, string? sch
/// <returns>The sequence to use, or <see langword="null" /> if no sequence exists in the model.</returns>
public static IReadOnlySequence? FindSequence(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)
{
var model = property.DeclaringEntityType.Model;
var model = property.DeclaringType.Model;

var sequenceName = property.GetSequenceName(storeObject)
?? model.GetSequenceNameSuffix();
Expand Down Expand Up @@ -458,7 +458,7 @@ internal static NpgsqlValueGenerationStrategy GetValueGenerationStrategy(

var annotation = property.FindAnnotation(NpgsqlAnnotationNames.ValueGenerationStrategy);
if (annotation?.Value != null
&& StoreObjectIdentifier.Create(property.DeclaringEntityType, storeObject.StoreObjectType) == storeObject)
&& StoreObjectIdentifier.Create(property.DeclaringType, storeObject.StoreObjectType) == storeObject)
{
return (NpgsqlValueGenerationStrategy)annotation.Value;
}
Expand Down Expand Up @@ -525,7 +525,7 @@ is StoreObjectIdentifier principal

private static NpgsqlValueGenerationStrategy GetDefaultValueGenerationStrategy(IReadOnlyProperty property)
{
var modelStrategy = property.DeclaringEntityType.Model.GetValueGenerationStrategy();
var modelStrategy = property.DeclaringType.Model.GetValueGenerationStrategy();

switch (modelStrategy)
{
Expand All @@ -550,7 +550,7 @@ private static NpgsqlValueGenerationStrategy GetDefaultValueGenerationStrategy(
in StoreObjectIdentifier storeObject,
ITypeMappingSource? typeMappingSource)
{
var modelStrategy = property.DeclaringEntityType.Model.GetValueGenerationStrategy();
var modelStrategy = property.DeclaringType.Model.GetValueGenerationStrategy();

switch (modelStrategy)
{
Expand All @@ -565,7 +565,7 @@ private static NpgsqlValueGenerationStrategy GetDefaultValueGenerationStrategy(
case NpgsqlValueGenerationStrategy.IdentityByDefaultColumn:
return !IsCompatibleWithValueGeneration(property, storeObject, typeMappingSource)
? NpgsqlValueGenerationStrategy.None
: property.DeclaringEntityType.GetMappingStrategy() == RelationalAnnotationNames.TpcMappingStrategy
: property.DeclaringType.GetMappingStrategy() == RelationalAnnotationNames.TpcMappingStrategy
? NpgsqlValueGenerationStrategy.Sequence
: modelStrategy.Value;

Expand Down Expand Up @@ -682,15 +682,15 @@ private static void CheckValueGenerationStrategy(IReadOnlyProperty property, Npg
{
throw new ArgumentException(
NpgsqlStrings.IdentityBadType(
property.Name, property.DeclaringEntityType.DisplayName(), propertyType.ShortDisplayName()));
property.Name, property.DeclaringType.DisplayName(), propertyType.ShortDisplayName()));
}

if (value is NpgsqlValueGenerationStrategy.SerialColumn or NpgsqlValueGenerationStrategy.SequenceHiLo
&& !IsCompatibleWithValueGeneration(property))
{
throw new ArgumentException(
NpgsqlStrings.SequenceBadType(
property.Name, property.DeclaringEntityType.DisplayName(), propertyType.ShortDisplayName()));
property.Name, property.DeclaringType.DisplayName(), propertyType.ShortDisplayName()));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.PG/Infrastructure/Internal/NpgsqlModelValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected virtual void ValidateIdentityVersionCompatibility(IModel model)
or NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
{
throw new InvalidOperationException(
$"{property.DeclaringEntityType}.{property.Name}: '{propertyStrategy}' requires PostgreSQL 10.0 or later.");
$"{property.DeclaringType}.{property.Name}: '{propertyStrategy}' requires PostgreSQL 10.0 or later.");
}
}
}
Expand Down Expand Up @@ -221,9 +221,9 @@ protected override void ValidateCompatible(
{
throw new InvalidOperationException(
NpgsqlStrings.DuplicateColumnCompressionMethodMismatch(
duplicateProperty.DeclaringEntityType.DisplayName(),
duplicateProperty.DeclaringType.DisplayName(),
duplicateProperty.Name,
property.DeclaringEntityType.DisplayName(),
property.DeclaringType.DisplayName(),
property.Name,
columnName,
storeObject.DisplayName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool IsStrategyNoneNeeded(IReadOnlyProperty property, StoreObjectIdentifier stor
&& !property.TryGetDefaultValue(storeObject, out _)
&& property.GetDefaultValueSql(storeObject) is null
&& property.GetComputedColumnSql(storeObject) is null
&& property.DeclaringEntityType.Model.GetValueGenerationStrategy() != NpgsqlValueGenerationStrategy.None)
&& property.DeclaringType.Model.GetValueGenerationStrategy() != NpgsqlValueGenerationStrategy.None)
{
var providerClrType = (property.GetValueConverter()
?? (property.FindRelationalTypeMapping(storeObject)
Expand All @@ -116,4 +116,4 @@ bool IsStrategyNoneNeeded(IReadOnlyProperty property, StoreObjectIdentifier stor
return false;
}
}
}
}
6 changes: 3 additions & 3 deletions src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override IEnumerable<IAnnotation> For(ITable table, bool designTime)
}

// Model validation ensures that these facets are the same on all mapped entity types
var entityType = table.EntityTypeMappings.First().EntityType;
var entityType = (IEntityType)table.EntityTypeMappings.First().TypeBase;

if (entityType.GetIsUnlogged())
{
Expand Down Expand Up @@ -70,7 +70,7 @@ public override IEnumerable<IAnnotation> For(IColumn column, bool designTime)
var table = StoreObjectIdentifier.Table(column.Table.Name, column.Table.Schema);
var valueGeneratedProperty = column.PropertyMappings.Where(
m => (m.TableMapping.IsSharedTablePrincipal ?? true)
&& m.TableMapping.EntityType == m.Property.DeclaringEntityType)
&& m.TableMapping.TypeBase == m.Property.DeclaringType)
.Select(m => m.Property)
.FirstOrDefault(
p => p.GetValueGenerationStrategy(table) switch
Expand Down Expand Up @@ -124,7 +124,7 @@ public override IEnumerable<IAnnotation> For(IColumn column, bool designTime)
yield return new Annotation(
NpgsqlAnnotationNames.TsVectorProperties,
valueGeneratedProperty.GetTsVectorProperties()!
.Select(p2 => valueGeneratedProperty.DeclaringEntityType.FindProperty(p2)!.GetColumnName(tableIdentifier))
.Select(p2 => valueGeneratedProperty.DeclaringType.FindProperty(p2)!.GetColumnName(tableIdentifier))
.ToArray());
}

Expand Down
Loading

0 comments on commit 2380c06

Please sign in to comment.