diff --git a/EFCore.PG.sln b/EFCore.PG.sln index d1e61fc97..dd965ca0d 100644 --- a/EFCore.PG.sln +++ b/EFCore.PG.sln @@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md NuGet.config = NuGet.config global.json = global.json + .editorconfig = .editorconfig EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}" diff --git a/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteAggregateMethodCallTranslatorPlugin.cs b/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteAggregateMethodCallTranslatorPlugin.cs index 6843da9df..c3a57fffa 100644 --- a/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteAggregateMethodCallTranslatorPlugin.cs +++ b/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteAggregateMethodCallTranslatorPlugin.cs @@ -52,16 +52,16 @@ public NpgsqlNetTopologySuiteAggregateMethodCallTranslatorPlugin( public class NpgsqlNetTopologySuiteAggregateMethodTranslator : IAggregateMethodCallTranslator { private static readonly MethodInfo GeometryCombineMethod - = typeof(GeometryCombiner).GetRuntimeMethod(nameof(GeometryCombiner.Combine), new[] { typeof(IEnumerable) })!; + = typeof(GeometryCombiner).GetRuntimeMethod(nameof(GeometryCombiner.Combine), [typeof(IEnumerable)])!; private static readonly MethodInfo ConvexHullMethod - = typeof(ConvexHull).GetRuntimeMethod(nameof(ConvexHull.Create), new[] { typeof(IEnumerable) })!; + = typeof(ConvexHull).GetRuntimeMethod(nameof(ConvexHull.Create), [typeof(IEnumerable)])!; private static readonly MethodInfo UnionMethod - = typeof(UnaryUnionOp).GetRuntimeMethod(nameof(UnaryUnionOp.Union), new[] { typeof(IEnumerable) })!; + = typeof(UnaryUnionOp).GetRuntimeMethod(nameof(UnaryUnionOp.Union), [typeof(IEnumerable)])!; private static readonly MethodInfo EnvelopeCombineMethod - = typeof(EnvelopeCombiner).GetRuntimeMethod(nameof(EnvelopeCombiner.CombineAsGeometry), new[] { typeof(IEnumerable) })!; + = typeof(EnvelopeCombiner).GetRuntimeMethod(nameof(EnvelopeCombiner.CombineAsGeometry), [typeof(IEnumerable)])!; private readonly NpgsqlSqlExpressionFactory _sqlExpressionFactory; private readonly IRelationalTypeMappingSource _typeMappingSource; diff --git a/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMemberTranslatorPlugin.cs b/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMemberTranslatorPlugin.cs index 95726cb29..1ab9fd45b 100644 --- a/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMemberTranslatorPlugin.cs +++ b/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMemberTranslatorPlugin.cs @@ -44,7 +44,7 @@ public class NpgsqlGeometryMemberTranslator : IMemberTranslator private readonly IRelationalTypeMappingSource _typeMappingSource; private readonly CaseWhenClause[] _ogcGeometryTypeWhenThenList; - private static readonly bool[][] TrueArrays = { Array.Empty(), new[] { true }, new[] { true, true }, new[] { true, true, true } }; + private static readonly bool[][] TrueArrays = [[], [true], [true, true], [true, true, true]]; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -59,8 +59,8 @@ public NpgsqlGeometryMemberTranslator( _sqlExpressionFactory = sqlExpressionFactory; _typeMappingSource = typeMappingSource; - _ogcGeometryTypeWhenThenList = new[] - { + _ogcGeometryTypeWhenThenList = + [ new CaseWhenClause( _sqlExpressionFactory.Constant("ST_CircularString"), _sqlExpressionFactory.Constant(OgcGeometryType.CircularString)), new CaseWhenClause( @@ -88,7 +88,7 @@ public NpgsqlGeometryMemberTranslator( _sqlExpressionFactory.Constant("ST_PolyhedralSurface"), _sqlExpressionFactory.Constant(OgcGeometryType.PolyhedralSurface)), new CaseWhenClause(_sqlExpressionFactory.Constant("ST_Tin"), _sqlExpressionFactory.Constant(OgcGeometryType.TIN)) - }; + ]; } /// @@ -127,7 +127,7 @@ public NpgsqlGeometryMemberTranslator( if (function is not null) { - return Function(function, new[] { instance }, typeof(double)); + return Function(function, [instance], typeof(double)); } } @@ -135,37 +135,37 @@ public NpgsqlGeometryMemberTranslator( { if (member.Name == "Count") { - return Function("ST_NumPoints", new[] { instance }, typeof(int)); + return Function("ST_NumPoints", [instance], typeof(int)); } } return member.Name switch { - nameof(Geometry.Area) => Function("ST_Area", new[] { instance }, typeof(double)), - nameof(Geometry.Boundary) => Function("ST_Boundary", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), - nameof(Geometry.Centroid) => Function("ST_Centroid", new[] { instance }, typeof(Point), ResultGeometryMapping()), - nameof(GeometryCollection.Count) => Function("ST_NumGeometries", new[] { instance }, typeof(int)), - nameof(Geometry.Dimension) => Function("ST_Dimension", new[] { instance }, typeof(Dimension)), - nameof(LineString.EndPoint) => Function("ST_EndPoint", new[] { instance }, typeof(Point), ResultGeometryMapping()), - nameof(Geometry.Envelope) => Function("ST_Envelope", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), - nameof(Polygon.ExteriorRing) => Function("ST_ExteriorRing", new[] { instance }, typeof(LineString), ResultGeometryMapping()), - nameof(Geometry.GeometryType) => Function("GeometryType", new[] { instance }, typeof(string)), - nameof(LineString.IsClosed) => Function("ST_IsClosed", new[] { instance }, typeof(bool)), - nameof(Geometry.IsEmpty) => Function("ST_IsEmpty", new[] { instance }, typeof(bool)), - nameof(LineString.IsRing) => Function("ST_IsRing", new[] { instance }, typeof(bool)), - nameof(Geometry.IsSimple) => Function("ST_IsSimple", new[] { instance }, typeof(bool)), - nameof(Geometry.IsValid) => Function("ST_IsValid", new[] { instance }, typeof(bool)), - nameof(Geometry.Length) => Function("ST_Length", new[] { instance }, typeof(double)), - nameof(Geometry.NumGeometries) => Function("ST_NumGeometries", new[] { instance }, typeof(int)), - nameof(Polygon.NumInteriorRings) => Function("ST_NumInteriorRings", new[] { instance }, typeof(int)), - nameof(Geometry.NumPoints) => Function("ST_NumPoints", new[] { instance }, typeof(int)), - nameof(Geometry.PointOnSurface) => Function("ST_PointOnSurface", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), - nameof(Geometry.InteriorPoint) => Function("ST_PointOnSurface", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), - nameof(Geometry.SRID) => Function("ST_SRID", new[] { instance }, typeof(int)), - nameof(LineString.StartPoint) => Function("ST_StartPoint", new[] { instance }, typeof(Point), ResultGeometryMapping()), + nameof(Geometry.Area) => Function("ST_Area", [instance], typeof(double)), + nameof(Geometry.Boundary) => Function("ST_Boundary", [instance], typeof(Geometry), ResultGeometryMapping()), + nameof(Geometry.Centroid) => Function("ST_Centroid", [instance], typeof(Point), ResultGeometryMapping()), + nameof(GeometryCollection.Count) => Function("ST_NumGeometries", [instance], typeof(int)), + nameof(Geometry.Dimension) => Function("ST_Dimension", [instance], typeof(Dimension)), + nameof(LineString.EndPoint) => Function("ST_EndPoint", [instance], typeof(Point), ResultGeometryMapping()), + nameof(Geometry.Envelope) => Function("ST_Envelope", [instance], typeof(Geometry), ResultGeometryMapping()), + nameof(Polygon.ExteriorRing) => Function("ST_ExteriorRing", [instance], typeof(LineString), ResultGeometryMapping()), + nameof(Geometry.GeometryType) => Function("GeometryType", [instance], typeof(string)), + nameof(LineString.IsClosed) => Function("ST_IsClosed", [instance], typeof(bool)), + nameof(Geometry.IsEmpty) => Function("ST_IsEmpty", [instance], typeof(bool)), + nameof(LineString.IsRing) => Function("ST_IsRing", [instance], typeof(bool)), + nameof(Geometry.IsSimple) => Function("ST_IsSimple", [instance], typeof(bool)), + nameof(Geometry.IsValid) => Function("ST_IsValid", [instance], typeof(bool)), + nameof(Geometry.Length) => Function("ST_Length", [instance], typeof(double)), + nameof(Geometry.NumGeometries) => Function("ST_NumGeometries", [instance], typeof(int)), + nameof(Polygon.NumInteriorRings) => Function("ST_NumInteriorRings", [instance], typeof(int)), + nameof(Geometry.NumPoints) => Function("ST_NumPoints", [instance], typeof(int)), + nameof(Geometry.PointOnSurface) => Function("ST_PointOnSurface", [instance], typeof(Geometry), ResultGeometryMapping()), + nameof(Geometry.InteriorPoint) => Function("ST_PointOnSurface", [instance], typeof(Geometry), ResultGeometryMapping()), + nameof(Geometry.SRID) => Function("ST_SRID", [instance], typeof(int)), + nameof(LineString.StartPoint) => Function("ST_StartPoint", [instance], typeof(Point), ResultGeometryMapping()), nameof(Geometry.OgcGeometryType) => _sqlExpressionFactory.Case( - Function("ST_GeometryType", new[] { instance }, typeof(string)), + Function("ST_GeometryType", [instance], typeof(string)), _ogcGeometryTypeWhenThenList, elseResult: null), diff --git a/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMethodCallTranslatorPlugin.cs b/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMethodCallTranslatorPlugin.cs index fc0746aaf..25e0b1f34 100644 --- a/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMethodCallTranslatorPlugin.cs +++ b/src/EFCore.PG.NTS/Query/ExpressionTranslators/Internal/NpgsqlNetTopologySuiteMethodCallTranslatorPlugin.cs @@ -53,9 +53,9 @@ public class NpgsqlGeometryMethodTranslator : IMethodCallTranslator private readonly IRelationalTypeMappingSource _typeMappingSource; private static readonly bool[][] TrueArrays = - { - Array.Empty(), new[] { true }, new[] { true, true }, new[] { true, true, true }, new[] { true, true, true, true } - }; + [ + [], [true], [true, true], [true, true, true], [true, true, true, true] + ]; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -157,65 +157,65 @@ public NpgsqlGeometryMethodTranslator( return method.Name switch { nameof(Geometry.AsBinary) - => Function("ST_AsBinary", new[] { instance }, typeof(byte[])), + => Function("ST_AsBinary", [instance], typeof(byte[])), nameof(Geometry.AsText) - => Function("ST_AsText", new[] { instance }, typeof(string)), + => Function("ST_AsText", [instance], typeof(string)), nameof(Geometry.Buffer) => Function("ST_Buffer", new[] { instance }.Concat(arguments).ToArray(), typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.Contains) - => Function("ST_Contains", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Contains", [instance, arguments[0]], typeof(bool)), nameof(Geometry.ConvexHull) - => Function("ST_ConvexHull", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_ConvexHull", [instance], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.CoveredBy) - => Function("ST_CoveredBy", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_CoveredBy", [instance, arguments[0]], typeof(bool)), nameof(Geometry.Covers) - => Function("ST_Covers", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Covers", [instance, arguments[0]], typeof(bool)), nameof(Geometry.Crosses) - => Function("ST_Crosses", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Crosses", [instance, arguments[0]], typeof(bool)), nameof(Geometry.Disjoint) - => Function("ST_Disjoint", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Disjoint", [instance, arguments[0]], typeof(bool)), nameof(Geometry.Difference) - => Function("ST_Difference", new[] { instance, arguments[0] }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_Difference", [instance, arguments[0]], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.Distance) => Function("ST_Distance", new[] { instance }.Concat(arguments).ToArray(), typeof(double)), nameof(Geometry.EqualsExact) - => Function("ST_OrderingEquals", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_OrderingEquals", [instance, arguments[0]], typeof(bool)), nameof(Geometry.EqualsTopologically) - => Function("ST_Equals", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Equals", [instance, arguments[0]], typeof(bool)), nameof(Geometry.GetGeometryN) - => Function("ST_GeometryN", new[] { instance, OneBased(arguments[0]) }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_GeometryN", [instance, OneBased(arguments[0])], typeof(Geometry), ResultGeometryMapping()), nameof(Polygon.GetInteriorRingN) - => Function("ST_InteriorRingN", new[] { instance, OneBased(arguments[0]) }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_InteriorRingN", [instance, OneBased(arguments[0])], typeof(Geometry), ResultGeometryMapping()), nameof(LineString.GetPointN) - => Function("ST_PointN", new[] { instance, OneBased(arguments[0]) }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_PointN", [instance, OneBased(arguments[0])], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.Intersection) - => Function("ST_Intersection", new[] { instance, arguments[0] }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_Intersection", [instance, arguments[0]], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.Intersects) - => Function("ST_Intersects", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Intersects", [instance, arguments[0]], typeof(bool)), nameof(Geometry.IsWithinDistance) => Function("ST_DWithin", new[] { instance }.Concat(arguments).ToArray(), typeof(bool)), nameof(Geometry.Normalized) - => Function("ST_Normalize", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_Normalize", [instance], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.Overlaps) - => Function("ST_Overlaps", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Overlaps", [instance, arguments[0]], typeof(bool)), nameof(Geometry.Relate) - => Function("ST_Relate", new[] { instance, arguments[0], arguments[1] }, typeof(bool)), + => Function("ST_Relate", [instance, arguments[0], arguments[1]], typeof(bool)), nameof(Geometry.Reverse) - => Function("ST_Reverse", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_Reverse", [instance], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.SymmetricDifference) - => Function("ST_SymDifference", new[] { instance, arguments[0] }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_SymDifference", [instance, arguments[0]], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.ToBinary) - => Function("ST_AsBinary", new[] { instance }, typeof(byte[])), + => Function("ST_AsBinary", [instance], typeof(byte[])), nameof(Geometry.ToText) - => Function("ST_AsText", new[] { instance }, typeof(string)), + => Function("ST_AsText", [instance], typeof(string)), nameof(Geometry.Touches) - => Function("ST_Touches", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Touches", [instance, arguments[0]], typeof(bool)), nameof(Geometry.Within) - => Function("ST_Within", new[] { instance, arguments[0] }, typeof(bool)), + => Function("ST_Within", [instance, arguments[0]], typeof(bool)), nameof(Geometry.Union) when arguments.Count == 0 - => Function("ST_UnaryUnion", new[] { instance }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_UnaryUnion", [instance], typeof(Geometry), ResultGeometryMapping()), nameof(Geometry.Union) when arguments.Count == 1 - => Function("ST_Union", new[] { instance, arguments[0] }, typeof(Geometry), ResultGeometryMapping()), + => Function("ST_Union", [instance, arguments[0]], typeof(Geometry), ResultGeometryMapping()), _ => null }; diff --git a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeAggregateMethodCallTranslatorPlugin.cs b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeAggregateMethodCallTranslatorPlugin.cs index 396abd401..f4b7da247 100644 --- a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeAggregateMethodCallTranslatorPlugin.cs +++ b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeAggregateMethodCallTranslatorPlugin.cs @@ -48,7 +48,7 @@ public NpgsqlNodaTimeAggregateMethodCallTranslatorPlugin( /// public class NpgsqlNodaTimeAggregateMethodTranslator : IAggregateMethodCallTranslator { - private static readonly bool[][] FalseArrays = { Array.Empty(), new[] { false } }; + private static readonly bool[][] FalseArrays = [[], [false]]; private readonly NpgsqlSqlExpressionFactory _sqlExpressionFactory; private readonly IRelationalTypeMappingSource _typeMappingSource; diff --git a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeEvaluatableExpressionFilterPlugin.cs b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeEvaluatableExpressionFilterPlugin.cs index 53085d2e4..6e837baf6 100644 --- a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeEvaluatableExpressionFilterPlugin.cs +++ b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeEvaluatableExpressionFilterPlugin.cs @@ -9,7 +9,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.Query.Internal; public class NpgsqlNodaTimeEvaluatableExpressionFilterPlugin : IEvaluatableExpressionFilterPlugin { private static readonly MethodInfo GetCurrentInstantMethod = - typeof(SystemClock).GetRuntimeMethod(nameof(SystemClock.GetCurrentInstant), Array.Empty())!; + typeof(SystemClock).GetRuntimeMethod(nameof(SystemClock.GetCurrentInstant), [])!; private static readonly MemberInfo SystemClockInstanceMember = typeof(SystemClock).GetMember(nameof(SystemClock.Instance)).FirstOrDefault()!; diff --git a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs index 37bffc7c6..f08aa47f6 100644 --- a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs +++ b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMemberTranslatorPlugin.cs @@ -100,7 +100,7 @@ public NpgsqlNodaTimeMemberTranslator( _localDateTimeTypeMapping = typeMappingSource.FindMapping(typeof(LocalDateTime))!; } - private static readonly bool[][] TrueArrays = { Array.Empty(), new[] { true }, new[] { true, true } }; + private static readonly bool[][] TrueArrays = [[], [true], [true, true]]; /// public virtual SqlExpression? Translate( diff --git a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMethodCallTranslatorPlugin.cs b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMethodCallTranslatorPlugin.cs index 7dada739f..1a3a9d7c7 100644 --- a/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMethodCallTranslatorPlugin.cs +++ b/src/EFCore.PG.NodaTime/Query/Internal/NpgsqlNodaTimeMethodCallTranslatorPlugin.cs @@ -56,14 +56,14 @@ public class NpgsqlNodaTimeMethodCallTranslator : IMethodCallTranslator typeof(Instant).GetRuntimeMethod(nameof(Instant.InUtc), Type.EmptyTypes)!; private static readonly MethodInfo Instant_InZone = - typeof(Instant).GetRuntimeMethod(nameof(Instant.InZone), new[] { typeof(DateTimeZone) })!; + typeof(Instant).GetRuntimeMethod(nameof(Instant.InZone), [typeof(DateTimeZone)])!; private static readonly MethodInfo Instant_ToDateTimeUtc = typeof(Instant).GetRuntimeMethod(nameof(Instant.ToDateTimeUtc), Type.EmptyTypes)!; private static readonly MethodInfo Instant_Distance = typeof(NpgsqlNodaTimeDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlNodaTimeDbFunctionsExtensions.Distance), new[] { typeof(DbFunctions), typeof(Instant), typeof(Instant) })!; + nameof(NpgsqlNodaTimeDbFunctionsExtensions.Distance), [typeof(DbFunctions), typeof(Instant), typeof(Instant)])!; private static readonly MethodInfo ZonedDateTime_ToInstant = typeof(ZonedDateTime).GetRuntimeMethod(nameof(ZonedDateTime.ToInstant), Type.EmptyTypes)!; @@ -71,56 +71,56 @@ public class NpgsqlNodaTimeMethodCallTranslator : IMethodCallTranslator private static readonly MethodInfo ZonedDateTime_Distance = typeof(NpgsqlNodaTimeDbFunctionsExtensions).GetRuntimeMethod( nameof(NpgsqlNodaTimeDbFunctionsExtensions.Distance), - new[] { typeof(DbFunctions), typeof(ZonedDateTime), typeof(ZonedDateTime) })!; + [typeof(DbFunctions), typeof(ZonedDateTime), typeof(ZonedDateTime)])!; private static readonly MethodInfo LocalDateTime_InZoneLeniently = - typeof(LocalDateTime).GetRuntimeMethod(nameof(LocalDateTime.InZoneLeniently), new[] { typeof(DateTimeZone) })!; + typeof(LocalDateTime).GetRuntimeMethod(nameof(LocalDateTime.InZoneLeniently), [typeof(DateTimeZone)])!; private static readonly MethodInfo LocalDateTime_Distance = typeof(NpgsqlNodaTimeDbFunctionsExtensions).GetRuntimeMethod( nameof(NpgsqlNodaTimeDbFunctionsExtensions.Distance), - new[] { typeof(DbFunctions), typeof(LocalDateTime), typeof(LocalDateTime) })!; + [typeof(DbFunctions), typeof(LocalDateTime), typeof(LocalDateTime)])!; private static readonly MethodInfo LocalDate_Distance = typeof(NpgsqlNodaTimeDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlNodaTimeDbFunctionsExtensions.Distance), new[] { typeof(DbFunctions), typeof(LocalDate), typeof(LocalDate) })!; + nameof(NpgsqlNodaTimeDbFunctionsExtensions.Distance), [typeof(DbFunctions), typeof(LocalDate), typeof(LocalDate)])!; - private static readonly MethodInfo Period_FromYears = typeof(Period).GetRuntimeMethod(nameof(Period.FromYears), new[] { typeof(int) })!; + private static readonly MethodInfo Period_FromYears = typeof(Period).GetRuntimeMethod(nameof(Period.FromYears), [typeof(int)])!; private static readonly MethodInfo Period_FromMonths = - typeof(Period).GetRuntimeMethod(nameof(Period.FromMonths), new[] { typeof(int) })!; + typeof(Period).GetRuntimeMethod(nameof(Period.FromMonths), [typeof(int)])!; - private static readonly MethodInfo Period_FromWeeks = typeof(Period).GetRuntimeMethod(nameof(Period.FromWeeks), new[] { typeof(int) })!; - private static readonly MethodInfo Period_FromDays = typeof(Period).GetRuntimeMethod(nameof(Period.FromDays), new[] { typeof(int) })!; + private static readonly MethodInfo Period_FromWeeks = typeof(Period).GetRuntimeMethod(nameof(Period.FromWeeks), [typeof(int)])!; + private static readonly MethodInfo Period_FromDays = typeof(Period).GetRuntimeMethod(nameof(Period.FromDays), [typeof(int)])!; private static readonly MethodInfo Period_FromHours = typeof(Period).GetRuntimeMethod( - nameof(Period.FromHours), new[] { typeof(long) })!; + nameof(Period.FromHours), [typeof(long)])!; private static readonly MethodInfo Period_FromMinutes = - typeof(Period).GetRuntimeMethod(nameof(Period.FromMinutes), new[] { typeof(long) })!; + typeof(Period).GetRuntimeMethod(nameof(Period.FromMinutes), [typeof(long)])!; private static readonly MethodInfo Period_FromSeconds = - typeof(Period).GetRuntimeMethod(nameof(Period.FromSeconds), new[] { typeof(long) })!; + typeof(Period).GetRuntimeMethod(nameof(Period.FromSeconds), [typeof(long)])!; private static readonly MethodInfo Interval_Contains - = typeof(Interval).GetRuntimeMethod(nameof(Interval.Contains), new[] { typeof(Instant) })!; + = typeof(Interval).GetRuntimeMethod(nameof(Interval.Contains), [typeof(Instant)])!; private static readonly MethodInfo DateInterval_Contains_LocalDate - = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Contains), new[] { typeof(LocalDate) })!; + = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Contains), [typeof(LocalDate)])!; private static readonly MethodInfo DateInterval_Contains_DateInterval - = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Contains), new[] { typeof(DateInterval) })!; + = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Contains), [typeof(DateInterval)])!; private static readonly MethodInfo DateInterval_Intersection - = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Intersection), new[] { typeof(DateInterval) })!; + = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Intersection), [typeof(DateInterval)])!; private static readonly MethodInfo DateInterval_Union - = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Union), new[] { typeof(DateInterval) })!; + = typeof(DateInterval).GetRuntimeMethod(nameof(DateInterval.Union), [typeof(DateInterval)])!; private static readonly MethodInfo IDateTimeZoneProvider_get_Item - = typeof(IDateTimeZoneProvider).GetRuntimeMethod("get_Item", new[] { typeof(string) })!; + = typeof(IDateTimeZoneProvider).GetRuntimeMethod("get_Item", [typeof(string)])!; - private static readonly bool[][] TrueArrays = { Array.Empty(), new[] { true }, new[] { true, true }, }; + private static readonly bool[][] TrueArrays = [[], [true], [true, true]]; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -179,17 +179,17 @@ public NpgsqlNodaTimeMethodCallTranslator( ? _sqlExpressionFactory.AtTimeZone( _sqlExpressionFactory.Function( "NOW", - Array.Empty(), + [], nullable: false, - argumentsPropagateNullability: Array.Empty(), + argumentsPropagateNullability: [], method.ReturnType), _sqlExpressionFactory.Constant("UTC"), method.ReturnType) : _sqlExpressionFactory.Function( "NOW", - Array.Empty(), + [], nullable: false, - argumentsPropagateNullability: Array.Empty(), + argumentsPropagateNullability: [], method.ReturnType, _typeMappingSource.FindMapping(typeof(Instant), "timestamp with time zone")); } diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalRangeMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalRangeMapping.cs index 6ac52f361..3a072e892 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalRangeMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/DateIntervalRangeMapping.cs @@ -13,10 +13,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; public class DateIntervalRangeMapping : NpgsqlTypeMapping { private static readonly ConstructorInfo _constructorWithDates = - typeof(DateInterval).GetConstructor(new[] { typeof(LocalDate), typeof(LocalDate) })!; + typeof(DateInterval).GetConstructor([typeof(LocalDate), typeof(LocalDate)])!; private static readonly ConstructorInfo _localDateConstructor = - typeof(LocalDate).GetConstructor(new[] { typeof(int), typeof(int), typeof(int) })!; + typeof(LocalDate).GetConstructor([typeof(int), typeof(int), typeof(int)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/DateMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/DateMapping.cs index 213f1a488..16cca6b5e 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/DateMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/DateMapping.cs @@ -16,7 +16,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; public class DateMapping : NpgsqlTypeMapping { private static readonly ConstructorInfo Constructor = - typeof(LocalDate).GetConstructor(new[] { typeof(int), typeof(int), typeof(int) })!; + typeof(LocalDate).GetConstructor([typeof(int), typeof(int), typeof(int)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs index 0959d6ef9..fea8f021b 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs @@ -52,7 +52,7 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p public override Expression GenerateCodeLiteral(object value) => Expression.Call( Expression.Property(null, typeof(DateTimeZoneProviders).GetProperty(nameof(DateTimeZoneProviders.Tzdb))!), - typeof(IDateTimeZoneProvider).GetMethod(nameof(IDateTimeZoneProvider.GetZoneOrNull), new[] { typeof(string) })!, + typeof(IDateTimeZoneProvider).GetMethod(nameof(IDateTimeZoneProvider.GetZoneOrNull), [typeof(string)])!, Expression.Constant(((DateTimeZone)value).Id)); private sealed class DateTimeZoneConverter() : ValueConverter( diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/DurationIntervalMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/DurationIntervalMapping.cs index 0f3385681..27a2c2038 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/DurationIntervalMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/DurationIntervalMapping.cs @@ -13,17 +13,17 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; /// public class DurationIntervalMapping : NpgsqlTypeMapping { - private static readonly MethodInfo FromDays = typeof(Duration).GetRuntimeMethod(nameof(Duration.FromDays), new[] { typeof(int) })!; - private static readonly MethodInfo FromHours = typeof(Duration).GetRuntimeMethod(nameof(Duration.FromHours), new[] { typeof(int) })!; + private static readonly MethodInfo FromDays = typeof(Duration).GetRuntimeMethod(nameof(Duration.FromDays), [typeof(int)])!; + private static readonly MethodInfo FromHours = typeof(Duration).GetRuntimeMethod(nameof(Duration.FromHours), [typeof(int)])!; private static readonly MethodInfo FromMinutes = - typeof(Duration).GetRuntimeMethod(nameof(Duration.FromMinutes), new[] { typeof(long) })!; + typeof(Duration).GetRuntimeMethod(nameof(Duration.FromMinutes), [typeof(long)])!; private static readonly MethodInfo FromSeconds = - typeof(Duration).GetRuntimeMethod(nameof(Duration.FromSeconds), new[] { typeof(long) })!; + typeof(Duration).GetRuntimeMethod(nameof(Duration.FromSeconds), [typeof(long)])!; private static readonly MethodInfo FromMilliseconds = typeof(Duration).GetRuntimeMethod( - nameof(Duration.FromMilliseconds), new[] { typeof(long) })!; + nameof(Duration.FromMilliseconds), [typeof(long)])!; private static readonly PropertyInfo Zero = typeof(Duration).GetProperty(nameof(Duration.Zero))!; diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/IntervalRangeMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/IntervalRangeMapping.cs index a262d0a11..6d0e08d12 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/IntervalRangeMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/IntervalRangeMapping.cs @@ -16,10 +16,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; public class IntervalRangeMapping : NpgsqlTypeMapping { private static readonly ConstructorInfo _constructor = - typeof(Interval).GetConstructor(new[] { typeof(Instant), typeof(Instant) })!; + typeof(Interval).GetConstructor([typeof(Instant), typeof(Instant)])!; private static readonly ConstructorInfo _constructorWithNulls = - typeof(Interval).GetConstructor(new[] { typeof(Instant?), typeof(Instant?) })!; + typeof(Interval).GetConstructor([typeof(Instant?), typeof(Instant?)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs b/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs index 7cad0fff4..d3a581c8e 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/NpgsqlNodaTimeTypeMappingSourcePlugin.cs @@ -97,30 +97,27 @@ public NpgsqlNodaTimeTypeMappingSourcePlugin(ISqlGenerationHelper sqlGenerationH // migrations, model snapshots still contain old mappings (Instant mapped to timestamp), and EF Core's model differ // expects type mappings to be found for these. See https://github.com/dotnet/efcore/issues/26168. "timestamp without time zone", LegacyTimestampBehavior - ? new RelationalTypeMapping[] { _legacyTimestampInstant, _timestampLocalDateTime } - : new RelationalTypeMapping[] { _timestampLocalDateTime, _legacyTimestampInstant } + ? [_legacyTimestampInstant, _timestampLocalDateTime] + : [_timestampLocalDateTime, _legacyTimestampInstant] }, { - "timestamp with time zone", - new RelationalTypeMapping[] { _timestamptzInstant, _timestamptzZonedDateTime, _timestamptzOffsetDateTime } + "timestamp with time zone", [_timestamptzInstant, _timestamptzZonedDateTime, _timestamptzOffsetDateTime] }, - { "date", new RelationalTypeMapping[] { _date } }, - { "time without time zone", new RelationalTypeMapping[] { _time } }, - { "time with time zone", new RelationalTypeMapping[] { _timetz } }, - { "interval", new RelationalTypeMapping[] { _periodInterval, _durationInterval } }, + { "date", [_date] }, + { "time without time zone", [_time] }, + { "time with time zone", [_timetz] }, + { "interval", [_periodInterval, _durationInterval] }, { "tsrange", LegacyTimestampBehavior - ? new RelationalTypeMapping[] { _legacyTimestampInstantRange, _timestampLocalDateTimeRange } - : new RelationalTypeMapping[] { _timestampLocalDateTimeRange, _legacyTimestampInstantRange } + ? [_legacyTimestampInstantRange, _timestampLocalDateTimeRange] + : [_timestampLocalDateTimeRange, _legacyTimestampInstantRange] }, { - "tstzrange", - new RelationalTypeMapping[] - { + "tstzrange", [ _intervalRange, _timestamptzInstantRange, _timestamptzZonedDateTimeRange, _timestamptzOffsetDateTimeRange - } + ] }, - { "daterange", new RelationalTypeMapping[] { _dateIntervalRange, _dateRange } } + { "daterange", [_dateIntervalRange, _dateRange] } }; // Set up aliases diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/PeriodIntervalMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/PeriodIntervalMapping.cs index 07ccff8b2..b46009434 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/PeriodIntervalMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/PeriodIntervalMapping.cs @@ -14,19 +14,19 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; /// public class PeriodIntervalMapping : NpgsqlTypeMapping { - private static readonly MethodInfo FromYears = typeof(Period).GetRuntimeMethod(nameof(Period.FromYears), new[] { typeof(int) })!; - private static readonly MethodInfo FromMonths = typeof(Period).GetRuntimeMethod(nameof(Period.FromMonths), new[] { typeof(int) })!; - private static readonly MethodInfo FromWeeks = typeof(Period).GetRuntimeMethod(nameof(Period.FromWeeks), new[] { typeof(int) })!; - private static readonly MethodInfo FromDays = typeof(Period).GetRuntimeMethod(nameof(Period.FromDays), new[] { typeof(int) })!; - private static readonly MethodInfo FromHours = typeof(Period).GetRuntimeMethod(nameof(Period.FromHours), new[] { typeof(long) })!; - private static readonly MethodInfo FromMinutes = typeof(Period).GetRuntimeMethod(nameof(Period.FromMinutes), new[] { typeof(long) })!; - private static readonly MethodInfo FromSeconds = typeof(Period).GetRuntimeMethod(nameof(Period.FromSeconds), new[] { typeof(long) })!; + private static readonly MethodInfo FromYears = typeof(Period).GetRuntimeMethod(nameof(Period.FromYears), [typeof(int)])!; + private static readonly MethodInfo FromMonths = typeof(Period).GetRuntimeMethod(nameof(Period.FromMonths), [typeof(int)])!; + private static readonly MethodInfo FromWeeks = typeof(Period).GetRuntimeMethod(nameof(Period.FromWeeks), [typeof(int)])!; + private static readonly MethodInfo FromDays = typeof(Period).GetRuntimeMethod(nameof(Period.FromDays), [typeof(int)])!; + private static readonly MethodInfo FromHours = typeof(Period).GetRuntimeMethod(nameof(Period.FromHours), [typeof(long)])!; + private static readonly MethodInfo FromMinutes = typeof(Period).GetRuntimeMethod(nameof(Period.FromMinutes), [typeof(long)])!; + private static readonly MethodInfo FromSeconds = typeof(Period).GetRuntimeMethod(nameof(Period.FromSeconds), [typeof(long)])!; private static readonly MethodInfo FromMilliseconds = typeof(Period).GetRuntimeMethod( - nameof(Period.FromMilliseconds), new[] { typeof(long) })!; + nameof(Period.FromMilliseconds), [typeof(long)])!; private static readonly MethodInfo FromNanoseconds = typeof(Period).GetRuntimeMethod( - nameof(Period.FromNanoseconds), new[] { typeof(long) })!; + nameof(Period.FromNanoseconds), [typeof(long)])!; private static readonly PropertyInfo Zero = typeof(Period).GetProperty(nameof(Period.Zero))!; diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/TimeMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/TimeMapping.cs index b3aab9393..a9d25f72b 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/TimeMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/TimeMapping.cs @@ -16,15 +16,15 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; public class TimeMapping : NpgsqlTypeMapping { private static readonly ConstructorInfo ConstructorWithMinutes = - typeof(LocalTime).GetConstructor(new[] { typeof(int), typeof(int) })!; + typeof(LocalTime).GetConstructor([typeof(int), typeof(int)])!; private static readonly ConstructorInfo ConstructorWithSeconds = - typeof(LocalTime).GetConstructor(new[] { typeof(int), typeof(int), typeof(int) })!; + typeof(LocalTime).GetConstructor([typeof(int), typeof(int), typeof(int)])!; private static readonly MethodInfo FromHourMinuteSecondNanosecondMethod = typeof(LocalTime).GetMethod( nameof(LocalTime.FromHourMinuteSecondNanosecond), - new[] { typeof(int), typeof(int), typeof(int), typeof(long) })!; + [typeof(int), typeof(int), typeof(int), typeof(long)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/TimeTzMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/TimeTzMapping.cs index f48ec2566..07ea8ac3a 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/TimeTzMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/TimeTzMapping.cs @@ -16,24 +16,24 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; public class TimeTzMapping : NpgsqlTypeMapping { private static readonly ConstructorInfo OffsetTimeConstructor = - typeof(OffsetTime).GetConstructor(new[] { typeof(LocalTime), typeof(Offset) })!; + typeof(OffsetTime).GetConstructor([typeof(LocalTime), typeof(Offset)])!; private static readonly ConstructorInfo LocalTimeConstructorWithMinutes = - typeof(LocalTime).GetConstructor(new[] { typeof(int), typeof(int) })!; + typeof(LocalTime).GetConstructor([typeof(int), typeof(int)])!; private static readonly ConstructorInfo LocalTimeConstructorWithSeconds = - typeof(LocalTime).GetConstructor(new[] { typeof(int), typeof(int), typeof(int) })!; + typeof(LocalTime).GetConstructor([typeof(int), typeof(int), typeof(int)])!; private static readonly MethodInfo LocalTimeFromHourMinuteSecondNanosecondMethod = typeof(LocalTime).GetMethod( nameof(LocalTime.FromHourMinuteSecondNanosecond), - new[] { typeof(int), typeof(int), typeof(int), typeof(long) })!; + [typeof(int), typeof(int), typeof(int), typeof(long)])!; private static readonly MethodInfo OffsetFromHoursMethod = - typeof(Offset).GetMethod(nameof(Offset.FromHours), new[] { typeof(int) })!; + typeof(Offset).GetMethod(nameof(Offset.FromHours), [typeof(int)])!; private static readonly MethodInfo OffsetFromSeconds = - typeof(Offset).GetMethod(nameof(Offset.FromSeconds), new[] { typeof(int) })!; + typeof(Offset).GetMethod(nameof(Offset.FromSeconds), [typeof(int)])!; private static readonly OffsetTimePattern Pattern = OffsetTimePattern.CreateWithInvariantCulture("HH':'mm':'ss;FFFFFFo"); diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampLocalDateTimeMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampLocalDateTimeMapping.cs index 63cba6b1c..6c85d56da 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampLocalDateTimeMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampLocalDateTimeMapping.cs @@ -16,13 +16,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; public class TimestampLocalDateTimeMapping : NpgsqlTypeMapping { private static readonly ConstructorInfo ConstructorWithMinutes = - typeof(LocalDateTime).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) })!; + typeof(LocalDateTime).GetConstructor([typeof(int), typeof(int), typeof(int), typeof(int), typeof(int)])!; private static readonly ConstructorInfo ConstructorWithSeconds = - typeof(LocalDateTime).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) })!; + typeof(LocalDateTime).GetConstructor([typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int)])!; private static readonly MethodInfo PlusNanosecondsMethod = - typeof(LocalDateTime).GetMethod(nameof(LocalDateTime.PlusNanoseconds), new[] { typeof(long) })!; + typeof(LocalDateTime).GetMethod(nameof(LocalDateTime.PlusNanoseconds), [typeof(long)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzInstantMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzInstantMapping.cs index 47bb9381a..ddeac0787 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzInstantMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzInstantMapping.cs @@ -121,7 +121,7 @@ public override Expression GenerateCodeLiteral(object value) => GenerateCodeLiteral((Instant)value); private static readonly MethodInfo _fromUnixTimeTicks - = typeof(Instant).GetRuntimeMethod(nameof(Instant.FromUnixTimeTicks), new[] { typeof(long) })!; + = typeof(Instant).GetRuntimeMethod(nameof(Instant.FromUnixTimeTicks), [typeof(long)])!; private sealed class JsonInstantReaderWriter : JsonValueReaderWriter { diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzOffsetDateTimeMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzOffsetDateTimeMapping.cs index 89ea37df4..31d8d25fd 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzOffsetDateTimeMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzOffsetDateTimeMapping.cs @@ -16,13 +16,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; public class TimestampTzOffsetDateTimeMapping : NpgsqlTypeMapping { private static readonly ConstructorInfo Constructor = - typeof(OffsetDateTime).GetConstructor(new[] { typeof(LocalDateTime), typeof(Offset) })!; + typeof(OffsetDateTime).GetConstructor([typeof(LocalDateTime), typeof(Offset)])!; private static readonly MethodInfo OffsetFromHoursMethod = - typeof(Offset).GetMethod(nameof(Offset.FromHours), new[] { typeof(int) })!; + typeof(Offset).GetMethod(nameof(Offset.FromHours), [typeof(int)])!; private static readonly MethodInfo OffsetFromSecondsMethod = - typeof(Offset).GetMethod(nameof(Offset.FromSeconds), new[] { typeof(int) })!; + typeof(Offset).GetMethod(nameof(Offset.FromSeconds), [typeof(int)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzZonedDateTimeMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzZonedDateTimeMapping.cs index 999bbe751..d6e637156 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzZonedDateTimeMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/TimestampTzZonedDateTimeMapping.cs @@ -117,7 +117,7 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(ZonedDateTime).GetConstructor(new[] { typeof(Instant), typeof(DateTimeZone) })!; + typeof(ZonedDateTime).GetConstructor([typeof(Instant), typeof(DateTimeZone)])!; private static readonly MemberInfo TzdbDateTimeZoneSourceDefaultMember = typeof(TzdbDateTimeZoneSource).GetMember(nameof(TzdbDateTimeZoneSource.Default))[0]; @@ -125,7 +125,7 @@ public override Expression GenerateCodeLiteral(object value) private static readonly MethodInfo ForIdMethod = typeof(TzdbDateTimeZoneSource).GetRuntimeMethod( nameof(TzdbDateTimeZoneSource.ForId), - new[] { typeof(string) })!; + [typeof(string)])!; private sealed class JsonZonedDateTimeReaderWriter : JsonValueReaderWriter { diff --git a/src/EFCore.PG/Design/Internal/NpgsqlAnnotationCodeGenerator.cs b/src/EFCore.PG/Design/Internal/NpgsqlAnnotationCodeGenerator.cs index d61efedfb..d11a08d6a 100644 --- a/src/EFCore.PG/Design/Internal/NpgsqlAnnotationCodeGenerator.cs +++ b/src/EFCore.PG/Design/Internal/NpgsqlAnnotationCodeGenerator.cs @@ -62,7 +62,7 @@ private static readonly MethodInfo ModelHasAnnotationMethodInfo private static readonly MethodInfo ModelUseKeySequencesMethodInfo = typeof(NpgsqlModelBuilderExtensions).GetRuntimeMethod( - nameof(NpgsqlModelBuilderExtensions.UseKeySequences), new[] { typeof(ModelBuilder), typeof(string), typeof(string) })!; + nameof(NpgsqlModelBuilderExtensions.UseKeySequences), [typeof(ModelBuilder), typeof(string), typeof(string)])!; private static readonly MethodInfo EntityTypeIsUnloggedMethodInfo = typeof(NpgsqlEntityTypeBuilderExtensions).GetRequiredRuntimeMethod( @@ -91,7 +91,7 @@ private static readonly MethodInfo PropertyHasIdentityOptionsMethodInfo private static readonly MethodInfo PropertyUseSequenceMethodInfo = typeof(NpgsqlPropertyBuilderExtensions).GetRuntimeMethod( - nameof(NpgsqlPropertyBuilderExtensions.UseSequence), new[] { typeof(PropertyBuilder), typeof(string), typeof(string) })!; + nameof(NpgsqlPropertyBuilderExtensions.UseSequence), [typeof(PropertyBuilder), typeof(string), typeof(string)])!; private static readonly MethodInfo IndexUseCollationMethodInfo = typeof(NpgsqlIndexBuilderExtensions).GetRequiredRuntimeMethod( @@ -352,9 +352,9 @@ public override IReadOnlyList GenerateFluentApiCalls( onModel ? ModelUseHiLoMethodInfo : PropertyUseHiLoMethodInfo, (name, schema) switch { - (null, null) => Array.Empty(), - (_, null) => new object[] { name }, - _ => new object?[] { name!, schema } + (null, null) => [], + (_, null) => [name], + _ => [name!, schema] }); } @@ -368,9 +368,9 @@ public override IReadOnlyList GenerateFluentApiCalls( onModel ? ModelUseKeySequencesMethodInfo : PropertyUseSequenceMethodInfo, (name: nameOrSuffix, schema) switch { - (null, null) => Array.Empty(), - (_, null) => new object[] { nameOrSuffix }, - _ => new object[] { nameOrSuffix!, schema } + (null, null) => [], + (_, null) => [nameOrSuffix], + _ => [nameOrSuffix!, schema] }); } case NpgsqlValueGenerationStrategy.None: diff --git a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs index 0d4fd224e..1ed164bb4 100644 --- a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs +++ b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs @@ -84,7 +84,7 @@ public virtual IReadOnlyList UserRangeDefinitions /// public NpgsqlOptionsExtension() { - _userRangeDefinitions = new List(); + _userRangeDefinitions = []; } // NB: When adding new options, make sure to update the copy ctor below. @@ -99,7 +99,7 @@ public NpgsqlOptionsExtension(NpgsqlOptionsExtension copyFrom) AdminDatabase = copyFrom.AdminDatabase; _postgresVersion = copyFrom._postgresVersion; UseRedshift = copyFrom.UseRedshift; - _userRangeDefinitions = new List(copyFrom._userRangeDefinitions); + _userRangeDefinitions = [..copyFrom._userRangeDefinitions]; ProvideClientCertificatesCallback = copyFrom.ProvideClientCertificatesCallback; RemoteCertificateValidationCallback = copyFrom.RemoteCertificateValidationCallback; ProvidePasswordCallback = copyFrom.ProvidePasswordCallback; diff --git a/src/EFCore.PG/Internal/EnumerableMethods.cs b/src/EFCore.PG/Internal/EnumerableMethods.cs index f840e16ff..3d8626534 100644 --- a/src/EFCore.PG/Internal/EnumerableMethods.cs +++ b/src/EFCore.PG/Internal/EnumerableMethods.cs @@ -257,14 +257,14 @@ static EnumerableMethods() All = GetMethod( nameof(Enumerable.All), 1, - types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) }); + types => [typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool))]); // AnyWithoutPredicate = GetMethod(nameof(Enumerable.Any), 1, // types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) }); AnyWithPredicate = GetMethod( nameof(Enumerable.Any), 1, - types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) }); + types => [typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool))]); // AsEnumerable = GetMethod(nameof(Enumerable.AsEnumerable), 1, // types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) }); @@ -280,7 +280,7 @@ static EnumerableMethods() Contains = GetMethod( nameof(Enumerable.Contains), 1, - types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), types[0] }); + types => [typeof(IEnumerable<>).MakeGenericType(types[0]), types[0]]); // CountWithoutPredicate = GetMethod(nameof(Enumerable.Count), 1, // types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) }); @@ -325,7 +325,7 @@ static EnumerableMethods() // typeof(IEnumerable<>).MakeGenericType(types[0]) // }); - FirstWithoutPredicate = GetMethod(nameof(Enumerable.First), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) }); + FirstWithoutPredicate = GetMethod(nameof(Enumerable.First), 1, types => [typeof(IEnumerable<>).MakeGenericType(types[0])]); // FirstWithPredicate = GetMethod(nameof(Enumerable.First), 1, // types => new[] @@ -339,7 +339,7 @@ static EnumerableMethods() FirstOrDefaultWithPredicate = GetMethod( nameof(Enumerable.FirstOrDefault), 1, - types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) }); + types => [typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool))]); // GroupByWithKeySelector = GetMethod(nameof(Enumerable.GroupBy), 2, // types => new[] @@ -645,6 +645,6 @@ MethodInfo GetMethod(string name, int genericParameterCount, Func ((genericParameterCount == 0 && !mi.IsGenericMethod) || (mi.IsGenericMethod && mi.GetGenericArguments().Length == genericParameterCount)) && mi.GetParameters().Select(e => e.ParameterType).SequenceEqual( - parameterGenerator(mi.IsGenericMethod ? mi.GetGenericArguments() : Array.Empty()))); + parameterGenerator(mi.IsGenericMethod ? mi.GetGenericArguments() : []))); } } diff --git a/src/EFCore.PG/Internal/NpgsqlSingletonOptions.cs b/src/EFCore.PG/Internal/NpgsqlSingletonOptions.cs index 81785d0bf..a6f859155 100644 --- a/src/EFCore.PG/Internal/NpgsqlSingletonOptions.cs +++ b/src/EFCore.PG/Internal/NpgsqlSingletonOptions.cs @@ -71,7 +71,7 @@ public class NpgsqlSingletonOptions : INpgsqlSingletonOptions /// public NpgsqlSingletonOptions() { - UserRangeDefinitions = Array.Empty(); + UserRangeDefinitions = []; } /// diff --git a/src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs b/src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs index a03696320..0d9591058 100644 --- a/src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs +++ b/src/EFCore.PG/Metadata/Internal/NpgsqlAnnotationProvider.cs @@ -224,7 +224,7 @@ public override IEnumerable For(IRelationalModel model, bool design { if (!designTime) { - return Array.Empty(); + return []; } return model.Model.GetAnnotations().Where( diff --git a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs index 2442078b9..2b43ed701 100644 --- a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs +++ b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs @@ -1951,7 +1951,7 @@ private bool IsSystemColumn(string name) /// /// https://www.postgresql.org/docs/current/static/ddl-system-columns.html /// - private static readonly string[] SystemColumnNames = { "tableoid", "xmin", "cmin", "xmax", "cmax", "ctid" }; + private static readonly string[] SystemColumnNames = ["tableoid", "xmin", "cmin", "xmax", "cmax", "ctid"]; #endregion System column utilities diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlArrayMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlArrayMethodTranslator.cs index 2dd0c5db3..286c87646 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlArrayMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlArrayMethodTranslator.cs @@ -139,7 +139,7 @@ static bool IsMappedToNonArray(SqlExpression arrayOrList) _sqlExpressionFactory.Subtract( _sqlExpressionFactory.Function( "array_position", - new[] { array, item }, + [array, item], nullable: true, TrueArrays[2], arrayOrList.Type), diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlConvertTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlConvertTranslator.cs index 39ef22fdb..5ad41bcc8 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlConvertTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlConvertTranslator.cs @@ -17,8 +17,8 @@ public class NpgsqlConvertTranslator : IMethodCallTranslator [nameof(Convert.ToString)] = "text" }; - private static readonly List SupportedTypes = new() - { + private static readonly List SupportedTypes = + [ typeof(bool), typeof(byte), typeof(decimal), @@ -28,7 +28,7 @@ public class NpgsqlConvertTranslator : IMethodCallTranslator typeof(long), typeof(short), typeof(string) - }; + ]; private static readonly List SupportedMethods = TypeMapping.Keys diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMemberTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMemberTranslator.cs index d83544d38..e9d54f133 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMemberTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMemberTranslator.cs @@ -148,7 +148,7 @@ public NpgsqlDateTimeMemberTranslator(IRelationalTypeMappingSource typeMappingSo SqlExpression UtcNow() => _sqlExpressionFactory.Function( "now", - Array.Empty(), + [], nullable: false, argumentsPropagateNullability: TrueArrays[0], returnType, diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMethodTranslator.cs index 960a7966e..e64192022 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlDateTimeMethodTranslator.cs @@ -13,85 +13,85 @@ public class NpgsqlDateTimeMethodTranslator : IMethodCallTranslator { private static readonly Dictionary MethodInfoDatePartMapping = new() { - { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddYears), new[] { typeof(int) })!, "years" }, - { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMonths), new[] { typeof(int) })!, "months" }, - { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddDays), new[] { typeof(double) })!, "days" }, - { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddHours), new[] { typeof(double) })!, "hours" }, - { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMinutes), new[] { typeof(double) })!, "mins" }, - { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddSeconds), new[] { typeof(double) })!, "secs" }, + { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddYears), [typeof(int)])!, "years" }, + { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMonths), [typeof(int)])!, "months" }, + { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddDays), [typeof(double)])!, "days" }, + { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddHours), [typeof(double)])!, "hours" }, + { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMinutes), [typeof(double)])!, "mins" }, + { typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddSeconds), [typeof(double)])!, "secs" }, //{ typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMilliseconds), new[] { typeof(double) })!, "milliseconds" }, - { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddYears), new[] { typeof(int) })!, "years" }, - { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddMonths), new[] { typeof(int) })!, "months" }, - { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddDays), new[] { typeof(double) })!, "days" }, - { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddHours), new[] { typeof(double) })!, "hours" }, - { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddMinutes), new[] { typeof(double) })!, "mins" }, - { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddSeconds), new[] { typeof(double) })!, "secs" }, + { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddYears), [typeof(int)])!, "years" }, + { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddMonths), [typeof(int)])!, "months" }, + { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddDays), [typeof(double)])!, "days" }, + { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddHours), [typeof(double)])!, "hours" }, + { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddMinutes), [typeof(double)])!, "mins" }, + { typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddSeconds), [typeof(double)])!, "secs" }, //{ typeof(DateTimeOffset).GetRuntimeMethod(nameof(DateTimeOffset.AddMilliseconds), new[] { typeof(double) })!, "milliseconds" } // DateOnly.AddDays, AddMonths and AddYears have a specialized translation, see below - { typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddHours), new[] { typeof(int) })!, "hours" }, - { typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddMinutes), new[] { typeof(int) })!, "mins" }, + { typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddHours), [typeof(int)])!, "hours" }, + { typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddMinutes), [typeof(int)])!, "mins" }, }; // ReSharper disable InconsistentNaming private static readonly MethodInfo DateTime_ToUniversalTime - = typeof(DateTime).GetRuntimeMethod(nameof(DateTime.ToUniversalTime), Array.Empty())!; + = typeof(DateTime).GetRuntimeMethod(nameof(DateTime.ToUniversalTime), [])!; private static readonly MethodInfo DateTime_ToLocalTime - = typeof(DateTime).GetRuntimeMethod(nameof(DateTime.ToLocalTime), Array.Empty())!; + = typeof(DateTime).GetRuntimeMethod(nameof(DateTime.ToLocalTime), [])!; private static readonly MethodInfo DateTime_SpecifyKind - = typeof(DateTime).GetRuntimeMethod(nameof(DateTime.SpecifyKind), new[] { typeof(DateTime), typeof(DateTimeKind) })!; + = typeof(DateTime).GetRuntimeMethod(nameof(DateTime.SpecifyKind), [typeof(DateTime), typeof(DateTimeKind)])!; private static readonly MethodInfo DateTime_Distance = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlDbFunctionsExtensions.Distance), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) })!; + nameof(NpgsqlDbFunctionsExtensions.Distance), [typeof(DbFunctions), typeof(DateTime), typeof(DateTime)])!; private static readonly MethodInfo DateOnly_FromDateTime - = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.FromDateTime), new[] { typeof(DateTime) })!; + = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.FromDateTime), [typeof(DateTime)])!; private static readonly MethodInfo DateOnly_ToDateTime - = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.ToDateTime), new[] { typeof(TimeOnly) })!; + = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.ToDateTime), [typeof(TimeOnly)])!; private static readonly MethodInfo DateOnly_Distance = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlDbFunctionsExtensions.Distance), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) })!; + nameof(NpgsqlDbFunctionsExtensions.Distance), [typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly)])!; private static readonly MethodInfo DateOnly_AddDays - = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddDays), new[] { typeof(int) })!; + = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddDays), [typeof(int)])!; private static readonly MethodInfo DateOnly_AddMonths - = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddMonths), new[] { typeof(int) })!; + = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddMonths), [typeof(int)])!; private static readonly MethodInfo DateOnly_AddYears - = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddYears), new[] { typeof(int) })!; + = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddYears), [typeof(int)])!; private static readonly MethodInfo TimeOnly_FromDateTime - = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromDateTime), new[] { typeof(DateTime) })!; + = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromDateTime), [typeof(DateTime)])!; private static readonly MethodInfo TimeOnly_FromTimeSpan - = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromTimeSpan), new[] { typeof(TimeSpan) })!; + = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromTimeSpan), [typeof(TimeSpan)])!; private static readonly MethodInfo TimeOnly_ToTimeSpan = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.ToTimeSpan), Type.EmptyTypes)!; private static readonly MethodInfo TimeOnly_IsBetween - = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.IsBetween), new[] { typeof(TimeOnly), typeof(TimeOnly) })!; + = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.IsBetween), [typeof(TimeOnly), typeof(TimeOnly)])!; private static readonly MethodInfo TimeOnly_Add_TimeSpan - = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.Add), new[] { typeof(TimeSpan) })!; + = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.Add), [typeof(TimeSpan)])!; private static readonly MethodInfo TimeZoneInfo_ConvertTimeBySystemTimeZoneId_DateTime = typeof(TimeZoneInfo).GetRuntimeMethod( - nameof(TimeZoneInfo.ConvertTimeBySystemTimeZoneId), new[] { typeof(DateTime), typeof(string) })!; + nameof(TimeZoneInfo.ConvertTimeBySystemTimeZoneId), [typeof(DateTime), typeof(string)])!; private static readonly MethodInfo TimeZoneInfo_ConvertTimeBySystemTimeZoneId_DateTimeOffset = typeof(TimeZoneInfo).GetRuntimeMethod( - nameof(TimeZoneInfo.ConvertTimeBySystemTimeZoneId), new[] { typeof(DateTimeOffset), typeof(string) })!; + nameof(TimeZoneInfo.ConvertTimeBySystemTimeZoneId), [typeof(DateTimeOffset), typeof(string)])!; private static readonly MethodInfo TimeZoneInfo_ConvertTimeToUtc - = typeof(TimeZoneInfo).GetRuntimeMethod(nameof(TimeZoneInfo.ConvertTimeToUtc), new[] { typeof(DateTime) })!; + = typeof(TimeZoneInfo).GetRuntimeMethod(nameof(TimeZoneInfo.ConvertTimeToUtc), [typeof(DateTime)])!; // ReSharper restore InconsistentNaming private readonly IRelationalTypeMappingSource _typeMappingSource; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlFuzzyStringMatchMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlFuzzyStringMatchMethodTranslator.cs index 1e4b84a88..b0c6aa651 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlFuzzyStringMatchMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlFuzzyStringMatchMethodTranslator.cs @@ -36,15 +36,15 @@ private static MethodInfo GetRuntimeMethod(string name, params Type[] parameters private readonly NpgsqlSqlExpressionFactory _sqlExpressionFactory; private static readonly bool[][] TrueArrays = - { - Array.Empty(), - new[] { true }, - new[] { true, true }, - new[] { true, true, true }, - new[] { true, true, true, true }, - new[] { true, true, true, true, true }, - new[] { true, true, true, true, true, true } - }; + [ + [], + [true], + [true, true], + [true, true, true], + [true, true, true, true], + [true, true, true, true, true], + [true, true, true, true, true, true] + ]; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonDomTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonDomTranslator.cs index e57698740..c314b5926 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonDomTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonDomTranslator.cs @@ -16,7 +16,7 @@ public class NpgsqlJsonDomTranslator : IMemberTranslator, IMethodCallTranslator private static readonly MemberInfo RootElement = typeof(JsonDocument).GetProperty(nameof(JsonDocument.RootElement))!; private static readonly MethodInfo GetProperty = typeof(JsonElement).GetRuntimeMethod( - nameof(JsonElement.GetProperty), new[] { typeof(string) })!; + nameof(JsonElement.GetProperty), [typeof(string)])!; private static readonly MethodInfo GetArrayLength = typeof(JsonElement).GetRuntimeMethod( nameof(JsonElement.GetArrayLength), Type.EmptyTypes)!; @@ -26,7 +26,7 @@ public class NpgsqlJsonDomTranslator : IMemberTranslator, IMethodCallTranslator .GetMethod!; private static readonly string[] GetMethods = - { + [ nameof(JsonElement.GetBoolean), nameof(JsonElement.GetDateTime), nameof(JsonElement.GetDateTimeOffset), @@ -38,7 +38,7 @@ public class NpgsqlJsonDomTranslator : IMemberTranslator, IMethodCallTranslator nameof(JsonElement.GetInt64), nameof(JsonElement.GetSingle), nameof(JsonElement.GetString) - }; + ]; private readonly IRelationalTypeMappingSource _typeMappingSource; private readonly NpgsqlSqlExpressionFactory _sqlExpressionFactory; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLTreeTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLTreeTranslator.cs index 9d9a55cb2..270797f14 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLTreeTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLTreeTranslator.cs @@ -92,7 +92,7 @@ public NpgsqlLTreeTranslator( => _sqlExpressionFactory.Function( "subpath", arguments.Count == 2 - ? new[] { instance!, arguments[0], arguments[1] } + ? [instance!, arguments[0], arguments[1]] : new[] { instance!, arguments[0] }, nullable: true, arguments.Count == 2 ? TrueArrays[3] : TrueArrays[2], @@ -103,7 +103,7 @@ public NpgsqlLTreeTranslator( => _sqlExpressionFactory.Function( "index", arguments.Count == 2 - ? new[] { instance!, arguments[0], arguments[1] } + ? [instance!, arguments[0], arguments[1]] : new[] { instance!, arguments[0] }, nullable: true, arguments.Count == 2 ? TrueArrays[3] : TrueArrays[2], diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLikeTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLikeTranslator.cs index 470ce23ad..6aba0252d 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLikeTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlLikeTranslator.cs @@ -8,24 +8,24 @@ public class NpgsqlLikeTranslator : IMethodCallTranslator private static readonly MethodInfo Like = typeof(DbFunctionsExtensions).GetRuntimeMethod( nameof(DbFunctionsExtensions.Like), - new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + [typeof(DbFunctions), typeof(string), typeof(string)])!; private static readonly MethodInfo LikeWithEscape = typeof(DbFunctionsExtensions).GetRuntimeMethod( nameof(DbFunctionsExtensions.Like), - new[] { typeof(DbFunctions), typeof(string), typeof(string), typeof(string) })!; + [typeof(DbFunctions), typeof(string), typeof(string), typeof(string)])!; // ReSharper disable once InconsistentNaming private static readonly MethodInfo ILike = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( nameof(NpgsqlDbFunctionsExtensions.ILike), - new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + [typeof(DbFunctions), typeof(string), typeof(string)])!; // ReSharper disable once InconsistentNaming private static readonly MethodInfo ILikeWithEscape = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( nameof(NpgsqlDbFunctionsExtensions.ILike), - new[] { typeof(DbFunctions), typeof(string), typeof(string), typeof(string) })!; + [typeof(DbFunctions), typeof(string), typeof(string), typeof(string)])!; private readonly NpgsqlSqlExpressionFactory _sqlExpressionFactory; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMathTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMathTranslator.cs index b7a14e134..380463f6f 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMathTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMathTranslator.cs @@ -16,71 +16,71 @@ public class NpgsqlMathTranslator : IMethodCallTranslator { private static readonly Dictionary SupportedMethodTranslations = new() { - { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(decimal) })!, "abs" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(double) })!, "abs" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(float) })!, "abs" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(int) })!, "abs" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(long) })!, "abs" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(short) })!, "abs" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Abs), new[] { typeof(float) })!, "abs" }, - { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Abs), new[] { typeof(BigInteger) })!, "abs" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), new[] { typeof(decimal) })!, "ceiling" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), new[] { typeof(double) })!, "ceiling" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Ceiling), new[] { typeof(float) })!, "ceiling" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Floor), new[] { typeof(decimal) })!, "floor" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Floor), new[] { typeof(double) })!, "floor" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Floor), new[] { typeof(float) })!, "floor" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Pow), new[] { typeof(double), typeof(double) })!, "power" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Pow), new[] { typeof(float), typeof(float) })!, "power" }, - { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Pow), new[] { typeof(BigInteger), typeof(int) })!, "power" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Exp), new[] { typeof(double) })!, "exp" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Exp), new[] { typeof(float) })!, "exp" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Log10), new[] { typeof(double) })!, "log" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Log10), new[] { typeof(float) })!, "log" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Log), new[] { typeof(double) })!, "ln" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Log), new[] { typeof(float) })!, "ln" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(decimal)])!, "abs" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(double)])!, "abs" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(float)])!, "abs" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(int)])!, "abs" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(long)])!, "abs" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Abs), [typeof(short)])!, "abs" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Abs), [typeof(float)])!, "abs" }, + { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Abs), [typeof(BigInteger)])!, "abs" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), [typeof(decimal)])!, "ceiling" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), [typeof(double)])!, "ceiling" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Ceiling), [typeof(float)])!, "ceiling" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Floor), [typeof(decimal)])!, "floor" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Floor), [typeof(double)])!, "floor" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Floor), [typeof(float)])!, "floor" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Pow), [typeof(double), typeof(double)])!, "power" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Pow), [typeof(float), typeof(float)])!, "power" }, + { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Pow), [typeof(BigInteger), typeof(int)])!, "power" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Exp), [typeof(double)])!, "exp" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Exp), [typeof(float)])!, "exp" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Log10), [typeof(double)])!, "log" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Log10), [typeof(float)])!, "log" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Log), [typeof(double)])!, "ln" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Log), [typeof(float)])!, "ln" }, // Note: PostgreSQL has log(x,y) but only for decimal, whereas .NET has it only for double/float - { typeof(Math).GetRuntimeMethod(nameof(Math.Sqrt), new[] { typeof(double) })!, "sqrt" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Sqrt), new[] { typeof(float) })!, "sqrt" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Acos), new[] { typeof(double) })!, "acos" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Acos), new[] { typeof(float) })!, "acos" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Asin), new[] { typeof(double) })!, "asin" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Asin), new[] { typeof(float) })!, "asin" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Atan), new[] { typeof(double) })!, "atan" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan), new[] { typeof(float) })!, "atan" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Atan2), new[] { typeof(double), typeof(double) })!, "atan2" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan2), new[] { typeof(float), typeof(float) })!, "atan2" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Cos), new[] { typeof(double) })!, "cos" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Cos), new[] { typeof(float) })!, "cos" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Sin), new[] { typeof(double) })!, "sin" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Sin), new[] { typeof(float) })!, "sin" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Tan), new[] { typeof(double) })!, "tan" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Tan), new[] { typeof(float) })!, "tan" }, - { typeof(double).GetRuntimeMethod(nameof(double.DegreesToRadians), new[] { typeof(double) })!, "radians" }, - { typeof(float).GetRuntimeMethod(nameof(float.DegreesToRadians), new[] { typeof(float) })!, "radians" }, - { typeof(double).GetRuntimeMethod(nameof(double.RadiansToDegrees), new[] { typeof(double) })!, "degrees" }, - { typeof(float).GetRuntimeMethod(nameof(float.RadiansToDegrees), new[] { typeof(float) })!, "degrees" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Sqrt), [typeof(double)])!, "sqrt" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Sqrt), [typeof(float)])!, "sqrt" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Acos), [typeof(double)])!, "acos" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Acos), [typeof(float)])!, "acos" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Asin), [typeof(double)])!, "asin" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Asin), [typeof(float)])!, "asin" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Atan), [typeof(double)])!, "atan" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan), [typeof(float)])!, "atan" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Atan2), [typeof(double), typeof(double)])!, "atan2" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Atan2), [typeof(float), typeof(float)])!, "atan2" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Cos), [typeof(double)])!, "cos" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Cos), [typeof(float)])!, "cos" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Sin), [typeof(double)])!, "sin" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Sin), [typeof(float)])!, "sin" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Tan), [typeof(double)])!, "tan" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Tan), [typeof(float)])!, "tan" }, + { typeof(double).GetRuntimeMethod(nameof(double.DegreesToRadians), [typeof(double)])!, "radians" }, + { typeof(float).GetRuntimeMethod(nameof(float.DegreesToRadians), [typeof(float)])!, "radians" }, + { typeof(double).GetRuntimeMethod(nameof(double.RadiansToDegrees), [typeof(double)])!, "degrees" }, + { typeof(float).GetRuntimeMethod(nameof(float.RadiansToDegrees), [typeof(float)])!, "degrees" }, // https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-GREATEST-LEAST - { typeof(Math).GetRuntimeMethod(nameof(Math.Max), new[] { typeof(decimal), typeof(decimal) })!, "GREATEST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Max), new[] { typeof(double), typeof(double) })!, "GREATEST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Max), new[] { typeof(float), typeof(float) })!, "GREATEST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Max), new[] { typeof(int), typeof(int) })!, "GREATEST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Max), new[] { typeof(long), typeof(long) })!, "GREATEST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Max), new[] { typeof(short), typeof(short) })!, "GREATEST" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Max), new[] { typeof(float), typeof(float) })!, "GREATEST" }, - { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Max), new[] { typeof(BigInteger), typeof(BigInteger) })!, "GREATEST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Max), [typeof(decimal), typeof(decimal)])!, "GREATEST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Max), [typeof(double), typeof(double)])!, "GREATEST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Max), [typeof(float), typeof(float)])!, "GREATEST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Max), [typeof(int), typeof(int)])!, "GREATEST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Max), [typeof(long), typeof(long)])!, "GREATEST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Max), [typeof(short), typeof(short)])!, "GREATEST" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Max), [typeof(float), typeof(float)])!, "GREATEST" }, + { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Max), [typeof(BigInteger), typeof(BigInteger)])!, "GREATEST" }, // https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-GREATEST-LEAST - { typeof(Math).GetRuntimeMethod(nameof(Math.Min), new[] { typeof(decimal), typeof(decimal) })!, "LEAST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Min), new[] { typeof(double), typeof(double) })!, "LEAST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Min), new[] { typeof(float), typeof(float) })!, "LEAST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Min), new[] { typeof(int), typeof(int) })!, "LEAST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Min), new[] { typeof(long), typeof(long) })!, "LEAST" }, - { typeof(Math).GetRuntimeMethod(nameof(Math.Min), new[] { typeof(short), typeof(short) })!, "LEAST" }, - { typeof(MathF).GetRuntimeMethod(nameof(MathF.Min), new[] { typeof(float), typeof(float) })!, "LEAST" }, - { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Min), new[] { typeof(BigInteger), typeof(BigInteger) })!, "LEAST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Min), [typeof(decimal), typeof(decimal)])!, "LEAST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Min), [typeof(double), typeof(double)])!, "LEAST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Min), [typeof(float), typeof(float)])!, "LEAST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Min), [typeof(int), typeof(int)])!, "LEAST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Min), [typeof(long), typeof(long)])!, "LEAST" }, + { typeof(Math).GetRuntimeMethod(nameof(Math.Min), [typeof(short), typeof(short)])!, "LEAST" }, + { typeof(MathF).GetRuntimeMethod(nameof(MathF.Min), [typeof(float), typeof(float)])!, "LEAST" }, + { typeof(BigInteger).GetRuntimeMethod(nameof(BigInteger.Min), [typeof(BigInteger), typeof(BigInteger)])!, "LEAST" }, }; private static readonly IEnumerable TruncateMethodInfos = new[] @@ -99,36 +99,36 @@ public class NpgsqlMathTranslator : IMethodCallTranslator private static readonly IEnumerable SignMethodInfos = new[] { - typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(decimal) })!, - typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(double) })!, - typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(float) })!, - typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(int) })!, - typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(long) })!, - typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(sbyte) })!, - typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(short) })!, - typeof(MathF).GetRuntimeMethod(nameof(MathF.Sign), new[] { typeof(float) })!, + typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(decimal)])!, + typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(double)])!, + typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(float)])!, + typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(int)])!, + typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(long)])!, + typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(sbyte)])!, + typeof(Math).GetRuntimeMethod(nameof(Math.Sign), [typeof(short)])!, + typeof(MathF).GetRuntimeMethod(nameof(MathF.Sign), [typeof(float)])!, }; private static readonly MethodInfo RoundDecimalTwoParams - = typeof(Math).GetRuntimeMethod(nameof(Math.Round), new[] { typeof(decimal), typeof(int) })!; + = typeof(Math).GetRuntimeMethod(nameof(Math.Round), [typeof(decimal), typeof(int)])!; private static readonly MethodInfo DoubleIsNanMethodInfo - = typeof(double).GetRuntimeMethod(nameof(double.IsNaN), new[] { typeof(double) })!; + = typeof(double).GetRuntimeMethod(nameof(double.IsNaN), [typeof(double)])!; private static readonly MethodInfo DoubleIsPositiveInfinityMethodInfo - = typeof(double).GetRuntimeMethod(nameof(double.IsPositiveInfinity), new[] { typeof(double) })!; + = typeof(double).GetRuntimeMethod(nameof(double.IsPositiveInfinity), [typeof(double)])!; private static readonly MethodInfo DoubleIsNegativeInfinityMethodInfo - = typeof(double).GetRuntimeMethod(nameof(double.IsNegativeInfinity), new[] { typeof(double) })!; + = typeof(double).GetRuntimeMethod(nameof(double.IsNegativeInfinity), [typeof(double)])!; private static readonly MethodInfo FloatIsNanMethodInfo - = typeof(float).GetRuntimeMethod(nameof(float.IsNaN), new[] { typeof(float) })!; + = typeof(float).GetRuntimeMethod(nameof(float.IsNaN), [typeof(float)])!; private static readonly MethodInfo FloatIsPositiveInfinityMethodInfo - = typeof(float).GetRuntimeMethod(nameof(float.IsPositiveInfinity), new[] { typeof(float) })!; + = typeof(float).GetRuntimeMethod(nameof(float.IsPositiveInfinity), [typeof(float)])!; private static readonly MethodInfo FloatIsNegativeInfinityMethodInfo - = typeof(float).GetRuntimeMethod(nameof(float.IsNegativeInfinity), new[] { typeof(float) })!; + = typeof(float).GetRuntimeMethod(nameof(float.IsNegativeInfinity), [typeof(float)])!; private readonly ISqlExpressionFactory _sqlExpressionFactory; private readonly RelationalTypeMapping _intTypeMapping; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMiscAggregateMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMiscAggregateMethodTranslator.cs index 2e3077f7c..488994c93 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMiscAggregateMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlMiscAggregateMethodTranslator.cs @@ -12,10 +12,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Inte public class NpgsqlMiscAggregateMethodTranslator : IAggregateMethodCallTranslator { private static readonly MethodInfo StringJoin - = typeof(string).GetRuntimeMethod(nameof(string.Join), new[] { typeof(string), typeof(IEnumerable) })!; + = typeof(string).GetRuntimeMethod(nameof(string.Join), [typeof(string), typeof(IEnumerable)])!; private static readonly MethodInfo StringConcat - = typeof(string).GetRuntimeMethod(nameof(string.Concat), new[] { typeof(IEnumerable) })!; + = typeof(string).GetRuntimeMethod(nameof(string.Concat), [typeof(IEnumerable)])!; private readonly NpgsqlSqlExpressionFactory _sqlExpressionFactory; private readonly IRelationalTypeMappingSource _typeMappingSource; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNetworkTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNetworkTranslator.cs index 81ffb280f..cb181134f 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNetworkTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNetworkTranslator.cs @@ -14,10 +14,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Inte public class NpgsqlNetworkTranslator : IMethodCallTranslator { private static readonly MethodInfo IPAddressParse = - typeof(IPAddress).GetRuntimeMethod(nameof(IPAddress.Parse), new[] { typeof(string) })!; + typeof(IPAddress).GetRuntimeMethod(nameof(IPAddress.Parse), [typeof(string)])!; private static readonly MethodInfo PhysicalAddressParse = - typeof(PhysicalAddress).GetRuntimeMethod(nameof(PhysicalAddress.Parse), new[] { typeof(string) })!; + typeof(PhysicalAddress).GetRuntimeMethod(nameof(PhysicalAddress.Parse), [typeof(string)])!; private readonly NpgsqlSqlExpressionFactory _sqlExpressionFactory; @@ -180,31 +180,31 @@ public NpgsqlNetworkTranslator( _longAddressMapping), nameof(NpgsqlNetworkDbFunctionsExtensions.Abbreviate) - => NullPropagatingFunction("abbrev", new[] { arguments[1] }, typeof(string)), + => NullPropagatingFunction("abbrev", [arguments[1]], typeof(string)), nameof(NpgsqlNetworkDbFunctionsExtensions.Broadcast) - => NullPropagatingFunction("broadcast", new[] { arguments[1] }, typeof(IPAddress), _inetMapping), + => NullPropagatingFunction("broadcast", [arguments[1]], typeof(IPAddress), _inetMapping), nameof(NpgsqlNetworkDbFunctionsExtensions.Family) - => NullPropagatingFunction("family", new[] { arguments[1] }, typeof(int)), + => NullPropagatingFunction("family", [arguments[1]], typeof(int)), nameof(NpgsqlNetworkDbFunctionsExtensions.Host) - => NullPropagatingFunction("host", new[] { arguments[1] }, typeof(string)), + => NullPropagatingFunction("host", [arguments[1]], typeof(string)), nameof(NpgsqlNetworkDbFunctionsExtensions.HostMask) - => NullPropagatingFunction("hostmask", new[] { arguments[1] }, typeof(IPAddress), _inetMapping), + => NullPropagatingFunction("hostmask", [arguments[1]], typeof(IPAddress), _inetMapping), nameof(NpgsqlNetworkDbFunctionsExtensions.MaskLength) - => NullPropagatingFunction("masklen", new[] { arguments[1] }, typeof(int)), + => NullPropagatingFunction("masklen", [arguments[1]], typeof(int)), nameof(NpgsqlNetworkDbFunctionsExtensions.Netmask) - => NullPropagatingFunction("netmask", new[] { arguments[1] }, typeof(IPAddress), _inetMapping), + => NullPropagatingFunction("netmask", [arguments[1]], typeof(IPAddress), _inetMapping), nameof(NpgsqlNetworkDbFunctionsExtensions.Network) - => NullPropagatingFunction("network", new[] { arguments[1] }, typeof((IPAddress Address, int Subnet)), _cidrMapping), + => NullPropagatingFunction("network", [arguments[1]], typeof((IPAddress Address, int Subnet)), _cidrMapping), nameof(NpgsqlNetworkDbFunctionsExtensions.SetMaskLength) => NullPropagatingFunction( - "set_masklen", new[] { arguments[1], arguments[2] }, arguments[1].Type, arguments[1].TypeMapping), + "set_masklen", [arguments[1], arguments[2]], arguments[1].Type, arguments[1].TypeMapping), nameof(NpgsqlNetworkDbFunctionsExtensions.Text) - => NullPropagatingFunction("text", new[] { arguments[1] }, typeof(string)), + => NullPropagatingFunction("text", [arguments[1]], typeof(string)), nameof(NpgsqlNetworkDbFunctionsExtensions.SameFamily) - => NullPropagatingFunction("inet_same_family", new[] { arguments[1], arguments[2] }, typeof(bool)), + => NullPropagatingFunction("inet_same_family", [arguments[1], arguments[2]], typeof(bool)), nameof(NpgsqlNetworkDbFunctionsExtensions.Merge) => NullPropagatingFunction( - "inet_merge", new[] { arguments[1], arguments[2] }, typeof((IPAddress Address, int Subnet)), _cidrMapping), + "inet_merge", [arguments[1], arguments[2]], typeof((IPAddress Address, int Subnet)), _cidrMapping), _ => null }; @@ -213,10 +213,10 @@ public NpgsqlNetworkTranslator( => method.Name switch { nameof(NpgsqlNetworkDbFunctionsExtensions.Abbreviate) - => NullPropagatingFunction("abbrev", new[] { arguments[1] }, typeof(string)), + => NullPropagatingFunction("abbrev", [arguments[1]], typeof(string)), nameof(NpgsqlNetworkDbFunctionsExtensions.SetMaskLength) => NullPropagatingFunction( - "set_masklen", new[] { arguments[1], arguments[2] }, arguments[1].Type, arguments[1].TypeMapping), + "set_masklen", [arguments[1], arguments[2]], arguments[1].Type, arguments[1].TypeMapping), _ => null }; @@ -241,9 +241,9 @@ public NpgsqlNetworkTranslator( => _sqlExpressionFactory.Or(arguments[1], arguments[2]), nameof(NpgsqlNetworkDbFunctionsExtensions.Truncate) => NullPropagatingFunction( - "trunc", new[] { arguments[1] }, typeof(PhysicalAddress), arguments[1].TypeMapping), + "trunc", [arguments[1]], typeof(PhysicalAddress), arguments[1].TypeMapping), nameof(NpgsqlNetworkDbFunctionsExtensions.Set7BitMac8) => NullPropagatingFunction( - "macaddr8_set7bit", new[] { arguments[1] }, typeof(PhysicalAddress), _macaddr8Mapping), + "macaddr8_set7bit", [arguments[1]], typeof(PhysicalAddress), _macaddr8Mapping), _ => null }; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNewGuidTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNewGuidTranslator.cs index 6ea22c4d8..8762343ff 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNewGuidTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlNewGuidTranslator.cs @@ -10,7 +10,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Inte /// public class NpgsqlNewGuidTranslator : IMethodCallTranslator { - private static readonly MethodInfo MethodInfo = typeof(Guid).GetRuntimeMethod(nameof(Guid.NewGuid), Array.Empty())!; + private static readonly MethodInfo MethodInfo = typeof(Guid).GetRuntimeMethod(nameof(Guid.NewGuid), [])!; private readonly ISqlExpressionFactory _sqlExpressionFactory; private readonly string _uuidGenerationFunction; @@ -41,7 +41,7 @@ public NpgsqlNewGuidTranslator(ISqlExpressionFactory sqlExpressionFactory, Versi => MethodInfo.Equals(method) ? _sqlExpressionFactory.Function( _uuidGenerationFunction, - Array.Empty(), + [], nullable: false, argumentsPropagateNullability: FalseArrays[0], method.ReturnType) diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlObjectToStringTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlObjectToStringTranslator.cs index 94df91dee..8478cae09 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlObjectToStringTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlObjectToStringTranslator.cs @@ -10,8 +10,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Inte /// public class NpgsqlObjectToStringTranslator : IMethodCallTranslator { - private static readonly HashSet _typeMapping = new() - { + private static readonly HashSet _typeMapping = + [ typeof(int), typeof(long), typeof(DateTime), @@ -29,8 +29,8 @@ public class NpgsqlObjectToStringTranslator : IMethodCallTranslator typeof(uint), typeof(ushort), typeof(ulong), - typeof(sbyte), - }; + typeof(sbyte) + ]; private readonly ISqlExpressionFactory _sqlExpressionFactory; private readonly RelationalTypeMapping _textTypeMapping; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRandomTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRandomTranslator.cs index 2457ff1fa..3368c9a65 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRandomTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRandomTranslator.cs @@ -9,7 +9,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Inte public class NpgsqlRandomTranslator : IMethodCallTranslator { private static readonly MethodInfo _methodInfo - = typeof(DbFunctionsExtensions).GetRuntimeMethod(nameof(DbFunctionsExtensions.Random), new[] { typeof(DbFunctions) })!; + = typeof(DbFunctionsExtensions).GetRuntimeMethod(nameof(DbFunctionsExtensions.Random), [typeof(DbFunctions)])!; private readonly ISqlExpressionFactory _sqlExpressionFactory; @@ -43,9 +43,9 @@ public NpgsqlRandomTranslator(ISqlExpressionFactory sqlExpressionFactory) return _methodInfo.Equals(method) ? _sqlExpressionFactory.Function( "random", - Array.Empty(), + [], nullable: false, - argumentsPropagateNullability: Array.Empty(), + argumentsPropagateNullability: [], method.ReturnType) : null; } diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRegexIsMatchTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRegexIsMatchTranslator.cs index 4af7bdcb8..659d27b73 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRegexIsMatchTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRegexIsMatchTranslator.cs @@ -12,10 +12,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Inte public class NpgsqlRegexIsMatchTranslator : IMethodCallTranslator { private static readonly MethodInfo IsMatch = - typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), new[] { typeof(string), typeof(string) })!; + typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), [typeof(string), typeof(string)])!; private static readonly MethodInfo IsMatchWithRegexOptions = - typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), new[] { typeof(string), typeof(string), typeof(RegexOptions) })!; + typeof(Regex).GetRuntimeMethod(nameof(Regex.IsMatch), [typeof(string), typeof(string), typeof(RegexOptions)])!; private const RegexOptions UnsupportedRegexOptions = RegexOptions.RightToLeft | RegexOptions.ECMAScript; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRowValueTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRowValueTranslator.cs index aa21383e7..f1e6f3aeb 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRowValueTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlRowValueTranslator.cs @@ -18,7 +18,7 @@ public class NpgsqlRowValueTranslator : IMethodCallTranslator private static readonly MethodInfo GreaterThan = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( nameof(NpgsqlDbFunctionsExtensions.GreaterThan), - new[] { typeof(DbFunctions), typeof(ITuple), typeof(ITuple) })!; + [typeof(DbFunctions), typeof(ITuple), typeof(ITuple)])!; private static readonly MethodInfo LessThan = typeof(NpgsqlDbFunctionsExtensions).GetMethods() diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index cffe8d89f..ae89c3243 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -19,24 +19,24 @@ public class NpgsqlStringMethodTranslator : IMethodCallTranslator #region MethodInfo - private static readonly MethodInfo IndexOfChar = typeof(string).GetRuntimeMethod(nameof(string.IndexOf), new[] { typeof(char) })!; - private static readonly MethodInfo IndexOfString = typeof(string).GetRuntimeMethod(nameof(string.IndexOf), new[] { typeof(string) })!; + private static readonly MethodInfo IndexOfChar = typeof(string).GetRuntimeMethod(nameof(string.IndexOf), [typeof(char)])!; + private static readonly MethodInfo IndexOfString = typeof(string).GetRuntimeMethod(nameof(string.IndexOf), [typeof(string)])!; private static readonly MethodInfo IsNullOrWhiteSpace = - typeof(string).GetRuntimeMethod(nameof(string.IsNullOrWhiteSpace), new[] { typeof(string) })!; + typeof(string).GetRuntimeMethod(nameof(string.IsNullOrWhiteSpace), [typeof(string)])!; - private static readonly MethodInfo PadLeft = typeof(string).GetRuntimeMethod(nameof(string.PadLeft), new[] { typeof(int) })!; + private static readonly MethodInfo PadLeft = typeof(string).GetRuntimeMethod(nameof(string.PadLeft), [typeof(int)])!; private static readonly MethodInfo PadLeftWithChar = typeof(string).GetRuntimeMethod( - nameof(string.PadLeft), new[] { typeof(int), typeof(char) })!; + nameof(string.PadLeft), [typeof(int), typeof(char)])!; - private static readonly MethodInfo PadRight = typeof(string).GetRuntimeMethod(nameof(string.PadRight), new[] { typeof(int) })!; + private static readonly MethodInfo PadRight = typeof(string).GetRuntimeMethod(nameof(string.PadRight), [typeof(int)])!; private static readonly MethodInfo PadRightWithChar = typeof(string).GetRuntimeMethod( - nameof(string.PadRight), new[] { typeof(int), typeof(char) })!; + nameof(string.PadRight), [typeof(int), typeof(char)])!; private static readonly MethodInfo Replace = typeof(string).GetRuntimeMethod( - nameof(string.Replace), new[] { typeof(string), typeof(string) })!; + nameof(string.Replace), [typeof(string), typeof(string)])!; private static readonly MethodInfo Substring = typeof(string).GetTypeInfo().GetDeclaredMethods(nameof(string.Substring)) .Single(m => m.GetParameters().Length == 1); @@ -44,38 +44,38 @@ public class NpgsqlStringMethodTranslator : IMethodCallTranslator private static readonly MethodInfo SubstringWithLength = typeof(string).GetTypeInfo().GetDeclaredMethods(nameof(string.Substring)) .Single(m => m.GetParameters().Length == 2); - private static readonly MethodInfo ToLower = typeof(string).GetRuntimeMethod(nameof(string.ToLower), Array.Empty())!; - private static readonly MethodInfo ToUpper = typeof(string).GetRuntimeMethod(nameof(string.ToUpper), Array.Empty())!; + private static readonly MethodInfo ToLower = typeof(string).GetRuntimeMethod(nameof(string.ToLower), [])!; + private static readonly MethodInfo ToUpper = typeof(string).GetRuntimeMethod(nameof(string.ToUpper), [])!; private static readonly MethodInfo TrimBothWithNoParam = typeof(string).GetRuntimeMethod(nameof(string.Trim), Type.EmptyTypes)!; - private static readonly MethodInfo TrimBothWithChars = typeof(string).GetRuntimeMethod(nameof(string.Trim), new[] { typeof(char[]) })!; + private static readonly MethodInfo TrimBothWithChars = typeof(string).GetRuntimeMethod(nameof(string.Trim), [typeof(char[])])!; private static readonly MethodInfo TrimBothWithSingleChar = - typeof(string).GetRuntimeMethod(nameof(string.Trim), new[] { typeof(char) })!; + typeof(string).GetRuntimeMethod(nameof(string.Trim), [typeof(char)])!; private static readonly MethodInfo TrimEndWithNoParam = typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), Type.EmptyTypes)!; private static readonly MethodInfo TrimEndWithChars = typeof(string).GetRuntimeMethod( - nameof(string.TrimEnd), new[] { typeof(char[]) })!; + nameof(string.TrimEnd), [typeof(char[])])!; private static readonly MethodInfo TrimEndWithSingleChar = - typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), new[] { typeof(char) })!; + typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), [typeof(char)])!; private static readonly MethodInfo TrimStartWithNoParam = typeof(string).GetRuntimeMethod(nameof(string.TrimStart), Type.EmptyTypes)!; private static readonly MethodInfo TrimStartWithChars = - typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new[] { typeof(char[]) })!; + typeof(string).GetRuntimeMethod(nameof(string.TrimStart), [typeof(char[])])!; private static readonly MethodInfo TrimStartWithSingleChar = - typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new[] { typeof(char) })!; + typeof(string).GetRuntimeMethod(nameof(string.TrimStart), [typeof(char)])!; private static readonly MethodInfo Reverse = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlDbFunctionsExtensions.Reverse), new[] { typeof(DbFunctions), typeof(string) })!; + nameof(NpgsqlDbFunctionsExtensions.Reverse), [typeof(DbFunctions), typeof(string)])!; private static readonly MethodInfo StringToArray = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlDbFunctionsExtensions.StringToArray), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + nameof(NpgsqlDbFunctionsExtensions.StringToArray), [typeof(DbFunctions), typeof(string), typeof(string)])!; private static readonly MethodInfo StringToArrayNullString = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlDbFunctionsExtensions.StringToArray), new[] { typeof(DbFunctions), typeof(string), typeof(string), typeof(string) })!; + nameof(NpgsqlDbFunctionsExtensions.StringToArray), [typeof(DbFunctions), typeof(string), typeof(string), typeof(string)])!; private static readonly MethodInfo FirstOrDefaultMethodInfoWithoutArgs = typeof(Enumerable).GetRuntimeMethods().Single( @@ -89,16 +89,16 @@ private static readonly MethodInfo LastOrDefaultMethodInfoWithoutArgs // ReSharper disable InconsistentNaming private static readonly MethodInfo String_Join1 = - typeof(string).GetMethod(nameof(string.Join), new[] { typeof(string), typeof(object[]) })!; + typeof(string).GetMethod(nameof(string.Join), [typeof(string), typeof(object[])])!; private static readonly MethodInfo String_Join2 = - typeof(string).GetMethod(nameof(string.Join), new[] { typeof(string), typeof(string[]) })!; + typeof(string).GetMethod(nameof(string.Join), [typeof(string), typeof(string[])])!; private static readonly MethodInfo String_Join3 = - typeof(string).GetMethod(nameof(string.Join), new[] { typeof(char), typeof(object[]) })!; + typeof(string).GetMethod(nameof(string.Join), [typeof(char), typeof(object[])])!; private static readonly MethodInfo String_Join4 = - typeof(string).GetMethod(nameof(string.Join), new[] { typeof(char), typeof(string[]) })!; + typeof(string).GetMethod(nameof(string.Join), [typeof(char), typeof(string[])])!; private static readonly MethodInfo String_Join_generic1 = typeof(string).GetTypeInfo().GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly) @@ -245,7 +245,7 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I { var args = method == Substring - ? new[] { instance!, GenerateOneBasedIndexExpression(arguments[0]) } + ? [instance!, GenerateOneBasedIndexExpression(arguments[0])] : new[] { instance!, GenerateOneBasedIndexExpression(arguments[0]), arguments[1] }; return _sqlExpressionFactory.Function( "substring", @@ -294,7 +294,7 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I } trimChars = constantTrimChars.Value is char c - ? new[] { c } + ? [c] : (char[]?)constantTrimChars.Value; } @@ -317,7 +317,7 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I { var args = method == PadLeft || method == PadRight - ? new[] { instance!, arguments[0] } + ? [instance!, arguments[0]] : new[] { instance!, arguments[0], arguments[1] }; return _sqlExpressionFactory.Function( diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTimeSpanMemberTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTimeSpanMemberTranslator.cs index 8496ab69c..6efe34dae 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTimeSpanMemberTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTimeSpanMemberTranslator.cs @@ -23,7 +23,7 @@ public NpgsqlTimeSpanMemberTranslator(ISqlExpressionFactory sqlExpressionFactory _sqlExpressionFactory = sqlExpressionFactory; } - private static readonly bool[] FalseTrueArray = { false, true }; + private static readonly bool[] FalseTrueArray = [false, true]; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTrigramsMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTrigramsMethodTranslator.cs index 647d9ee92..291dcd3d4 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTrigramsMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlTrigramsMethodTranslator.cs @@ -57,7 +57,7 @@ private static MethodInfo GetRuntimeMethod(string name, params Type[] parameters private readonly RelationalTypeMapping _boolMapping; private readonly RelationalTypeMapping _floatMapping; - private static readonly bool[][] TrueArrays = { Array.Empty(), new[] { true }, new[] { true, true } }; + private static readonly bool[][] TrueArrays = [[], [true], [true, true]]; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Query/Expressions/Internal/PgFunctionExpression.cs b/src/EFCore.PG/Query/Expressions/Internal/PgFunctionExpression.cs index c129ad530..7e4601d3a 100644 --- a/src/EFCore.PG/Query/Expressions/Internal/PgFunctionExpression.cs +++ b/src/EFCore.PG/Query/Expressions/Internal/PgFunctionExpression.cs @@ -63,7 +63,7 @@ public static PgFunctionExpression CreateWithNamedArguments( return new PgFunctionExpression( name, arguments, argumentNames, argumentSeparators: null, - aggregateDistinct: false, aggregatePredicate: null, aggregateOrderings: Array.Empty(), + aggregateDistinct: false, aggregatePredicate: null, aggregateOrderings: [], nullable: nullable, argumentsPropagateNullability: argumentsPropagateNullability, type: type, typeMapping: typeMapping); } @@ -85,7 +85,7 @@ public static PgFunctionExpression CreateWithArgumentSeparators( return new PgFunctionExpression( name, arguments, argumentNames: null, argumentSeparators: argumentSeparators, - aggregateDistinct: false, aggregatePredicate: null, aggregateOrderings: Array.Empty(), + aggregateDistinct: false, aggregatePredicate: null, aggregateOrderings: [], nullable: nullable, argumentsPropagateNullability: argumentsPropagateNullability, type: type, typeMapping: typeMapping); } @@ -109,8 +109,8 @@ public PgFunctionExpression( Check.NotEmpty(name, nameof(name)); Check.NotNull(type, nameof(type)); - ArgumentNames = (argumentNames ?? Array.Empty()).ToList(); - ArgumentSeparators = (argumentSeparators ?? Array.Empty()).ToList(); + ArgumentNames = (argumentNames ?? []).ToList(); + ArgumentSeparators = (argumentSeparators ?? []).ToList(); if (ArgumentNames.SkipWhile(a => a is null).Contains(null)) { diff --git a/src/EFCore.PG/Query/Expressions/Internal/PgNewArrayExpression.cs b/src/EFCore.PG/Query/Expressions/Internal/PgNewArrayExpression.cs index 5d0c56412..5aafba511 100644 --- a/src/EFCore.PG/Query/Expressions/Internal/PgNewArrayExpression.cs +++ b/src/EFCore.PG/Query/Expressions/Internal/PgNewArrayExpression.cs @@ -44,7 +44,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) var visitedExpression = (SqlExpression)visitor.Visit(expression); if (visitedExpression != expression && newExpressions is null) { - newExpressions = new List(); + newExpressions = []; for (var j = 0; j < i; j++) { newExpressions.Add(Expressions[j]); diff --git a/src/EFCore.PG/Query/Internal/NpgsqlEvaluatableExpressionFilter.cs b/src/EFCore.PG/Query/Internal/NpgsqlEvaluatableExpressionFilter.cs index b03807f13..da5ebbbd1 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlEvaluatableExpressionFilter.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlEvaluatableExpressionFilter.cs @@ -11,10 +11,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal; public class NpgsqlEvaluatableExpressionFilter : RelationalEvaluatableExpressionFilter { private static readonly MethodInfo TsQueryParse = - typeof(NpgsqlTsQuery).GetRuntimeMethod(nameof(NpgsqlTsQuery.Parse), new[] { typeof(string) })!; + typeof(NpgsqlTsQuery).GetRuntimeMethod(nameof(NpgsqlTsQuery.Parse), [typeof(string)])!; private static readonly MethodInfo TsVectorParse = - typeof(NpgsqlTsVector).GetRuntimeMethod(nameof(NpgsqlTsVector.Parse), new[] { typeof(string) })!; + typeof(NpgsqlTsVector).GetRuntimeMethod(nameof(NpgsqlTsVector.Parse), [typeof(string)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs index 4cde6c0cd..208e033d8 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs @@ -22,15 +22,15 @@ public class NpgsqlQueryableMethodTranslatingExpressionVisitor : RelationalQuery private static readonly MethodInfo Like2MethodInfo = typeof(DbFunctionsExtensions).GetRuntimeMethod( - nameof(DbFunctionsExtensions.Like), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + nameof(DbFunctionsExtensions.Like), [typeof(DbFunctions), typeof(string), typeof(string)])!; // ReSharper disable once InconsistentNaming private static readonly MethodInfo ILike2MethodInfo = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( - nameof(NpgsqlDbFunctionsExtensions.ILike), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + nameof(NpgsqlDbFunctionsExtensions.ILike), [typeof(DbFunctions), typeof(string), typeof(string)])!; private static readonly MethodInfo MatchesLQuery = - typeof(LTree).GetRuntimeMethod(nameof(LTree.MatchesLQuery), new[] { typeof(string) })!; + typeof(LTree).GetRuntimeMethod(nameof(LTree.MatchesLQuery), [typeof(string)])!; #endregion diff --git a/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs b/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs index 277c50991..cbc64eaf9 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs @@ -30,26 +30,26 @@ public class NpgsqlSqlTranslatingExpressionVisitor : RelationalSqlTranslatingExp private static Type? _nodaTimePeriodType; private static readonly ConstructorInfo DateTimeCtor1 = - typeof(DateTime).GetConstructor(new[] { typeof(int), typeof(int), typeof(int) })!; + typeof(DateTime).GetConstructor([typeof(int), typeof(int), typeof(int)])!; private static readonly ConstructorInfo DateTimeCtor2 = - typeof(DateTime).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) })!; + typeof(DateTime).GetConstructor([typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int)])!; private static readonly ConstructorInfo DateTimeCtor3 = typeof(DateTime).GetConstructor( - new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(DateTimeKind) })!; + [typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(DateTimeKind)])!; private static readonly ConstructorInfo DateOnlyCtor = - typeof(DateOnly).GetConstructor(new[] { typeof(int), typeof(int), typeof(int) })!; + typeof(DateOnly).GetConstructor([typeof(int), typeof(int), typeof(int)])!; private static readonly MethodInfo StringStartsWithMethod - = typeof(string).GetRuntimeMethod(nameof(string.StartsWith), new[] { typeof(string) })!; + = typeof(string).GetRuntimeMethod(nameof(string.StartsWith), [typeof(string)])!; private static readonly MethodInfo StringEndsWithMethod - = typeof(string).GetRuntimeMethod(nameof(string.EndsWith), new[] { typeof(string) })!; + = typeof(string).GetRuntimeMethod(nameof(string.EndsWith), [typeof(string)])!; private static readonly MethodInfo StringContainsMethod - = typeof(string).GetRuntimeMethod(nameof(string.Contains), new[] { typeof(string) })!; + = typeof(string).GetRuntimeMethod(nameof(string.Contains), [typeof(string)])!; private static readonly MethodInfo EscapeLikePatternParameterMethod = typeof(NpgsqlSqlTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(ConstructLikePatternParameter))!; diff --git a/src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs b/src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs index 3fd39ac8c..91d898672 100644 --- a/src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs +++ b/src/EFCore.PG/Query/NpgsqlSqlExpressionFactory.cs @@ -151,7 +151,7 @@ public virtual PgJsonTraversalExpression JsonTraversal( bool returnsText, Type type, RelationalTypeMapping? typeMapping = null) - => JsonTraversal(expression, Array.Empty(), returnsText, type, typeMapping); + => JsonTraversal(expression, [], returnsText, type, typeMapping); /// /// Creates a new , for traversing inside a JSON document. @@ -198,7 +198,7 @@ public virtual SqlExpression NewArrayOrConstant( var addMethod = type.GetMethod("Add")!; for (var i = 0; i < elements.Count; i++) { - addMethod.Invoke(list, new[] { ((SqlConstantExpression)newArrayExpression.Expressions[i]).Value }); + addMethod.Invoke(list, [((SqlConstantExpression)newArrayExpression.Expressions[i]).Value]); } return Constant(list, newArrayExpression.TypeMapping); @@ -1007,7 +1007,7 @@ static bool IsTextualTypeMapping(RelationalTypeMapping mapping) var newExpression = ApplyTypeMapping(expression, elementTypeMapping); if (newExpression != expression && newExpressions is null) { - newExpressions = new List(); + newExpressions = []; for (var j = 0; j < i; j++) { newExpressions.Add(pgNewArrayExpression.Expressions[j]); diff --git a/src/EFCore.PG/Scaffolding/Internal/NpgsqlCodeGenerator.cs b/src/EFCore.PG/Scaffolding/Internal/NpgsqlCodeGenerator.cs index 52168228c..32d0b4dd7 100644 --- a/src/EFCore.PG/Scaffolding/Internal/NpgsqlCodeGenerator.cs +++ b/src/EFCore.PG/Scaffolding/Internal/NpgsqlCodeGenerator.cs @@ -35,6 +35,6 @@ public override MethodCallCodeFragment GenerateUseProvider( => new( _useNpgsqlMethodInfo, providerOptions is null - ? new object[] { connectionString } - : new object[] { connectionString, new NestedClosureCodeFragment("x", providerOptions) }); + ? [connectionString] + : [connectionString, new NestedClosureCodeFragment("x", providerOptions)]); } diff --git a/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs b/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs index 68bf6b898..5cb3103cd 100644 --- a/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs +++ b/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs @@ -29,7 +29,7 @@ public class NpgsqlDatabaseModelFactory : DatabaseModelFactory RegexOptions.Compiled, TimeSpan.FromMilliseconds(1000.0)); - private static readonly string[] SerialTypes = { "int2", "int4", "int8" }; + private static readonly string[] SerialTypes = ["int2", "int4", "int8"]; private readonly IDiagnosticsLogger _logger; @@ -228,7 +228,7 @@ deptype IN ('e', 'x') var name = reader.GetString("relname"); var type = reader.GetChar("relkind"); var comment = reader.GetValueOrDefault("description"); - var storageParameters = reader.GetValueOrDefault("reloptions") ?? Array.Empty(); + var storageParameters = reader.GetValueOrDefault("reloptions") ?? []; var table = type switch { @@ -772,7 +772,7 @@ deptype IN ('e', 'x') index[NpgsqlAnnotationNames.NullsDistinct] = false; } - foreach (var storageParameter in record.GetValueOrDefault("idx_reloptions") ?? Array.Empty()) + foreach (var storageParameter in record.GetValueOrDefault("idx_reloptions") ?? []) { if (storageParameter.Split("=") is [var paramName, var paramValue]) { @@ -839,7 +839,7 @@ deptype IN ('e', 'x') using var command = new NpgsqlCommand(commandText, connection); using var reader = command.ExecuteReader(); - constraintIndexes = new List(); + constraintIndexes = []; var tableGroups = reader.Cast().GroupBy( ddr => ( tableSchema: ddr.GetFieldValue("nspname"), diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlBitTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlBitTypeMapping.cs index f2e148e71..977fbd56e 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlBitTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlBitTypeMapping.cs @@ -87,5 +87,5 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(BitArray).GetConstructor(new[] { typeof(bool[]) })!; + typeof(BitArray).GetConstructor([typeof(bool[])])!; } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlCidrTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlCidrTypeMapping.cs index 18b4f3526..a07b54d41 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlCidrTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlCidrTypeMapping.cs @@ -78,10 +78,10 @@ public override Expression GenerateCodeLiteral(object value) Expression.Constant(cidr.Netmask)); } - private static readonly MethodInfo ParseMethod = typeof(IPAddress).GetMethod("Parse", new[] { typeof(string) })!; + private static readonly MethodInfo ParseMethod = typeof(IPAddress).GetMethod("Parse", [typeof(string)])!; private static readonly ConstructorInfo NpgsqlCidrConstructor = - typeof(NpgsqlCidr).GetConstructor(new[] { typeof(IPAddress), typeof(byte) })!; + typeof(NpgsqlCidr).GetConstructor([typeof(IPAddress), typeof(byte)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlGeometricTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlGeometricTypeMapping.cs index d7df0b599..d93451429 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlGeometricTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlGeometricTypeMapping.cs @@ -75,7 +75,7 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlPoint).GetConstructor(new[] { typeof(double), typeof(double) })!; + typeof(NpgsqlPoint).GetConstructor([typeof(double), typeof(double)])!; } /// @@ -155,7 +155,7 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlLine).GetConstructor(new[] { typeof(double), typeof(double), typeof(double) })!; + typeof(NpgsqlLine).GetConstructor([typeof(double), typeof(double), typeof(double)])!; } /// @@ -233,7 +233,7 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlLSeg).GetConstructor(new[] { typeof(double), typeof(double), typeof(double), typeof(double) })!; + typeof(NpgsqlLSeg).GetConstructor([typeof(double), typeof(double), typeof(double), typeof(double)])!; } /// @@ -311,7 +311,7 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlBox).GetConstructor(new[] { typeof(double), typeof(double), typeof(double), typeof(double) })!; + typeof(NpgsqlBox).GetConstructor([typeof(double), typeof(double), typeof(double), typeof(double)])!; } /// @@ -412,10 +412,10 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlPath).GetConstructor(new[] { typeof(IEnumerable), typeof(bool) })!; + typeof(NpgsqlPath).GetConstructor([typeof(IEnumerable), typeof(bool)])!; private static readonly ConstructorInfo PointConstructor = - typeof(NpgsqlPoint).GetConstructor(new[] { typeof(double), typeof(double) })!; + typeof(NpgsqlPoint).GetConstructor([typeof(double), typeof(double)])!; } /// @@ -513,10 +513,10 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlPolygon).GetConstructor(new[] { typeof(NpgsqlPoint[]) })!; + typeof(NpgsqlPolygon).GetConstructor([typeof(NpgsqlPoint[])])!; private static readonly ConstructorInfo PointConstructor = - typeof(NpgsqlPoint).GetConstructor(new[] { typeof(double), typeof(double) })!; + typeof(NpgsqlPoint).GetConstructor([typeof(double), typeof(double)])!; } /// @@ -593,5 +593,5 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlCircle).GetConstructor(new[] { typeof(double), typeof(double), typeof(double) })!; + typeof(NpgsqlCircle).GetConstructor([typeof(double), typeof(double), typeof(double)])!; } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlInetTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlInetTypeMapping.cs index 59fb0ba15..90a6edb9d 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlInetTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlInetTypeMapping.cs @@ -82,8 +82,8 @@ public override Expression GenerateCodeLiteral(object value) _ => throw new UnreachableException() }; - private static readonly MethodInfo IPAddressParseMethod = typeof(IPAddress).GetMethod("Parse", new[] { typeof(string) })!; - private static readonly ConstructorInfo NpgsqlInetConstructor = typeof(NpgsqlInet).GetConstructor(new[] { typeof(string) })!; + private static readonly MethodInfo IPAddressParseMethod = typeof(IPAddress).GetMethod("Parse", [typeof(string)])!; + private static readonly ConstructorInfo NpgsqlInetConstructor = typeof(NpgsqlInet).GetConstructor([typeof(string)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlJsonTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlJsonTypeMapping.cs index dcc449191..e0931b198 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlJsonTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlJsonTypeMapping.cs @@ -126,5 +126,5 @@ public override Expression GenerateCodeLiteral(object value) private static readonly Expression DefaultJsonDocumentOptions = Expression.New(typeof(JsonDocumentOptions)); private static readonly MethodInfo ParseMethod = - typeof(JsonDocument).GetMethod(nameof(JsonDocument.Parse), new[] { typeof(string), typeof(JsonDocumentOptions) })!; + typeof(JsonDocument).GetMethod(nameof(JsonDocument.Parse), [typeof(string), typeof(JsonDocumentOptions)])!; } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlLTreeTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlLTreeTypeMapping.cs index e6a6c4180..a761cffa7 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlLTreeTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlLTreeTypeMapping.cs @@ -11,7 +11,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping; /// public class NpgsqlLTreeTypeMapping : NpgsqlStringTypeMapping { - private static readonly ConstructorInfo Constructor = typeof(LTree).GetConstructor(new[] { typeof(string) })!; + private static readonly ConstructorInfo Constructor = typeof(LTree).GetConstructor([typeof(string)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddr8TypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddr8TypeMapping.cs index 61bbc1897..c73b20642 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddr8TypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddr8TypeMapping.cs @@ -72,5 +72,5 @@ protected override string GenerateNonNullSqlLiteral(object value) public override Expression GenerateCodeLiteral(object value) => Expression.Call(ParseMethod, Expression.Constant(((PhysicalAddress)value).ToString())); - private static readonly MethodInfo ParseMethod = typeof(PhysicalAddress).GetMethod("Parse", new[] { typeof(string) })!; + private static readonly MethodInfo ParseMethod = typeof(PhysicalAddress).GetMethod("Parse", [typeof(string)])!; } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddrTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddrTypeMapping.cs index 961cfee74..25ccc25bd 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddrTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlMacaddrTypeMapping.cs @@ -68,5 +68,5 @@ protected override string GenerateNonNullSqlLiteral(object value) public override Expression GenerateCodeLiteral(object value) => Expression.Call(ParseMethod, Expression.Constant(((PhysicalAddress)value).ToString())); - private static readonly MethodInfo ParseMethod = typeof(PhysicalAddress).GetMethod("Parse", new[] { typeof(string) })!; + private static readonly MethodInfo ParseMethod = typeof(PhysicalAddress).GetMethod("Parse", [typeof(string)])!; } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlOwnedJsonTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlOwnedJsonTypeMapping.cs index 0a0c935fc..0be732a0d 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlOwnedJsonTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlOwnedJsonTypeMapping.cs @@ -17,16 +17,16 @@ public class NpgsqlOwnedJsonTypeMapping : JsonTypeMapping public virtual NpgsqlDbType NpgsqlDbType { get; } private static readonly MethodInfo GetStringMethod - = typeof(DbDataReader).GetRuntimeMethod(nameof(DbDataReader.GetString), new[] { typeof(int) })!; + = typeof(DbDataReader).GetRuntimeMethod(nameof(DbDataReader.GetString), [typeof(int)])!; private static readonly PropertyInfo UTF8Property = typeof(Encoding).GetProperty(nameof(Encoding.UTF8))!; private static readonly MethodInfo EncodingGetBytesMethod - = typeof(Encoding).GetMethod(nameof(Encoding.GetBytes), new[] { typeof(string) })!; + = typeof(Encoding).GetMethod(nameof(Encoding.GetBytes), [typeof(string)])!; private static readonly ConstructorInfo MemoryStreamConstructor - = typeof(MemoryStream).GetConstructor(new[] { typeof(byte[]) })!; + = typeof(MemoryStream).GetConstructor([typeof(byte[])])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlPgLsnTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlPgLsnTypeMapping.cs index 4faeb5fb5..7dcb7279e 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlPgLsnTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlPgLsnTypeMapping.cs @@ -81,7 +81,7 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlLogSequenceNumber).GetConstructor(new[] { typeof(ulong) })!; + typeof(NpgsqlLogSequenceNumber).GetConstructor([typeof(ulong)])!; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs index 7687410d6..d8e5d62ae 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlRangeTypeMapping.cs @@ -260,10 +260,10 @@ private void InitializeAccessors(Type rangeClrType, Type subtypeClrType) _upperInfiniteProperty = rangeClrType.GetProperty(nameof(NpgsqlRange.UpperBoundInfinite))!; _rangeConstructor1 = rangeClrType.GetConstructor( - new[] { subtypeClrType, subtypeClrType })!; + [subtypeClrType, subtypeClrType])!; _rangeConstructor2 = rangeClrType.GetConstructor( - new[] { subtypeClrType, typeof(bool), subtypeClrType, typeof(bool) })!; + [subtypeClrType, typeof(bool), subtypeClrType, typeof(bool)])!; _rangeConstructor3 = rangeClrType.GetConstructor( - new[] { subtypeClrType, typeof(bool), typeof(bool), subtypeClrType, typeof(bool), typeof(bool) })!; + [subtypeClrType, typeof(bool), typeof(bool), subtypeClrType, typeof(bool), typeof(bool)])!; } } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlTidTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlTidTypeMapping.cs index d4185164e..bcf13e7b4 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlTidTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlTidTypeMapping.cs @@ -79,5 +79,5 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(NpgsqlTid).GetConstructor(new[] { typeof(uint), typeof(ushort) })!; + typeof(NpgsqlTid).GetConstructor([typeof(uint), typeof(ushort)])!; } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlVarbitTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlVarbitTypeMapping.cs index 4f024940d..909475cc2 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlVarbitTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlVarbitTypeMapping.cs @@ -92,5 +92,5 @@ public override Expression GenerateCodeLiteral(object value) } private static readonly ConstructorInfo Constructor = - typeof(BitArray).GetConstructor(new[] { typeof(bool[]) })!; + typeof(BitArray).GetConstructor([typeof(bool[])])!; } diff --git a/src/EFCore.PG/Storage/Internal/NpgsqlSqlGenerationHelper.cs b/src/EFCore.PG/Storage/Internal/NpgsqlSqlGenerationHelper.cs index bd6089b70..bbff1a515 100644 --- a/src/EFCore.PG/Storage/Internal/NpgsqlSqlGenerationHelper.cs +++ b/src/EFCore.PG/Storage/Internal/NpgsqlSqlGenerationHelper.cs @@ -19,7 +19,7 @@ static NpgsqlSqlGenerationHelper() using (var conn = new NpgsqlConnection()) { ReservedWords = - new HashSet(conn.GetSchema("ReservedWords").Rows.Cast().Select(r => (string)r["ReservedWord"])); + [..conn.GetSchema("ReservedWords").Rows.Cast().Select(r => (string)r["ReservedWord"])]; } } diff --git a/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs b/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs index 3c9baa486..d6661e7fb 100644 --- a/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs +++ b/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs @@ -217,75 +217,75 @@ public NpgsqlTypeMappingSource( // https://www.postgresql.org/docs/current/static/datatype.html#DATATYPE-TABLE var storeTypeMappings = new Dictionary(StringComparer.OrdinalIgnoreCase) { - { "smallint", new RelationalTypeMapping[] { _int2, _int2Byte } }, - { "int2", new RelationalTypeMapping[] { _int2, _int2Byte } }, - { "integer", new[] { _int4 } }, - { "int", new[] { _int4 } }, - { "int4", new[] { _int4 } }, - { "bigint", new[] { _int8 } }, - { "int8", new[] { _int8 } }, - { "real", new[] { _float4 } }, - { "float4", new[] { _float4 } }, - { "double precision", new[] { _float8 } }, - { "float8", new[] { _float8 } }, - { "numeric", new RelationalTypeMapping[] { _numeric, _bigInteger, _numericAsFloat, _numericAsDouble } }, - { "decimal", new RelationalTypeMapping[] { _numeric, _bigInteger, _numericAsFloat, _numericAsDouble } }, - { "money", new[] { _money } }, - { "text", new[] { _text } }, - { "jsonb", new RelationalTypeMapping[] { _jsonbString, _jsonbDocument, _jsonbElement } }, - { "json", new RelationalTypeMapping[] { _jsonString, _jsonDocument, _jsonElement } }, - { "xml", new[] { _xml } }, - { "citext", new[] { _citext } }, - { "character varying", new[] { _varchar } }, - { "varchar", new[] { _varchar } }, + { "smallint", [_int2, _int2Byte] }, + { "int2", [_int2, _int2Byte] }, + { "integer", [_int4] }, + { "int", [_int4] }, + { "int4", [_int4] }, + { "bigint", [_int8] }, + { "int8", [_int8] }, + { "real", [_float4] }, + { "float4", [_float4] }, + { "double precision", [_float8] }, + { "float8", [_float8] }, + { "numeric", [_numeric, _bigInteger, _numericAsFloat, _numericAsDouble] }, + { "decimal", [_numeric, _bigInteger, _numericAsFloat, _numericAsDouble] }, + { "money", [_money] }, + { "text", [_text] }, + { "jsonb", [_jsonbString, _jsonbDocument, _jsonbElement] }, + { "json", [_jsonString, _jsonDocument, _jsonElement] }, + { "xml", [_xml] }, + { "citext", [_citext] }, + { "character varying", [_varchar] }, + { "varchar", [_varchar] }, // See FindBaseMapping below for special treatment of 'character' - { "timestamp without time zone", new[] { _timestamp } }, - { "timestamp with time zone", new[] { _timestamptz, _timestamptzDto } }, - { "interval", new[] { _interval } }, - { "date", new RelationalTypeMapping[] { _dateDateOnly, _dateDateTime } }, - { "time without time zone", new RelationalTypeMapping[] { _timeTimeOnly, _timeTimeSpan } }, - { "time with time zone", new[] { _timetz } }, - { "boolean", new[] { _bool } }, - { "bool", new[] { _bool } }, - { "bytea", new[] { _bytea } }, - { "uuid", new[] { _uuid } }, - { "bit", new[] { _bit } }, - { "bit varying", new[] { _varbit } }, - { "varbit", new[] { _varbit } }, - { "hstore", new RelationalTypeMapping[] { _hstore, _immutableHstore } }, - { "macaddr", new[] { _macaddr } }, - { "macaddr8", new[] { _macaddr8 } }, - { "inet", new RelationalTypeMapping[] { _inetAsIPAddress, _inetAsNpgsqlInet } }, - { "cidr", new[] { _cidr } }, - { "point", new[] { _point } }, - { "box", new[] { _box } }, - { "line", new[] { _line } }, - { "lseg", new[] { _lseg } }, - { "path", new[] { _path } }, - { "polygon", new[] { _polygon } }, - { "circle", new[] { _circle } }, - { "xid", new[] { _xid } }, - { "xid8", new[] { _xid8 } }, - { "oid", new[] { _oid } }, - { "cid", new[] { _cid } }, - { "regtype", new[] { _regtype } }, - { "lo", new[] { _lo } }, - { "tid", new[] { _tid } }, - { "pg_lsn", new[] { _pgLsn } }, - { "int4range", new[] { _int4range } }, - { "int8range", new[] { _int8range } }, - { "numrange", new[] { _numrange } }, - { "tsrange", new[] { _tsrange } }, - { "tstzrange", new[] { _tstzrange } }, - { "daterange", new[] { _dateOnlyDaterange, _dateTimeDaterange } }, - { "tsquery", new[] { _tsquery } }, - { "tsvector", new[] { _tsvector } }, - { "regconfig", new[] { _regconfig } }, - { "ltree", new[] { _ltree, _ltreeString } }, - { "lquery", new[] { _lquery } }, - { "ltxtquery", new[] { _ltxtquery } }, - { "regdictionary", new[] { _regdictionary } } + { "timestamp without time zone", [_timestamp] }, + { "timestamp with time zone", [_timestamptz, _timestamptzDto] }, + { "interval", [_interval] }, + { "date", [_dateDateOnly, _dateDateTime] }, + { "time without time zone", [_timeTimeOnly, _timeTimeSpan] }, + { "time with time zone", [_timetz] }, + { "boolean", [_bool] }, + { "bool", [_bool] }, + { "bytea", [_bytea] }, + { "uuid", [_uuid] }, + { "bit", [_bit] }, + { "bit varying", [_varbit] }, + { "varbit", [_varbit] }, + { "hstore", [_hstore, _immutableHstore] }, + { "macaddr", [_macaddr] }, + { "macaddr8", [_macaddr8] }, + { "inet", [_inetAsIPAddress, _inetAsNpgsqlInet] }, + { "cidr", [_cidr] }, + { "point", [_point] }, + { "box", [_box] }, + { "line", [_line] }, + { "lseg", [_lseg] }, + { "path", [_path] }, + { "polygon", [_polygon] }, + { "circle", [_circle] }, + { "xid", [_xid] }, + { "xid8", [_xid8] }, + { "oid", [_oid] }, + { "cid", [_cid] }, + { "regtype", [_regtype] }, + { "lo", [_lo] }, + { "tid", [_tid] }, + { "pg_lsn", [_pgLsn] }, + { "int4range", [_int4range] }, + { "int8range", [_int8range] }, + { "numrange", [_numrange] }, + { "tsrange", [_tsrange] }, + { "tstzrange", [_tstzrange] }, + { "daterange", [_dateOnlyDaterange, _dateTimeDaterange] }, + { "tsquery", [_tsquery] }, + { "tsvector", [_tsvector] }, + { "regconfig", [_regconfig] }, + { "ltree", [_ltree, _ltreeString] }, + { "lquery", [_lquery] }, + { "ltxtquery", [_ltxtquery] }, + { "regdictionary", [_regdictionary] } }; // ReSharper restore CoVariantArrayConversion @@ -403,7 +403,7 @@ is PropertyInfo globalEnumTypeMappingsProperty adoEnumMapping.EnumClrType, adoEnumMapping.NameTranslator); ClrTypeMappings[adoEnumMapping.EnumClrType] = mapping; - StoreTypeMappings[mapping.StoreType] = new RelationalTypeMapping[] { mapping }; + StoreTypeMappings[mapping.StoreType] = [mapping]; } } } diff --git a/src/EFCore.PG/Storage/ValueConversion/NpgsqlArrayConverter.cs b/src/EFCore.PG/Storage/ValueConversion/NpgsqlArrayConverter.cs index a052ef292..c27fb5a87 100644 --- a/src/EFCore.PG/Storage/ValueConversion/NpgsqlArrayConverter.cs +++ b/src/EFCore.PG/Storage/ValueConversion/NpgsqlArrayConverter.cs @@ -164,9 +164,9 @@ private static Expression> ArrayConversionExpression())!)), + : New(typeof(TConcreteOutput).GetConstructor([])!)), // Loop over the elements, applying the element converter on them one by one // for (var i = 0; i < length; i++) @@ -187,7 +187,7 @@ elementConversionExpression is null : Invoke(elementConversionExpression, indexer(loopVariable))) : Call( output, - typeof(TConcreteOutput).GetMethod("Add", new[] { outputElementType })!, + typeof(TConcreteOutput).GetMethod("Add", [outputElementType])!, elementConversionExpression is null ? indexer(loopVariable) : Invoke(elementConversionExpression, indexer(loopVariable)))), diff --git a/src/EFCore.PG/Update/Internal/NpgsqlUpdateSqlGenerator.cs b/src/EFCore.PG/Update/Internal/NpgsqlUpdateSqlGenerator.cs index aea8747aa..fa7d1fad0 100644 --- a/src/EFCore.PG/Update/Internal/NpgsqlUpdateSqlGenerator.cs +++ b/src/EFCore.PG/Update/Internal/NpgsqlUpdateSqlGenerator.cs @@ -225,7 +225,7 @@ public override ResultSetMapping AppendDeleteOperation( requiresTransaction = false; - AppendDeleteCommand(commandStringBuilder, name, schema, Array.Empty(), conditionOperations); + AppendDeleteCommand(commandStringBuilder, name, schema, [], conditionOperations); return ResultSetMapping.NoResults; } diff --git a/src/EFCore.PG/Utilities/Util.cs b/src/EFCore.PG/Utilities/Util.cs index 9f0c14ae4..bdbceb282 100644 --- a/src/EFCore.PG/Utilities/Util.cs +++ b/src/EFCore.PG/Utilities/Util.cs @@ -3,17 +3,17 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Utilities; internal static class Statics { internal static readonly bool[][] TrueArrays = - { - Array.Empty(), - new[] { true }, - new[] { true, true }, - new[] { true, true, true }, - new[] { true, true, true, true }, - new[] { true, true, true, true, true }, - new[] { true, true, true, true, true, true }, - new[] { true, true, true, true, true, true, true }, - new[] { true, true, true, true, true, true, true, true } - }; + [ + [], + [true], + [true, true], + [true, true, true], + [true, true, true, true], + [true, true, true, true, true], + [true, true, true, true, true, true], + [true, true, true, true, true, true, true], + [true, true, true, true, true, true, true, true] + ]; - internal static readonly bool[][] FalseArrays = { Array.Empty(), new[] { false }, new[] { false, false } }; + internal static readonly bool[][] FalseArrays = [[], [false], [false, false]]; } diff --git a/src/Shared/SharedTypeExtensions.cs b/src/Shared/SharedTypeExtensions.cs index d37c585c3..ae06d69f7 100644 --- a/src/Shared/SharedTypeExtensions.cs +++ b/src/Shared/SharedTypeExtensions.cs @@ -303,7 +303,7 @@ public static IEnumerable GetTypesInHierarchy(this Type type) public static ConstructorInfo GetDeclaredConstructor(this Type type, Type[] types) { - types ??= Array.Empty(); + types ??= []; return type.GetTypeInfo().DeclaredConstructors .SingleOrDefault( @@ -540,7 +540,7 @@ public static IEnumerable GetNamespaces(this Type type) public static ConstantExpression GetDefaultValueConstant(this Type type) => (ConstantExpression)_generateDefaultValueConstantMethod - .MakeGenericMethod(type).Invoke(null, Array.Empty()); + .MakeGenericMethod(type).Invoke(null, []); private static readonly MethodInfo _generateDefaultValueConstantMethod = typeof(SharedTypeExtensions).GetTypeInfo().GetDeclaredMethod(nameof(GenerateDefaultValueConstant)); diff --git a/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs index 771b6bc5b..939fa9ae0 100644 --- a/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs @@ -95,7 +95,7 @@ public virtual void Can_query_using_any_mapped_data_type() // CharAsChar1 = 'f', CharAsText = 'g', CharAsVarchar = 'h', - BytesAsBytea = new byte[] { 86 }, + BytesAsBytea = [86], GuidAsUuid = new Guid("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"), EnumAsText = StringEnum16.Value4, EnumAsVarchar = StringEnumU16.Value4, @@ -106,9 +106,9 @@ public virtual void Can_query_using_any_mapped_data_type() DictionaryAsHstore = new Dictionary { { "a", "b" } }, ImmutableDictionaryAsHstore = ImmutableDictionary.Empty.Add("c", "d"), NpgsqlRangeAsRange = new NpgsqlRange(4, true, 8, false), - IntArrayAsIntArray = new[] { 2, 3 }, + IntArrayAsIntArray = [2, 3], PhysicalAddressArrayAsMacaddrArray = - new[] { PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04") }, + [PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04")], UintAsXid = (uint)int.MaxValue + 1, #pragma warning disable CS0618 // Full-text search client-parsing is obsolete @@ -555,7 +555,7 @@ private static void AssertMappedDataTypes(MappedDataTypes entity, int id) // Assert.Equal('f', entity.CharAsChar1); Assert.Equal('g', entity.CharAsText); Assert.Equal('h', entity.CharAsVarchar); - Assert.Equal(new byte[] { 86 }, entity.BytesAsBytea); + Assert.Equal([86], entity.BytesAsBytea); Assert.Equal(new Guid("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"), entity.GuidAsUuid); @@ -569,9 +569,9 @@ private static void AssertMappedDataTypes(MappedDataTypes entity, int id) Assert.Equal(new Dictionary { { "a", "b" } }, entity.DictionaryAsHstore); Assert.Equal(new NpgsqlRange(4, true, 8, false), entity.NpgsqlRangeAsRange); - Assert.Equal(new[] { 2, 3 }, entity.IntArrayAsIntArray); + Assert.Equal([2, 3], entity.IntArrayAsIntArray); Assert.Equal( - new[] { PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04") }, + [PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04")], entity.PhysicalAddressArrayAsMacaddrArray); Assert.Equal((uint)int.MaxValue + 1, entity.UintAsXid); @@ -613,7 +613,7 @@ private static MappedDataTypes CreateMappedDataTypes(int id) // CharAsChar1 = 'f', CharAsText = 'g', CharAsVarchar = 'h', - BytesAsBytea = new byte[] { 86 }, + BytesAsBytea = [86], GuidAsUuid = new Guid("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"), EnumAsText = StringEnum16.Value4, EnumAsVarchar = StringEnumU16.Value4, @@ -623,9 +623,9 @@ private static MappedDataTypes CreateMappedDataTypes(int id) StringAsJson = @"{""a"": ""b""}", DictionaryAsHstore = new Dictionary { { "a", "b" } }, NpgsqlRangeAsRange = new NpgsqlRange(4, true, 8, false), - IntArrayAsIntArray = new[] { 2, 3 }, + IntArrayAsIntArray = [2, 3], PhysicalAddressArrayAsMacaddrArray = - new[] { PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04") }, + [PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04")], UintAsXid = (uint)int.MaxValue + 1, #pragma warning disable CS0618 // Full-text search client-parsing is obsolete SearchQuery = NpgsqlTsQuery.Parse("a & b"), @@ -986,7 +986,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con ((NpgsqlTypeMappingSource)context.GetService()).LoadUserDefinedTypeMappings( context.GetService(), dataSource: null); - modelBuilder.HasPostgresEnum("mood", new[] { "happy", "sad" }); + modelBuilder.HasPostgresEnum("mood", ["happy", "sad"]); MakeRequired(modelBuilder); diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs index bf9f677e6..fcd36e8cf 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs @@ -158,7 +158,7 @@ public virtual async Task Update_with_primitive_collection_in_value_selector(boo var contextFactory = await InitializeAsync( seed: ctx => { - ctx.AddRange(new EntityWithPrimitiveCollection { Tags = new List { "tag1", "tag2" }}); + ctx.AddRange(new EntityWithPrimitiveCollection { Tags = ["tag1", "tag2"] }); ctx.SaveChanges(); }); diff --git a/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs index 2e1279923..db8e54053 100644 --- a/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs @@ -34,14 +34,13 @@ public override void Can_read_write_nullable_ulong_enum_JSON_values(object? valu public override void Can_read_write_collection_of_ulong_enum_JSON_values() => Can_read_and_write_JSON_value>( nameof(EnumU64CollectionType.EnumU64), - new List - { + [ EnumU64.Min, EnumU64.Max, EnumU64.Default, EnumU64.One, (EnumU64)8 - }, + ], // Relational databases don't support unsigned numeric types, so ulong is value-converted to long """{"Prop":[0,-1,0,1,8]}""", mappedCollection: true); @@ -49,15 +48,14 @@ public override void Can_read_write_collection_of_ulong_enum_JSON_values() public override void Can_read_write_collection_of_nullable_ulong_enum_JSON_values() => Can_read_and_write_JSON_value>( nameof(NullableEnumU64CollectionType.EnumU64), - new List - { + [ EnumU64.Min, null, EnumU64.Max, EnumU64.Default, EnumU64.One, (EnumU64?)8 - }, + ], // Relational databases don't support unsigned numeric types, so ulong is value-converted to long """{"Prop":[0,null,-1,0,1,8]}""", mappedCollection: true); @@ -103,14 +101,11 @@ public override void Can_read_write_collection_of_TimeSpan_JSON_values() { Can_read_and_write_JSON_value>( nameof(TimeSpanCollectionType.TimeSpan), - new List - { - // We cannot roundtrip MinValue and MaxValue since these contain sub-microsecond components, which PG does not support. - // TimeSpan.MinValue, + [ new(1, 2, 3, 4), - new(0, 2, 3, 4, 5, 678), + new(0, 2, 3, 4, 5, 678) // TimeSpan.MaxValue - }, + ], """{"Prop":["1 02:03:04","02:03:04.005678"]}""", mappedCollection: true); } @@ -119,15 +114,12 @@ public override void Can_read_write_collection_of_TimeSpan_JSON_values() public override void Can_read_write_collection_of_nullable_TimeSpan_JSON_values() => Can_read_and_write_JSON_value>( nameof(NullableTimeSpanCollectionType.TimeSpan), - new List - { - // We cannot roundtrip MinValue and MaxValue since these contain sub-microsecond components, which PG does not support. - // TimeSpan.MinValue, + [ new(1, 2, 3, 4), new(0, 2, 3, 4, 5, 678), // TimeSpan.MaxValue null - }, + ], """{"Prop":["1 02:03:04","02:03:04.005678",null]}""", mappedCollection: true); @@ -177,12 +169,11 @@ public virtual void Can_read_write_DateOnly_JSON_values_infinity() public override void Can_read_write_collection_of_DateOnly_JSON_values() => Can_read_and_write_JSON_value>( nameof(DateOnlyCollectionType.DateOnly), - new List - { + [ DateOnly.MinValue, new(2023, 5, 29), DateOnly.MaxValue - }, + ], """{"Prop":["-infinity","2023-05-29","infinity"]}""", mappedCollection: true); @@ -190,13 +181,12 @@ public override void Can_read_write_collection_of_DateOnly_JSON_values() public override void Can_read_write_collection_of_nullable_DateOnly_JSON_values() => Can_read_and_write_JSON_value>( nameof(NullableDateOnlyCollectionType.DateOnly), - new List - { + [ DateOnly.MinValue, new(2023, 5, 29), DateOnly.MaxValue, null - }, + ], """{"Prop":["-infinity","2023-05-29","infinity",null]}""", mappedCollection: true); @@ -251,12 +241,11 @@ public virtual void Can_read_write_nullable_DateTime_JSON_values_npgsql(string? public override void Can_read_write_collection_of_DateTime_JSON_values() => Can_read_and_write_JSON_value>( nameof(DateTimeCollectionType.DateTime), - new List - { + [ DateTime.MinValue, new(2023, 5, 29, 10, 52, 47, DateTimeKind.Utc), DateTime.MaxValue - }, + ], """{"Prop":["-infinity","2023-05-29T10:52:47Z","infinity"]}""", mappedCollection: true); @@ -264,13 +253,12 @@ public override void Can_read_write_collection_of_DateTime_JSON_values() public override void Can_read_write_collection_of_nullable_DateTime_JSON_values() => Can_read_and_write_JSON_value>( nameof(NullableDateTimeCollectionType.DateTime), - new List - { + [ DateTime.MinValue, null, new(2023, 5, 29, 10, 52, 47, DateTimeKind.Utc), DateTime.MaxValue - }, + ], """{"Prop":["-infinity",null,"2023-05-29T10:52:47Z","infinity"]}""", mappedCollection: true); @@ -338,14 +326,13 @@ public virtual void Can_read_write_nullable_DateTimeOffset_JSON_values_npgsql(st public override void Can_read_write_collection_of_DateTimeOffset_JSON_values() => Can_read_and_write_JSON_value>( nameof(DateTimeOffsetCollectionType.DateTimeOffset), - new List - { + [ DateTimeOffset.MinValue, new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(-2, 0, 0)), new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(0, 0, 0)), new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(2, 0, 0)), DateTimeOffset.MaxValue - }, + ], """{"Prop":["-infinity","2023-05-29T10:52:47-02:00","2023-05-29T10:52:47\u002B00:00","2023-05-29T10:52:47\u002B02:00","infinity"]}""", mappedCollection: true); @@ -353,15 +340,14 @@ public override void Can_read_write_collection_of_DateTimeOffset_JSON_values() public override void Can_read_write_collection_of_nullable_DateTimeOffset_JSON_values() => Can_read_and_write_JSON_value>( nameof(NullableDateTimeOffsetCollectionType.DateTimeOffset), - new List - { + [ DateTimeOffset.MinValue, new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(-2, 0, 0)), new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(0, 0, 0)), null, new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(2, 0, 0)), DateTimeOffset.MaxValue - }, + ], """{"Prop":["-infinity","2023-05-29T10:52:47-02:00","2023-05-29T10:52:47\u002B00:00",null,"2023-05-29T10:52:47\u002B02:00","infinity"]}""", mappedCollection: true); diff --git a/test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs index 96e931e30..338273052 100644 --- a/test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Migrations/MigrationsNpgsqlTest.cs @@ -2370,10 +2370,10 @@ await Test( builder => builder.Entity( "People", b => { - b.HasIndex(new[] { "Age" }, "IX_NullsDistinct") + b.HasIndex(["Age"], "IX_NullsDistinct") .IsUnique(); - b.HasIndex(new[] { "Age" }, "IX_NullsNotDistinct") + b.HasIndex(["Age"], "IX_NullsNotDistinct") .IsUnique() .AreNullsDistinct(false); }), @@ -2918,7 +2918,7 @@ public virtual async Task Create_enum() { await Test( _ => { }, - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Sad" }), + builder => builder.HasPostgresEnum("Mood", ["Happy", "Sad"]), model => { var moodEnum = Assert.Single(model.GetPostgresEnums()); @@ -2939,7 +2939,7 @@ public virtual async Task Create_enum_with_schema() { await Test( _ => { }, - builder => builder.HasPostgresEnum("some_schema", "Mood", new[] { "Happy", "Sad" }), + builder => builder.HasPostgresEnum("some_schema", "Mood", ["Happy", "Sad"]), model => { var moodEnum = Assert.Single(model.GetPostgresEnums()); @@ -2968,7 +2968,7 @@ IF NOT EXISTS(SELECT 1 FROM pg_namespace WHERE nspname = 'some_schema') THEN public virtual async Task Drop_enum() { await Test( - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Sad" }), + builder => builder.HasPostgresEnum("Mood", ["Happy", "Sad"]), _ => { }, model => Assert.Empty(model.GetPostgresEnums())); @@ -2980,9 +2980,9 @@ await Test( public virtual async Task Do_not_alter_existing_enum_when_creating_new_one() { await Test( - builder => builder.HasPostgresEnum("Enum1", new[] { "A", "B" }), + builder => builder.HasPostgresEnum("Enum1", ["A", "B"]), _ => { }, - builder => builder.HasPostgresEnum("Enum2", new[] { "X", "Y" }), + builder => builder.HasPostgresEnum("Enum2", ["X", "Y"]), model => Assert.Equal(2, model.GetPostgresEnums().Count())); AssertSql( @@ -2993,8 +2993,8 @@ await Test( public virtual async Task Alter_enum_add_label_at_end() { await Test( - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Sad" }), - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Sad", "Angry" }), + builder => builder.HasPostgresEnum("Mood", ["Happy", "Sad"]), + builder => builder.HasPostgresEnum("Mood", ["Happy", "Sad", "Angry"]), model => { var moodEnum = Assert.Single(model.GetPostgresEnums()); @@ -3013,8 +3013,8 @@ await Test( public virtual async Task Alter_enum_add_label_in_middle() { await Test( - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Sad" }), - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Angry", "Sad" }), + builder => builder.HasPostgresEnum("Mood", ["Happy", "Sad"]), + builder => builder.HasPostgresEnum("Mood", ["Happy", "Angry", "Sad"]), model => { var moodEnum = Assert.Single(model.GetPostgresEnums()); @@ -3032,14 +3032,14 @@ await Test( [Fact] public virtual Task Alter_enum_drop_label_not_supported() => TestThrows( - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Sad" }), - builder => builder.HasPostgresEnum("Mood", new[] { "Happy" })); + builder => builder.HasPostgresEnum("Mood", ["Happy", "Sad"]), + builder => builder.HasPostgresEnum("Mood", ["Happy"])); [Fact] public virtual Task Alter_enum_change_label_not_supported() => TestThrows( - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Sad" }), - builder => builder.HasPostgresEnum("Mood", new[] { "Happy", "Angry" })); + builder => builder.HasPostgresEnum("Mood", ["Happy", "Sad"]), + builder => builder.HasPostgresEnum("Mood", ["Happy", "Angry"])); #endregion @@ -3270,5 +3270,5 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build protected override ICollection GetAdditionalReferences() => AdditionalReferences; - private static readonly BuildReference[] AdditionalReferences = { BuildReference.ByName("Npgsql") }; + private static readonly BuildReference[] AdditionalReferences = [BuildReference.ByName("Npgsql")]; } diff --git a/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs b/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs index a9e96d2c5..ac5fec041 100644 --- a/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs +++ b/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs @@ -490,8 +490,7 @@ public void Alter_column_change_serial_to_identity_idempotent(MigrationsSqlGener modelBuilder.HasAnnotation(CoreAnnotationNames.ProductVersion, "3.1.0"); modelBuilder.Entity().Property("Id").UseSerialColumn(); }, - new[] - { + [ new AlterColumnOperation { Table = "Person", @@ -508,7 +507,7 @@ public void Alter_column_change_serial_to_identity_idempotent(MigrationsSqlGener NpgsqlValueGenerationStrategy.SerialColumn, } } - }, + ], options); AssertSql( @@ -527,7 +526,7 @@ public void Create_schema_idempotent() { Generate( _ => { }, - new[] { new EnsureSchemaOperation { Name = "some_schema" } }, + [new EnsureSchemaOperation { Name = "some_schema" }], MigrationsSqlGenerationOptions.Idempotent); AssertSql( @@ -563,13 +562,13 @@ public void CreateTableOperation_with_cockroach_interleave_in_parent() IsNullable = false }, }, - PrimaryKey = new AddPrimaryKeyOperation { Columns = new[] { "Id" } } + PrimaryKey = new AddPrimaryKeyOperation { Columns = ["Id"] } }; var interleaveInParent = new CockroachDbInterleaveInParent(op); interleaveInParent.ParentTableSchema = "my_schema"; interleaveInParent.ParentTableName = "my_parent"; - interleaveInParent.InterleavePrefix = new List { "col_a", "col_b" }; + interleaveInParent.InterleavePrefix = ["col_a", "col_b"]; Generate(op); @@ -612,8 +611,8 @@ public override void InsertDataOperation_throws_for_unsupported_column_types() { Table = "People", Schema = "dbo", - Columns = new[] { "First Name" }, - ColumnTypes = new[] { "foo" }, + Columns = ["First Name"], + ColumnTypes = ["foo"], Values = new object[,] { { null } } })).Message); diff --git a/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs b/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs index c5c596b2c..5b331b827 100644 --- a/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs +++ b/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs @@ -14,8 +14,8 @@ protected override Assembly TargetAssembly public class NpgsqlApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new() - { + public override HashSet FluentApiTypes { get; } = + [ typeof(NpgsqlDbContextOptionsBuilder), typeof(NpgsqlDbContextOptionsBuilderExtensions), typeof(NpgsqlMigrationBuilderExtensions), @@ -24,14 +24,14 @@ public class NpgsqlApiConsistencyFixture : ApiConsistencyFixtureBase typeof(NpgsqlPropertyBuilderExtensions), typeof(NpgsqlEntityTypeBuilderExtensions), typeof(NpgsqlServiceCollectionExtensions) - }; + ]; - public override HashSet UnmatchedMetadataMethods { get; } = new() - { + public override HashSet UnmatchedMetadataMethods { get; } = + [ typeof(NpgsqlPropertyBuilderExtensions).GetMethod( nameof(NpgsqlPropertyBuilderExtensions.IsGeneratedTsVectorColumn), - new[] { typeof(PropertyBuilder), typeof(string), typeof(string[]) }) - }; + [typeof(PropertyBuilder), typeof(string), typeof(string[])]) + ]; public override Dictionary MetadataMethodExceptions { get; } = new() - { + public override HashSet MetadataMethodExceptions { get; } = + [ typeof(NpgsqlEntityTypeExtensions).GetRuntimeMethod( nameof(NpgsqlEntityTypeExtensions.SetStorageParameter), - new[] { typeof(IConventionEntityType), typeof(string), typeof(object), typeof(bool) }) - }; + [typeof(IConventionEntityType), typeof(string), typeof(object), typeof(bool)]) + ]; } } diff --git a/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs b/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs index 0a2ff9dcb..5efd47db1 100644 --- a/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs +++ b/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs @@ -208,8 +208,7 @@ private static async Task Creates_physical_database_and_schema_test( Assert.Equal(14, columns.Length); Assert.Equal( - new[] - { + [ "Blogs.AndChew (bytea)", "Blogs.AndRow (bytea)", "Blogs.Cheese (text)", @@ -224,7 +223,7 @@ private static async Task Creates_physical_database_and_schema_test( "Blogs.TheGu (uuid)", "Blogs.ToEat (smallint)", "Blogs.WayRound (bigint)" - }, + ], columns); } diff --git a/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs index 98a30442c..bd8d59e33 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs @@ -968,7 +968,7 @@ protected override Expression VisitBinary(BinaryExpression node) var listExpression = Visit(node.Left); if (listExpression.Type.IsGenericList()) { - var getItemMethod = listExpression.Type.GetMethod("get_Item", new[] { typeof(int) })!; + var getItemMethod = listExpression.Type.GetMethod("get_Item", [typeof(int)])!; return Expression.Call(listExpression, getItemMethod, node.Right); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs index 0bc0b3508..dd35fc5f4 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs @@ -24,16 +24,15 @@ public void Roundtrip() using var ctx = CreateContext(); var x = ctx.SomeEntities.Single(e => e.Id == 1); - Assert.Equal(new[] { 3, 4 }, x.IntArray); - Assert.Equal(new List { 3, 4 }, x.IntList); - Assert.Equal(new int?[] { 3, 4, null }, x.NullableIntArray); + Assert.Equal([3, 4], x.IntArray); + Assert.Equal([3, 4], x.IntList); + Assert.Equal([3, 4, null], x.NullableIntArray); Assert.Equal( - new List - { - 3, - 4, - null - }, x.NullableIntList); + [ + 3, + 4, + null + ], x.NullableIntList); } #endregion diff --git a/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs index 5676f51a1..c7f577afc 100644 --- a/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs @@ -224,7 +224,7 @@ public class EnumContext(DbContextOptions options) : PoolableDbContext(options) protected override void OnModelCreating(ModelBuilder builder) => builder - .HasPostgresEnum("mapped_enum", new[] { "happy", "sad" }) + .HasPostgresEnum("mapped_enum", ["happy", "sad"]) .HasPostgresEnum() .HasPostgresEnum() .HasDefaultSchema("test") diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs index 3bb952e3e..096206a07 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs @@ -716,7 +716,7 @@ public static void Seed(JsonPocoQueryContext context) { Id = 1, Customer = CreateCustomer1(), - ToplevelArray = new[] { "one", "two", "three" } + ToplevelArray = ["one", "two", "three"] }, new JsonbEntity { Id = 2, Customer = CreateCustomer2() }); context.JsonEntities.AddRange( @@ -724,7 +724,7 @@ public static void Seed(JsonPocoQueryContext context) { Id = 1, Customer = CreateCustomer1(), - ToplevelArray = new[] { "one", "two", "three" } + ToplevelArray = ["one", "two", "three"] }, new JsonEntity { Id = 2, Customer = CreateCustomer2() }); context.SaveChanges(); @@ -745,12 +745,12 @@ static Customer CreateCustomer1() SomeProperty = 10, SomeNullableInt = 20, SomeNullableGuid = Guid.Parse("d5f2685d-e5c4-47e5-97aa-d0266154eb2d"), - IntArray = new[] { 3, 4 }, - IntList = new List { 3, 4 } + IntArray = [3, 4], + IntList = [3, 4] } }, - Orders = new[] - { + Orders = + [ new Order { Price = 99.5m, ShippingAddress = "Some address 1", @@ -759,7 +759,7 @@ static Customer CreateCustomer1() { Price = 23, ShippingAddress = "Some address 2", } - }, + ], VariousTypes = new VariousTypes { String = "foo", @@ -789,22 +789,22 @@ static Customer CreateCustomer2() SomeProperty = 20, SomeNullableInt = null, SomeNullableGuid = null, - IntArray = new[] { 5, 6, 7 }, - IntList = new List - { + IntArray = [5, 6, 7], + IntList = + [ 5, 6, 7 - } + ] } }, - Orders = new[] - { + Orders = + [ new Order { Price = 5, ShippingAddress = "Moe's address", } - }, + ], VariousTypes = new VariousTypes { String = "bar", diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs index c44c70060..a26bb18fd 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs @@ -24,8 +24,8 @@ public virtual async Task Json_predicate_on_bytea(bool async) seed: context => { context.Entities.AddRange( - new TypesContainerEntity { JsonEntity = new TypesJsonEntity { Bytea = new byte[] { 1, 2, 3 } } }, - new TypesContainerEntity { JsonEntity = new TypesJsonEntity { Bytea = new byte[] { 1, 2, 4 } } }); + new TypesContainerEntity { JsonEntity = new TypesJsonEntity { Bytea = [1, 2, 3] } }, + new TypesContainerEntity { JsonEntity = new TypesJsonEntity { Bytea = [1, 2, 4] } }); context.SaveChanges(); }); @@ -107,19 +107,19 @@ protected override void Seed29219(MyContext29219 ctx) { Id = 1, Reference = new MyJsonEntity29219 { NonNullableScalar = 10, NullableScalar = 11 }, - Collection = new List - { + Collection = + [ new() { NonNullableScalar = 100, NullableScalar = 101 }, new() { NonNullableScalar = 200, NullableScalar = 201 }, - new() { NonNullableScalar = 300, NullableScalar = null }, - } + new() { NonNullableScalar = 300, NullableScalar = null } + ] }; var entity2 = new MyEntity29219 { Id = 2, Reference = new MyJsonEntity29219 { NonNullableScalar = 20, NullableScalar = null }, - Collection = new List { new() { NonNullableScalar = 1001, NullableScalar = null }, } + Collection = [new() { NonNullableScalar = 1001, NullableScalar = null }] }; ctx.Entities.AddRange(entity1, entity2); @@ -178,19 +178,19 @@ protected override void SeedArrayOfPrimitives(MyContextArrayOfPrimitives ctx) Id = 1, Reference = new MyJsonEntityArrayOfPrimitives { - IntArray = new[] { 1, 2, 3 }, - ListOfString = new List - { + IntArray = [1, 2, 3], + ListOfString = + [ "Foo", "Bar", "Baz" - } + ] }, - Collection = new List - { - new() { IntArray = new[] { 111, 112, 113 }, ListOfString = new List { "Foo11", "Bar11" } }, - new() { IntArray = new[] { 211, 212, 213 }, ListOfString = new List { "Foo12", "Bar12" } }, - } + Collection = + [ + new() { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, + new() { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } + ] }; var entity2 = new MyEntityArrayOfPrimitives @@ -198,19 +198,19 @@ protected override void SeedArrayOfPrimitives(MyContextArrayOfPrimitives ctx) Id = 2, Reference = new MyJsonEntityArrayOfPrimitives { - IntArray = new[] { 10, 20, 30 }, - ListOfString = new List - { + IntArray = [10, 20, 30], + ListOfString = + [ "A", "B", "C" - } + ] }, - Collection = new List - { - new() { IntArray = new[] { 110, 120, 130 }, ListOfString = new List { "A1", "Z1" } }, - new() { IntArray = new[] { 210, 220, 230 }, ListOfString = new List { "A2", "Z2" } }, - } + Collection = + [ + new() { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, + new() { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } + ] }; ctx.Entities.AddRange(entity1, entity2); diff --git a/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs index 67a8ecc95..91781976a 100644 --- a/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs @@ -523,7 +523,7 @@ public static void Seed(LTreeQueryContext context) { ltreeEntity.LTreeAsString = ltreeEntity.LTree; ltreeEntity.SomeString = "*.Astrophysics"; - ltreeEntity.LTrees = new LTree[] { ltreeEntity.LTree, "Foo" }; + ltreeEntity.LTrees = [ltreeEntity.LTree, "Foo"]; } context.LTreeEntities.AddRange(ltreeEntities); diff --git a/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs index f88be7e10..d62f2518c 100644 --- a/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs @@ -488,7 +488,7 @@ public void Intersect_aggregate() .Select(g => g.Select(x => x.IntMultirange).RangeIntersectAgg()) .Single(); - Assert.Equal(new NpgsqlRange[] { new(4, true, 6, false), new(7, true, 9, false) }, intersection); + Assert.Equal([new(4, true, 6, false), new(7, true, 9, false)], intersection); AssertSql( """ @@ -759,36 +759,34 @@ public static void Seed(MultirangeContext context) new MultirangeTestEntity { Id = 1, - IntMultirange = new NpgsqlRange[] { new(0, 5), new(7, 10) }, - LongMultirange = new NpgsqlRange[] { new(0, 5), new(7, 10) }, - DecimalMultirange = new NpgsqlRange[] { new(0, 5), new(7, 10) }, + IntMultirange = [new(0, 5), new(7, 10)], + LongMultirange = [new(0, 5), new(7, 10)], + DecimalMultirange = [new(0, 5), new(7, 10)], DateOnlyDateMultirange = - new NpgsqlRange[] - { - new(new DateOnly(2020, 1, 1), new DateOnly(2020, 1, 5)), + [ + new(new DateOnly(2020, 1, 1), new DateOnly(2020, 1, 5)), new(new DateOnly(2020, 1, 7), new DateOnly(2020, 1, 10)) - }, - DateTimeDateMultirange = new NpgsqlRange[] - { + ], + DateTimeDateMultirange = + [ new(new DateTime(2020, 1, 1), new DateTime(2020, 1, 5)), new(new DateTime(2020, 1, 7), new DateTime(2020, 1, 10)) - } + ] }, new MultirangeTestEntity { Id = 2, - IntMultirange = new NpgsqlRange[] { new(4, 8), new(13, 20) }, - LongMultirange = new NpgsqlRange[] { new(4, 8), new(13, 20) }, - DecimalMultirange = new NpgsqlRange[] { new(4, 8), new(13, 20) }, + IntMultirange = [new(4, 8), new(13, 20)], + LongMultirange = [new(4, 8), new(13, 20)], + DecimalMultirange = [new(4, 8), new(13, 20)], DateOnlyDateMultirange = - new NpgsqlRange[] - { - new(new DateOnly(2020, 1, 4), new DateOnly(2020, 1, 8)), + [ + new(new DateOnly(2020, 1, 4), new DateOnly(2020, 1, 8)), new(new DateOnly(2020, 1, 13), new DateOnly(2020, 1, 20)) - }, - DateTimeDateMultirange = new NpgsqlRange[] - { + ], + DateTimeDateMultirange = + [ new(new DateTime(2020, 1, 4), new DateTime(2020, 1, 8)), new(new DateTime(2020, 1, 13), new DateTime(2020, 1, 20)) - } + ] }); context.SaveChanges(); diff --git a/test/EFCore.PG.FunctionalTests/Query/QueryFilterFuncletizationNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/QueryFilterFuncletizationNpgsqlTest.cs index cafe75bdb..4c820b3ef 100644 --- a/test/EFCore.PG.FunctionalTests/Query/QueryFilterFuncletizationNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/QueryFilterFuncletizationNpgsqlTest.cs @@ -22,15 +22,15 @@ public override void DbContext_list_is_parameterized() // when the list is null. We translate to server-side with PostgresAnyExpression, so no exception is thrown. // Assert.Throws(() => context.Set().ToList()); - context.TenantIds = new List(); + context.TenantIds = []; var query = context.Set().ToList(); Assert.Empty(query); - context.TenantIds = new List { 1 }; + context.TenantIds = [1]; query = context.Set().ToList(); Assert.Single(query); - context.TenantIds = new List { 2, 3 }; + context.TenantIds = [2, 3]; query = context.Set().ToList(); Assert.Equal(2, query.Count); } diff --git a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs index 880ade010..764a1a636 100644 --- a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs @@ -259,7 +259,7 @@ public void Union_aggregate() .Select(g => g.Select(x => x.IntRange).RangeAgg()) .Single(); - Assert.Equal(new NpgsqlRange[] { new(1, true, 16, false) }, union); + Assert.Equal([new(1, true, 16, false)], union); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs index 86d0c9b83..20d115583 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs @@ -24,7 +24,7 @@ protected override bool AssertDistances public static IEnumerable IsAsyncDataAndUseSpheroid = new[] { - new object[] { false, false }, new object[] { false, true }, new object[] { true, false }, new object[] { true, true } + [false, false], [false, true], [true, false], new object[] { true, true } }; public override async Task Area(bool async) diff --git a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs index 8e156866b..6bf97811b 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs @@ -740,7 +740,7 @@ public override async Task Z(bool async) [MemberData(nameof(IsAsyncData))] public virtual async Task MultiString_Any(bool async) { - var lineString = Fixture.GeometryFactory.CreateLineString(new[] { new Coordinate(1, 0), new Coordinate(1, 1) }); + var lineString = Fixture.GeometryFactory.CreateLineString([new Coordinate(1, 0), new Coordinate(1, 1)]); // Note the subtle difference between Contains and Any here: Contains resolves to Geometry.Contains, which checks whether a geometry // is contained in another; this is different from .NET collection/enumerable Contains, which checks whether an item is in a diff --git a/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs index b30d4e609..f94f7c692 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs @@ -978,7 +978,7 @@ public static IReadOnlyList CreateEntities() TimestampDateTimeOffset = new DateTimeOffset(utcDateTime1), TimestamptzDateTimeArray = utcDateTimeArray1, TimestampDateTimeArray = localDateTimeArray1, - TimestampDateTimeOffsetArray = new DateTimeOffset[] { new(utcDateTimeArray1[0]), new(utcDateTimeArray1[1]) }, + TimestampDateTimeOffsetArray = [new(utcDateTimeArray1[0]), new(utcDateTimeArray1[1])], TimestamptzDateTimeRange = utcDateTimeRange1, TimestampDateTimeRange = localDateTimeRange1, }, @@ -990,7 +990,7 @@ public static IReadOnlyList CreateEntities() TimestampDateTimeOffset = new DateTimeOffset(utcDateTime2), TimestamptzDateTimeArray = utcDateTimeArray2, TimestampDateTimeArray = localDateTimeArray2, - TimestampDateTimeOffsetArray = new DateTimeOffset[] { new(utcDateTimeArray2[0]), new(utcDateTimeArray2[1]) }, + TimestampDateTimeOffsetArray = [new(utcDateTimeArray2[0]), new(utcDateTimeArray2[1])], TimestamptzDateTimeRange = utcDateTimeRange2, TimestampDateTimeRange = localDateTimeRange2, } diff --git a/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs b/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs index 06b83238d..35b749fb0 100644 --- a/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs @@ -541,7 +541,7 @@ public void Create_primary_key() Assert.Equal("public", pk.Table.Schema); Assert.Equal("PrimaryKeyTable", pk.Table.Name); Assert.StartsWith("PrimaryKeyTable_pkey", pk.Name); - Assert.Equal(new List { "Id" }, pk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], pk.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""PrimaryKeyTable"""); @@ -571,12 +571,12 @@ public void Create_unique_constraints() Assert.Equal("public", firstConstraint.Table.Schema); Assert.Equal("UniqueConstraint", firstConstraint.Table.Name); //Assert.StartsWith("UQ__UniqueCo", uniqueConstraint.Name); - Assert.Equal(new List { "Name" }, firstConstraint.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Name"], firstConstraint.Columns.Select(ic => ic.Name).ToList()); var secondConstraint = table.UniqueConstraints.Single(c => c.Columns.Count == 2); Assert.Equal("public", secondConstraint.Table.Schema); Assert.Equal("UniqueConstraint", secondConstraint.Table.Name); - Assert.Equal(new List { "Unq1", "Unq2" }, secondConstraint.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Unq1", "Unq2"], secondConstraint.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""UniqueConstraint"""); @@ -645,8 +645,8 @@ FOREIGN KEY ("Id") REFERENCES "PrincipalTable"("Id") ON DELETE NO ACTION Assert.Equal("FirstDependent", firstFk.Table.Name); Assert.Equal("public", firstFk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", firstFk.PrincipalTable.Name); - Assert.Equal(new List { "ForeignKeyId" }, firstFk.Columns.Select(ic => ic.Name).ToList()); - Assert.Equal(new List { "Id" }, firstFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["ForeignKeyId"], firstFk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], firstFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, firstFk.OnDelete); var secondFk = Assert.Single(dbModel.Tables.Single(t => t.Name == "SecondDependent").ForeignKeys); @@ -656,8 +656,8 @@ FOREIGN KEY ("Id") REFERENCES "PrincipalTable"("Id") ON DELETE NO ACTION Assert.Equal("SecondDependent", secondFk.Table.Name); Assert.Equal("public", secondFk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", secondFk.PrincipalTable.Name); - Assert.Equal(new List { "Id" }, secondFk.Columns.Select(ic => ic.Name).ToList()); - Assert.Equal(new List { "Id" }, secondFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], secondFk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], secondFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.NoAction, secondFk.OnDelete); }, """ @@ -1090,7 +1090,7 @@ PRIMARY KEY ("Id2", "Id1") Assert.Equal("public", pk.Table.Schema); Assert.Equal("CompositePrimaryKeyTable", pk.Table.Name); - Assert.Equal(new List { "Id2", "Id1" }, pk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2", "Id1"], pk.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""CompositePrimaryKeyTable"""); @@ -1113,7 +1113,7 @@ public void Set_primary_key_name_from_index() Assert.Equal("public", pk.Table.Schema); Assert.Equal("PrimaryKeyName", pk.Table.Name); Assert.StartsWith("MyPK", pk.Name); - Assert.Equal(new List { "Id2" }, pk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2"], pk.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""PrimaryKeyName"""); @@ -1141,7 +1141,7 @@ public void Create_composite_unique_constraint() Assert.Equal("public", uniqueConstraint.Table.Schema); Assert.Equal("CompositeUniqueConstraintTable", uniqueConstraint.Table.Name); Assert.Equal("UX", uniqueConstraint.Name); - Assert.Equal(new List { "Id2", "Id1" }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2", "Id1"], uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""CompositeUniqueConstraintTable"""); @@ -1166,7 +1166,7 @@ public void Set_unique_constraint_name_from_index() Assert.Equal("public", uniqueConstraint.Table.Schema); Assert.Equal("UniqueConstraintName", uniqueConstraint.Table.Name); Assert.Equal("MyUC", uniqueConstraint.Name); - Assert.Equal(new List { "Id2" }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2"], uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); Assert.Empty(table.Indexes); }, @"DROP TABLE ""UniqueConstraintName"""); @@ -1196,7 +1196,7 @@ public void Create_composite_index() Assert.Equal("public", index.Table.Schema); Assert.Equal("CompositeIndexTable", index.Table.Name); Assert.Equal("IX_COMPOSITE", index.Name); - Assert.Equal(new List { "Id2", "Id1" }, index.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2", "Id1"], index.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""CompositeIndexTable"""); @@ -1223,7 +1223,7 @@ public void Set_unique_true_for_unique_index() Assert.Equal("IX_UNIQUE", index.Name); Assert.True(index.IsUnique); Assert.Null(index.Filter); - Assert.Equal(new List { "Id2" }, index.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2"], index.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""UniqueIndexTable"""); @@ -1249,7 +1249,7 @@ public void Set_filter_for_filtered_index() Assert.Equal("FilteredIndexTable", index.Table.Name); Assert.Equal("IX_UNIQUE", index.Name); Assert.Equal(@"(""Id2"" > 10)", index.Filter); - Assert.Equal(new List { "Id2" }, index.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2"], index.Columns.Select(ic => ic.Name).ToList()); }, @"DROP TABLE ""FilteredIndexTable"""); @@ -1285,8 +1285,8 @@ FOREIGN KEY ("ForeignKeyId1", "ForeignKeyId2") REFERENCES "PrincipalTable"("Id1" Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("public", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); - Assert.Equal(new List { "ForeignKeyId1", "ForeignKeyId2" }, fk.Columns.Select(ic => ic.Name).ToList()); - Assert.Equal(new List { "Id1", "Id2" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["ForeignKeyId1", "ForeignKeyId2"], fk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id1", "Id2"], fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); }, """ @@ -1329,8 +1329,8 @@ FOREIGN KEY ("ForeignKeyId2") REFERENCES "AnotherPrincipalTable"("Id") ON DELETE Assert.Equal("DependentTable", principalFk.Table.Name); Assert.Equal("public", principalFk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", principalFk.PrincipalTable.Name); - Assert.Equal(new List { "ForeignKeyId1" }, principalFk.Columns.Select(ic => ic.Name).ToList()); - Assert.Equal(new List { "Id" }, principalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["ForeignKeyId1"], principalFk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], principalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, principalFk.OnDelete); var anotherPrincipalFk = Assert.Single(foreignKeys.Where(f => f.PrincipalTable.Name == "AnotherPrincipalTable")); @@ -1340,8 +1340,8 @@ FOREIGN KEY ("ForeignKeyId2") REFERENCES "AnotherPrincipalTable"("Id") ON DELETE Assert.Equal("DependentTable", anotherPrincipalFk.Table.Name); Assert.Equal("public", anotherPrincipalFk.PrincipalTable.Schema); Assert.Equal("AnotherPrincipalTable", anotherPrincipalFk.PrincipalTable.Name); - Assert.Equal(new List { "ForeignKeyId2" }, anotherPrincipalFk.Columns.Select(ic => ic.Name).ToList()); - Assert.Equal(new List { "Id" }, anotherPrincipalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["ForeignKeyId2"], anotherPrincipalFk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], anotherPrincipalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, anotherPrincipalFk.OnDelete); }, """ @@ -1376,8 +1376,8 @@ FOREIGN KEY ("ForeignKeyId") REFERENCES "PrincipalTable"("Id2") ON DELETE CASCAD Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("public", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); - Assert.Equal(new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); - Assert.Equal(new List { "Id2" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["ForeignKeyId"], fk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id2"], fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); }, """ @@ -1410,8 +1410,8 @@ public void Set_name_for_foreign_key() Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("public", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); - Assert.Equal(new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); - Assert.Equal(new List { "Id" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["ForeignKeyId"], fk.Columns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); // ReSharper disable once StringLiteralTypo Assert.Equal("MYFK", fk.Name); @@ -1455,7 +1455,7 @@ FOREIGN KEY ("ForeignKeySetDefaultId") REFERENCES "PrincipalTable"("Id") ON DELE Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("public", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); - Assert.Equal(new List { "Id" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + Assert.Equal(["Id"], fk.PrincipalColumns.Select(ic => ic.Name).ToList()); } Assert.Equal( @@ -1886,7 +1886,7 @@ public void Index_covering() // Assert.Equal(new[] { "b", "c" }, indexWith.FindAnnotation(NpgsqlAnnotationNames.IndexInclude).Value); var indexWithout = table.Indexes.Single(i => i.Name == "ix_without"); - Assert.Equal(new[] { "a", "b", "c" }, indexWithout.Columns.Select(i => i.Name).ToArray()); + Assert.Equal(["a", "b", "c"], indexWithout.Columns.Select(i => i.Name).ToArray()); Assert.Null(indexWithout.FindAnnotation(NpgsqlAnnotationNames.IndexInclude)); }, @"DROP TABLE ""IndexCovering"""); @@ -2103,9 +2103,9 @@ line line new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), - Array.Empty() + [] ), - new RelationalTypeMappingSourceDependencies(Array.Empty()), + new RelationalTypeMappingSourceDependencies([]), new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()), options); diff --git a/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs b/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs index 55dd61c1c..34bf3dd30 100644 --- a/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs +++ b/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs @@ -27,26 +27,16 @@ public static IReadOnlyList CreateArrayEntities() new() { Id = 1, - IntArray = new[] { 3, 4 }, - IntList = new List { 3, 4 }, - NullableIntArray = new int?[] { 3, 4, null }, - NullableIntList = new List - { - 3, - 4, - null - }, - Bytea = new byte[] { 3, 4 }, - ByteArray = new byte[] { 3, 4 }, - StringArray = new[] { "3", "4" }, - NullableStringArray = new[] { "3", "4", null }, - StringList = new List { "3", "4" }, - NullableStringList = new List - { - "3", - "4", - null - }, + IntArray = [3, 4], + IntList = [3, 4], + NullableIntArray = [3, 4, null], + NullableIntList = [3, 4, null], + Bytea = [3, 4], + ByteArray = [3, 4], + StringArray = ["3", "4"], + NullableStringArray = ["3", "4", null], + StringList = ["3", "4"], + NullableStringList = ["3", "4", null], NullableText = "foo", NonNullableText = "foo", Varchar10 = "foo", @@ -55,48 +45,24 @@ public static IReadOnlyList CreateArrayEntities() EnumConvertedToString = SomeEnum.One, NullableEnumConvertedToString = SomeEnum.One, NullableEnumConvertedToStringWithNonNullableLambda = SomeEnum.One, - ValueConvertedArray = new[] { SomeEnum.Eight, SomeEnum.Nine }, - ValueConvertedList = new List { SomeEnum.Eight, SomeEnum.Nine }, + ValueConvertedArray = [SomeEnum.Eight, SomeEnum.Nine], + ValueConvertedList = [SomeEnum.Eight, SomeEnum.Nine], IList = new[] { 8, 9 }, Byte = 10 }, new() { Id = 2, - IntArray = new[] { 5, 6, 7, 8 }, - IntList = new List - { - 5, - 6, - 7, - 8 - }, - NullableIntArray = new int?[] { 5, 6, 7, 8 }, - NullableIntList = new List - { - 5, - 6, - 7, - 8 - }, - Bytea = new byte[] { 5, 6, 7, 8 }, - ByteArray = new byte[] { 5, 6, 7, 8 }, - StringArray = new[] { "5", "6", "7", "8" }, - NullableStringArray = new[] { "5", "6", "7", "8" }, - StringList = new List - { - "5", - "6", - "7", - "8" - }, - NullableStringList = new List - { - "5", - "6", - "7", - "8" - }, + IntArray = [5, 6, 7, 8], + IntList = [5, 6, 7, 8], + NullableIntArray = [5, 6, 7, 8], + NullableIntList = [5, 6, 7, 8], + Bytea = [5, 6, 7, 8], + ByteArray = [5, 6, 7, 8], + StringArray = ["5", "6", "7", "8"], + NullableStringArray = ["5", "6", "7", "8"], + StringList = ["5", "6", "7", "8"], + NullableStringList = ["5", "6", "7", "8"], NullableText = "bar", NonNullableText = "bar", Varchar10 = "bar", @@ -105,8 +71,8 @@ public static IReadOnlyList CreateArrayEntities() EnumConvertedToString = SomeEnum.Two, NullableEnumConvertedToString = SomeEnum.Two, NullableEnumConvertedToStringWithNonNullableLambda = SomeEnum.Two, - ValueConvertedArray = new[] { SomeEnum.Nine, SomeEnum.Ten }, - ValueConvertedList = new List { SomeEnum.Nine, SomeEnum.Ten }, + ValueConvertedArray = [SomeEnum.Nine, SomeEnum.Ten], + ValueConvertedList = [SomeEnum.Nine, SomeEnum.Ten], IList = new[] { 9, 10 }, Byte = 20 } diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlRetryingExecutionStrategy.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlRetryingExecutionStrategy.cs index 0c3c982f8..c443ccdc8 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlRetryingExecutionStrategy.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlRetryingExecutionStrategy.cs @@ -4,7 +4,7 @@ public class TestNpgsqlRetryingExecutionStrategy : NpgsqlRetryingExecutionStrate { private const bool ErrorNumberDebugMode = false; - private static readonly string[] AdditionalSqlStates = { "XX000" }; + private static readonly string[] AdditionalSqlStates = ["XX000"]; public TestNpgsqlRetryingExecutionStrategy() : base( diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs index 35e7dd1a4..6dcc65fd1 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs @@ -11,7 +11,7 @@ public virtual IRelationalCommandBuilder Create() private class TestRelationalCommandBuilder(RelationalCommandBuilderDependencies dependencies) : IRelationalCommandBuilder { - private readonly List _parameters = new(); + private readonly List _parameters = []; public IndentedStringBuilder Instance { get; } = new(); diff --git a/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs index 5cebb5470..6b7a7869f 100644 --- a/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs @@ -158,7 +158,7 @@ public async Task Can_insert_and_read_back_with_value_converted_array() { await using var ctx = CreateContext(); - var entity = new ValueConvertedArrayEntity { Values = new IntWrapper[] { new(8), new(9) } }; + var entity = new ValueConvertedArrayEntity { Values = [new(8), new(9)] }; ctx.Add(entity); await ctx.SaveChangesAsync(); diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs index 080a54bf3..e6e49a8be 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs @@ -63,7 +63,7 @@ public void GenerateSqlLiteral_returns_instant_range_in_legacy_mode() new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), - Array.Empty()), + []), new RelationalTypeMappingSourceDependencies( new IRelationalTypeMappingSourcePlugin[] { diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs index dabd1dba4..f59bcf5ef 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs @@ -1208,7 +1208,7 @@ public async Task Interval_RangeAgg(bool async) : query.Single(); var start = Instant.FromUtc(2018, 4, 20, 10, 31, 33).Plus(Duration.FromMilliseconds(666)); - Assert.Equal(new Interval[] { new(start, start + Duration.FromDays(5)) }, union); + Assert.Equal([new(start, start + Duration.FromDays(5))], union); AssertSql( """ @@ -1416,7 +1416,7 @@ public async Task DateInterval_RangeAgg(bool async) ? await query.SingleAsync() : query.Single(); - Assert.Equal(new DateInterval[] { new(new LocalDate(2018, 4, 20), new LocalDate(2018, 4, 24)) }, union); + Assert.Equal([new(new LocalDate(2018, 4, 20), new LocalDate(2018, 4, 24))], union); AssertSql( """ diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs index ddf7e078d..f2cb829af 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/NpgsqlNodaTimeTypeMappingTest.cs @@ -838,7 +838,7 @@ public void GenerateCodeLiteral_returns_DateTimezone_literal() new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), - Array.Empty()), + []), new RelationalTypeMappingSourceDependencies( new IRelationalTypeMappingSourcePlugin[] { diff --git a/test/EFCore.PG.Tests/Design/Internal/NpgsqlAnnotationCodeGeneratorTest.cs b/test/EFCore.PG.Tests/Design/Internal/NpgsqlAnnotationCodeGeneratorTest.cs index f0323eac3..ec9cff986 100644 --- a/test/EFCore.PG.Tests/Design/Internal/NpgsqlAnnotationCodeGeneratorTest.cs +++ b/test/EFCore.PG.Tests/Design/Internal/NpgsqlAnnotationCodeGeneratorTest.cs @@ -404,9 +404,9 @@ private NpgsqlAnnotationCodeGenerator CreateGenerator() new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), - Array.Empty() + [] ), - new RelationalTypeMappingSourceDependencies(Array.Empty()), + new RelationalTypeMappingSourceDependencies([]), new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()), new NpgsqlSingletonOptions()))); } diff --git a/test/EFCore.PG.Tests/Metadata/NpgsqlBuilderExtensionsTest.cs b/test/EFCore.PG.Tests/Metadata/NpgsqlBuilderExtensionsTest.cs index f16f06749..b4efac2bd 100644 --- a/test/EFCore.PG.Tests/Metadata/NpgsqlBuilderExtensionsTest.cs +++ b/test/EFCore.PG.Tests/Metadata/NpgsqlBuilderExtensionsTest.cs @@ -11,7 +11,7 @@ public void CockroachDbInterleaveInParent() modelBuilder.Entity() .ToTable("customers", "my_schema") - .UseCockroachDbInterleaveInParent(typeof(Customer), new List { "col_a", "col_b" }); + .UseCockroachDbInterleaveInParent(typeof(Customer), ["col_a", "col_b"]); var entityType = modelBuilder.Model.FindEntityType(typeof(Customer)); var interleaveInParent = entityType.GetCockroachDbInterleaveInParent(); diff --git a/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs b/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs index 5f52f567d..029c02ecb 100644 --- a/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs +++ b/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs @@ -12,9 +12,7 @@ protected override Assembly TargetAssembly public class NpgsqlNetTopologySuiteApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new() - { - typeof(NpgsqlNetTopologySuiteDbContextOptionsBuilderExtensions), typeof(NpgsqlNetTopologySuiteServiceCollectionExtensions) - }; + public override HashSet FluentApiTypes { get; } = + [typeof(NpgsqlNetTopologySuiteDbContextOptionsBuilderExtensions), typeof(NpgsqlNetTopologySuiteServiceCollectionExtensions)]; } } diff --git a/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs b/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs index ff79bc1ce..d1e6798a4 100644 --- a/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs +++ b/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs @@ -11,9 +11,7 @@ protected override Assembly TargetAssembly public class NpgsqlNodaTimeApiConsistencyFixture : ApiConsistencyFixtureBase { - public override HashSet FluentApiTypes { get; } = new() - { - typeof(NpgsqlNodaTimeDbContextOptionsBuilderExtensions), typeof(NpgsqlNodaTimeServiceCollectionExtensions) - }; + public override HashSet FluentApiTypes { get; } = + [typeof(NpgsqlNodaTimeDbContextOptionsBuilderExtensions), typeof(NpgsqlNodaTimeServiceCollectionExtensions)]; } } diff --git a/test/EFCore.PG.Tests/Scaffolding/NpgsqlCodeGeneratorTest.cs b/test/EFCore.PG.Tests/Scaffolding/NpgsqlCodeGeneratorTest.cs index 3f68c3341..5b2d1348b 100644 --- a/test/EFCore.PG.Tests/Scaffolding/NpgsqlCodeGeneratorTest.cs +++ b/test/EFCore.PG.Tests/Scaffolding/NpgsqlCodeGeneratorTest.cs @@ -95,7 +95,7 @@ public virtual void Use_provider_method_is_generated_correctly_with_NodaTime() } private static readonly MethodInfo _setProviderOptionMethodInfo - = typeof(NpgsqlCodeGeneratorTest).GetRuntimeMethod(nameof(SetProviderOption), new[] { typeof(DbContextOptionsBuilder) }); + = typeof(NpgsqlCodeGeneratorTest).GetRuntimeMethod(nameof(SetProviderOption), [typeof(DbContextOptionsBuilder)]); public static NpgsqlDbContextOptionsBuilder SetProviderOption(DbContextOptionsBuilder optionsBuilder) => throw new NotSupportedException(); diff --git a/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs b/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs index 64400b9c4..ac536bd4d 100644 --- a/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs +++ b/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs @@ -49,9 +49,9 @@ public void GenerateSqlLiteral_returns_timestamptz_datetime_literal() new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), - Array.Empty() + [] ), - new RelationalTypeMappingSourceDependencies(Array.Empty()), + new RelationalTypeMappingSourceDependencies([]), new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()), new NpgsqlSingletonOptions()); diff --git a/test/EFCore.PG.Tests/Storage/NpgsqlArrayValueConverterTest.cs b/test/EFCore.PG.Tests/Storage/NpgsqlArrayValueConverterTest.cs index ebfe3ba45..0f16dd6b2 100644 --- a/test/EFCore.PG.Tests/Storage/NpgsqlArrayValueConverterTest.cs +++ b/test/EFCore.PG.Tests/Storage/NpgsqlArrayValueConverterTest.cs @@ -12,12 +12,12 @@ public void Can_convert_enum_arrays_to_number_arrays() { var converter = EnumArrayToNumberArray.ConvertToProviderExpression.Compile(); - Assert.Equal(new[] { 7 }, converter(new[] { Beatles.John })); - Assert.Equal(new[] { 4 }, converter(new[] { Beatles.Paul })); - Assert.Equal(new[] { 1 }, converter(new[] { Beatles.George })); - Assert.Equal(new[] { -1 }, converter(new[] { Beatles.Ringo })); - Assert.Equal(new[] { 77 }, converter(new[] { (Beatles)77 })); - Assert.Equal(new[] { 0 }, converter(new[] { default(Beatles) })); + Assert.Equal([7], converter([Beatles.John])); + Assert.Equal([4], converter([Beatles.Paul])); + Assert.Equal([1], converter([Beatles.George])); + Assert.Equal([-1], converter([Beatles.Ringo])); + Assert.Equal([77], converter([(Beatles)77])); + Assert.Equal([0], converter([default(Beatles)])); Assert.Null(converter(null)); } @@ -40,12 +40,12 @@ public void Can_convert_number_arrays_to_enum_arrays() { var converter = EnumArrayToNumberArray.ConvertFromProviderExpression.Compile(); - Assert.Equal(new[] { Beatles.John }, converter(new[] { 7 })); - Assert.Equal(new[] { Beatles.Paul }, converter(new[] { 4 })); - Assert.Equal(new[] { Beatles.George }, converter(new[] { 1 })); - Assert.Equal(new[] { Beatles.Ringo }, converter(new[] { -1 })); - Assert.Equal(new[] { (Beatles)77 }, converter(new[] { 77 })); - Assert.Equal(new[] { default(Beatles) }, converter(new[] { 0 })); + Assert.Equal([Beatles.John], converter([7])); + Assert.Equal([Beatles.Paul], converter([4])); + Assert.Equal([Beatles.George], converter([1])); + Assert.Equal([Beatles.Ringo], converter([-1])); + Assert.Equal([(Beatles)77], converter([77])); + Assert.Equal([default(Beatles)], converter([0])); Assert.Null(converter(null)); } diff --git a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs index a1dca3a49..c16e5d2d2 100644 --- a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs +++ b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs @@ -308,7 +308,7 @@ private NpgsqlTypeMappingSource CreateTypeMappingSource(Version postgresVersion new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), - Array.Empty()), + []), new RelationalTypeMappingSourceDependencies( new IRelationalTypeMappingSourcePlugin[] { diff --git a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs index f2e558f1e..77f45d8bf 100644 --- a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs +++ b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingTest.cs @@ -939,8 +939,8 @@ public void ValueComparer_JsonElement() Name = "Joe", Age = 25, IsVip = false, - Orders = new[] - { + Orders = + [ new Order { Price = 99.5m, @@ -953,7 +953,7 @@ public void ValueComparer_JsonElement() ShippingAddress = "Some address 2", ShippingDate = new DateTime(2019, 10, 10) } - } + ] }; public class Customer @@ -979,9 +979,9 @@ public class Order new TypeMappingSourceDependencies( new ValueConverterSelector(new ValueConverterSelectorDependencies()), new JsonValueReaderWriterSource(new JsonValueReaderWriterSourceDependencies()), - Array.Empty() + [] ), - new RelationalTypeMappingSourceDependencies(Array.Empty()), + new RelationalTypeMappingSourceDependencies([]), new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()), new NpgsqlSingletonOptions() );