diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index ec445e4..7e3a22a 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -9,7 +9,7 @@
]
},
"dotnet-reportgenerator-globaltool": {
- "version": "5.2.0",
+ "version": "5.2.4",
"commands": [
"reportgenerator"
]
diff --git a/.editorconfig b/.editorconfig
index 1368c97..c0b6e56 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -17,6 +17,15 @@ indent_size = 2
# C# files
[*.cs]
csharp_style_namespace_declarations = file_scoped
+csharp_style_expression_bodied_methods = true:silent
+csharp_style_namespace_declarations = file_scoped
+csharp_style_expression_bodied_operators = true
+csharp_style_expression_bodied_local_functions = true
+
+csharp_style_var_for_built_in_types = true:error
+csharp_style_var_when_type_is_apparent = true:error
+csharp_style_var_elsewhere = true:error
+
dotnet_diagnostic.IDE0005.severity = warning
#### Core EditorConfig Options ####
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 16a08f2..0581c60 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -8,22 +8,22 @@
7.0.0
- 8.0.2
- 8.0.0
+ 8.0.4
+ 8.0.2
-
+
-
+
-
+
@@ -32,8 +32,8 @@
-
+
-
+
\ No newline at end of file
diff --git a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs
index e1827de..38d857b 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs
@@ -11,10 +11,7 @@ public static class NpgsqlDbContextOptionsBuilderExtensions
/// The build being used to configure Postgres.
/// The same builder so that further configuration can be chained.
public static NpgsqlDbContextOptionsBuilder UseBinaryFunctions(
- this NpgsqlDbContextOptionsBuilder builder)
- {
- return builder.AddOrUpdateExtension();
- }
+ this NpgsqlDbContextOptionsBuilder builder) => builder.AddOrUpdateExtension();
private static NpgsqlDbContextOptionsBuilder AddOrUpdateExtension(
this NpgsqlDbContextOptionsBuilder builder)
@@ -25,9 +22,9 @@ private static NpgsqlDbContextOptionsBuilder AddOrUpdateExtension(
var extension = coreOptionsBuilder.Options.FindExtension() ?? new NpgsqlDbContextOptionsExtension();
((IDbContextOptionsBuilderInfrastructure)coreOptionsBuilder).AddOrUpdateExtension(extension);
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
return builder;
}
diff --git a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs
index d55065e..00f837a 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs
@@ -18,14 +18,9 @@ public void Validate(IDbContextOptions options)
{
}
- private sealed class ExtensionInfo : BinaryFunctions.Infrastructure.Internal.ExtensionInfo
+ private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : BinaryFunctions.Infrastructure.Internal.ExtensionInfo(extension)
{
- public ExtensionInfo(IDbContextOptionsExtension extension)
- : base(extension)
- {
- }
-
- private new NpgsqlDbContextOptionsExtension Extension
+ public override IDbContextOptionsExtension Extension
=> (NpgsqlDbContextOptionsExtension)base.Extension;
}
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGenerator.cs b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGenerator.cs
index b005623..550c98a 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGenerator.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGenerator.cs
@@ -3,6 +3,7 @@
///
/// Query SQL generator for Npgsql which includes binary operations.
///
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class BinaryNpgsqlQuerySqlGenerator : NpgsqlQuerySqlGenerator
{
#if !EF_CORE_7 && !EF_CORE_6
@@ -31,6 +32,7 @@ public BinaryNpgsqlQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies,
#endif
///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0072:Add missing cases", Justification = "Only interested in Add for binary")]
protected override string GetOperator(SqlBinaryExpression e)
=> e.OperatorType switch
{
diff --git a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGeneratorFactory.cs b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGeneratorFactory.cs
index 5048cb6..1b852b8 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGeneratorFactory.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/BinaryNpgsqlQuerySqlGeneratorFactory.cs
@@ -3,6 +3,7 @@
///
/// Factory for generating .
///
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class BinaryNpgsqlQuerySqlGeneratorFactory : NpgsqlQuerySqlGeneratorFactory
{
private readonly QuerySqlGeneratorDependencies dependencies;
@@ -39,11 +40,12 @@ public BinaryNpgsqlQuerySqlGeneratorFactory(QuerySqlGeneratorDependencies depend
}
#endif
- ///
#if !EF_CORE_7 && !EF_CORE_6
+ ///
public override QuerySqlGenerator Create()
=> new BinaryNpgsqlQuerySqlGenerator(dependencies, relationalTypeMappingSource, npgsqlOptions.ReverseNullOrderingEnabled, npgsqlOptions.PostgresVersion);
#else
+ ///
public override QuerySqlGenerator Create()
=> new BinaryNpgsqlQuerySqlGenerator(dependencies, npgsqlOptions.ReverseNullOrderingEnabled, npgsqlOptions.PostgresVersion);
#endif
diff --git a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslator.cs b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslator.cs
index 541665a..d6ef9d8 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslator.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslator.cs
@@ -3,26 +3,19 @@
///
/// A SQL translator for binary functions in Postgres.
///
-public class NpgsqlBinaryTranslator : BinaryTranslator
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class NpgsqlBinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : BinaryTranslator(sqlExpressionFactory, relationalTypeMappingSource)
{
private static readonly bool[] LPadArgumentsPropagateNullability = [true, false, false];
private static readonly bool[] DecodeArgumentsPropagateNullabilityArray = [true, false];
private static readonly bool[] ToHexArgumentsPropagateNullabilityArray = [true];
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly RelationalTypeMapping? byteArrayTypeMapping;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public NpgsqlBinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- byteArrayTypeMapping = relationalTypeMappingSource.FindMapping(typeof(byte[]));
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
+ private readonly RelationalTypeMapping? byteArrayTypeMapping = relationalTypeMappingSource.FindMapping(typeof(byte[]));
///
protected override SqlExpression BinaryCast(SqlExpression sqlExpression, Type toType)
@@ -42,7 +35,7 @@ protected override SqlExpression BinaryCast(SqlExpression sqlExpression, Type to
protected override SqlExpression GetBytes(SqlExpression sqlExpression)
{
// Generate an expression like this: decode(LPAD(to_hex(r."SomeInt"), 8, '0'), 'hex')::bytea
- var toHex = sqlExpressionFactory.Function("to_hex", new[] { sqlExpression }, true, ToHexArgumentsPropagateNullabilityArray, typeof(string));
+ var toHex = sqlExpressionFactory.Function("to_hex", [sqlExpression], true, ToHexArgumentsPropagateNullabilityArray, typeof(string));
var type = sqlExpression.Type;
int sizeOfType;
if (type == typeof(DateTime))
@@ -60,8 +53,8 @@ protected override SqlExpression GetBytes(SqlExpression sqlExpression)
var byteSize = new SqlConstantExpression(Expression.Constant(sizeOfType * 2), null);
var zero = new SqlConstantExpression(Expression.Constant("0"), null);
var hex = new SqlConstantExpression(Expression.Constant("hex"), null);
- var lPad = sqlExpressionFactory.Function("LPAD", new SqlExpression[] { toHex, byteSize, zero }, true, LPadArgumentsPropagateNullability, typeof(string));
- var decode = sqlExpressionFactory.Function("decode", new SqlExpression[] { lPad, hex }, true, DecodeArgumentsPropagateNullabilityArray, typeof(string), byteArrayTypeMapping);
+ var lPad = sqlExpressionFactory.Function("LPAD", [toHex, byteSize, zero], true, LPadArgumentsPropagateNullability, typeof(string));
+ var decode = sqlExpressionFactory.Function("decode", [lPad, hex], true, DecodeArgumentsPropagateNullabilityArray, typeof(string), byteArrayTypeMapping);
return new SqlUnaryExpression(ExpressionType.Convert, decode, typeof(byte[]), byteArrayTypeMapping);
}
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslatorPluginFactory.cs b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslatorPluginFactory.cs
index 4586b39..13a30e6 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslatorPluginFactory.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Query/Internal/NpgsqlBinaryTranslatorPluginFactory.cs
@@ -3,22 +3,15 @@
///
/// Binary translator plugin factory for Postgres provider.
///
-public class NpgsqlBinaryTranslatorPluginFactory : BinaryTranslatorPluginFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class NpgsqlBinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : BinaryTranslatorPluginFactory(sqlExpressionFactory, relationalTypeMappingSource)
{
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public NpgsqlBinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
+ private readonly IRelationalTypeMappingSource relationalTypeMappingSource = relationalTypeMappingSource;
///
public override BinaryTranslator Create()
diff --git a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Storage/Internal/BinaryNpgsqlTypeMappingSource.cs b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Storage/Internal/BinaryNpgsqlTypeMappingSource.cs
index 80024e4..ba2b98e 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Npgsql/Storage/Internal/BinaryNpgsqlTypeMappingSource.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Npgsql/Storage/Internal/BinaryNpgsqlTypeMappingSource.cs
@@ -3,20 +3,15 @@
///
/// Binary type mapping source for Postgres provider.
///
-public class BinaryNpgsqlTypeMappingSource : NpgsqlTypeMappingSource
+///
+/// Initializes a new instance of the class.
+///
+/// Type mapping source dependencies.
+/// Relational type mapping source dependencies.
+/// sqlGenerationHelper.
+/// Npgsql Options.
+public class BinaryNpgsqlTypeMappingSource(TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies, ISqlGenerationHelper sqlGenerationHelper, INpgsqlSingletonOptions npgsqlOptions) : NpgsqlTypeMappingSource(dependencies, relationalDependencies, sqlGenerationHelper, npgsqlOptions)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Type mapping source dependencies.
- /// Relational type mapping source dependencies.
- /// sqlGenerationHelper.
- /// Npgsql Options.
- public BinaryNpgsqlTypeMappingSource(TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies, ISqlGenerationHelper sqlGenerationHelper, INpgsqlSingletonOptions npgsqlOptions)
- : base(dependencies, relationalDependencies, sqlGenerationHelper, npgsqlOptions)
- {
- }
-
/*
protected override RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo)
{
@@ -29,7 +24,7 @@ public BinaryNpgsqlTypeMappingSource(TypeMappingSourceDependencies dependencies,
*/
// This is to turn an expression into a bit array.
- // Unfortinately I didn't come across a good way of translating bit(n) into bytea
+ // Unfortunately I didn't come across a good way of translating bit(n) into bytea
///
protected override RelationalTypeMapping? FindBaseMapping(in RelationalTypeMappingInfo mappingInfo)
diff --git a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs
index b903d77..aaf86d8 100644
--- a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs
@@ -13,7 +13,7 @@ public static class SqlServerDbContextOptionsBuilderExtensions
public static SqlServerDbContextOptionsBuilder UseBinaryFunctions(
this SqlServerDbContextOptionsBuilder builder)
{
- builder.AddOrUpdateExtension();
+ _ = builder.AddOrUpdateExtension();
return builder;
}
@@ -26,8 +26,8 @@ private static SqlServerDbContextOptionsBuilder AddOrUpdateExtension(
var extension = coreOptionsBuilder.Options.FindExtension() ?? new SqlServerDbContextOptionsExtension();
((IDbContextOptionsBuilderInfrastructure)coreOptionsBuilder).AddOrUpdateExtension(extension);
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
return builder;
}
diff --git a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslator.cs b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslator.cs
index d4a6e9f..19486ea 100644
--- a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslator.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslator.cs
@@ -3,7 +3,12 @@
///
/// A SQL translator for binary functions in SQL Server.
///
-public class SqlServerBinaryTranslator : BinaryTranslator
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class SqlServerBinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : BinaryTranslator(sqlExpressionFactory, relationalTypeMappingSource)
{
private static readonly bool[] SignArgumentsPropagateNullability = [true];
private static readonly bool[] PowerArgumentsPropagateNullability = [false, false];
@@ -26,18 +31,7 @@ public class SqlServerBinaryTranslator : BinaryTranslator
var x0010000000000000 = GetBytes(new SqlConstantExpression(Expression.Constant(0x0010000000000000), null));
* */
- private readonly ISqlExpressionFactory sqlExpressionFactory;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public SqlServerBinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
///
protected override SqlExpression ToValue(SqlExpression sqlExpression, Type type)
@@ -60,7 +54,7 @@ private SqlBinaryExpression ToDouble(SqlExpression sqlExpression)
var sql1023 = new SqlConstantExpression(Expression.Constant(1023), null);
// Line 1
- var l1 = sqlExpressionFactory.Function("SIGN", new[] { colNameBigInt }, true, SignArgumentsPropagateNullability, colNameBigInt.Type);
+ var l1 = sqlExpressionFactory.Function("SIGN", [colNameBigInt], true, SignArgumentsPropagateNullability, colNameBigInt.Type);
// Line 2
var l2e1 = new SqlBinaryExpression(ExpressionType.And, colNameBigInt, X000FFFFFFFFFFFFF, typeof(long), null);
@@ -72,7 +66,7 @@ private SqlBinaryExpression ToDouble(SqlExpression sqlExpression)
var l3e1 = new SqlBinaryExpression(ExpressionType.And, colNameBigInt, X7ff0000000000000, typeof(long), null);
var l3e2 = new SqlBinaryExpression(ExpressionType.Divide, l3e1, X0010000000000000, typeof(long), null);
var l3e3 = new SqlBinaryExpression(ExpressionType.Subtract, l3e2, sql1023, typeof(long), null);
- var l3 = sqlExpressionFactory.Function("POWER", new SqlExpression[] { TwoFloat, l3e3 }, false, PowerArgumentsPropagateNullability, colNameBigInt.Type);
+ var l3 = sqlExpressionFactory.Function("POWER", [TwoFloat, l3e3], false, PowerArgumentsPropagateNullability, colNameBigInt.Type);
var l1l2 = new SqlBinaryExpression(ExpressionType.Multiply, l1, l2, typeof(double), null);
var final = new SqlBinaryExpression(ExpressionType.Multiply, l1l2, l3, typeof(double), null);
diff --git a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslatorPluginFactory.cs b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslatorPluginFactory.cs
index b614b16..eb10038 100644
--- a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslatorPluginFactory.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerBinaryTranslatorPluginFactory.cs
@@ -3,22 +3,15 @@
///
/// Sql Server BinaryTranslator Plugin Factory.
///
-public class SqlServerBinaryTranslatorPluginFactory : BinaryTranslatorPluginFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class SqlServerBinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : BinaryTranslatorPluginFactory(sqlExpressionFactory, relationalTypeMappingSource)
{
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public SqlServerBinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
+ private readonly IRelationalTypeMappingSource relationalTypeMappingSource = relationalTypeMappingSource;
///
public override BinaryTranslator Create()
diff --git a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs
index e09fc4e..26e0a75 100644
--- a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs
@@ -18,14 +18,9 @@ public void Validate(IDbContextOptions options)
{
}
- private sealed class ExtensionInfo : BinaryFunctions.Infrastructure.Internal.ExtensionInfo
+ private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : BinaryFunctions.Infrastructure.Internal.ExtensionInfo(extension)
{
- public ExtensionInfo(IDbContextOptionsExtension extension)
- : base(extension)
- {
- }
-
- private new SqlServerDbContextOptionsExtension Extension
+ public override IDbContextOptionsExtension Extension
=> (SqlServerDbContextOptionsExtension)base.Extension;
}
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Storage/Internal/BinarySqlServerTypeMappingSource.cs b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Storage/Internal/BinarySqlServerTypeMappingSource.cs
index 7eb4c65..75a330b 100644
--- a/src/Zomp.EFCore.BinaryFunctions.SqlServer/Storage/Internal/BinarySqlServerTypeMappingSource.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.SqlServer/Storage/Internal/BinarySqlServerTypeMappingSource.cs
@@ -3,6 +3,7 @@
///
/// Binary type mapping source for SQL Server provider.
///
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class BinarySqlServerTypeMappingSource : SqlServerTypeMappingSource
{
#if !EF_CORE_6 && !EF_CORE_7
@@ -48,7 +49,7 @@ public BinarySqlServerTypeMappingSource(TypeMappingSourceDependencies dependenci
var clrType = underlyingMapping.ClrType;
- int fixedSize
+ var fixedSize
= clrType == typeof(DateTime) ? 9
: clrType == typeof(bool) ? 1
: Marshal.SizeOf(clrType);
diff --git a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
index d19e694..cf7492e 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
@@ -11,10 +11,7 @@ public static class SqliteDbContextOptionsBuilderExtensions
/// The build being used to configure Postgres.
/// The same builder so that further configuration can be chained.
public static SqliteDbContextOptionsBuilder UseBinaryFunctions(
- this SqliteDbContextOptionsBuilder builder)
- {
- return builder.AddOrUpdateExtension();
- }
+ this SqliteDbContextOptionsBuilder builder) => builder.AddOrUpdateExtension();
private static SqliteDbContextOptionsBuilder AddOrUpdateExtension(
this SqliteDbContextOptionsBuilder sqliteOptionsBuilder)
@@ -25,8 +22,8 @@ private static SqliteDbContextOptionsBuilder AddOrUpdateExtension(
var extension = coreOptionsBuilder.Options.FindExtension() ?? new SqliteDbContextOptionsExtension();
((IDbContextOptionsBuilderInfrastructure)coreOptionsBuilder).AddOrUpdateExtension(extension);
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService()
+ .ReplaceService();
return sqliteOptionsBuilder;
}
diff --git a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslator.cs b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslator.cs
index b6c6c84..97af780 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslator.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslator.cs
@@ -3,22 +3,17 @@
///
/// A SQL translator for binary functions in SQLite.
///
-public class SqliteBinaryTranslator : BinaryTranslator
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class SqliteBinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : BinaryTranslator(sqlExpressionFactory, relationalTypeMappingSource)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public SqliteBinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- }
-
///
protected override SqlExpression BinaryCast(SqlExpression sqlExpression, Type toType)
{
- Type fromType = sqlExpression.Type;
+ var fromType = sqlExpression.Type;
if (fromType == typeof(double) || fromType == typeof(float))
{
diff --git a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslatorPluginFactory.cs b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslatorPluginFactory.cs
index 71d37f4..b905c27 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslatorPluginFactory.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Query/Internal/SqliteBinaryTranslatorPluginFactory.cs
@@ -3,22 +3,15 @@
///
/// Factory for instances.
///
-public class SqliteBinaryTranslatorPluginFactory : BinaryTranslatorPluginFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class SqliteBinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : BinaryTranslatorPluginFactory(sqlExpressionFactory, relationalTypeMappingSource)
{
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public SqliteBinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
+ private readonly IRelationalTypeMappingSource relationalTypeMappingSource = relationalTypeMappingSource;
///
public override BinaryTranslator Create()
diff --git a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Storage/Internal/BinarySqliteTypeMappingSource.cs b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Storage/Internal/BinarySqliteTypeMappingSource.cs
index 5af9fd5..ada6eba 100644
--- a/src/Zomp.EFCore.BinaryFunctions.Sqlite/Storage/Internal/BinarySqliteTypeMappingSource.cs
+++ b/src/Zomp.EFCore.BinaryFunctions.Sqlite/Storage/Internal/BinarySqliteTypeMappingSource.cs
@@ -3,28 +3,18 @@
///
/// Binary type mapping source for SQLite provider.
///
-public class BinarySqliteTypeMappingSource : SqliteTypeMappingSource
+///
+/// Initializes a new instance of the class.
+///
+/// The Type Mapping Source Dependencies.
+/// Relational Type Mapping Source Dependencies.
+public class BinarySqliteTypeMappingSource(TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies) : SqliteTypeMappingSource(dependencies, relationalDependencies)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The Type Mapping Source Dependencies.
- /// Relational Type Mapping Source Dependencies.
- public BinarySqliteTypeMappingSource(TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies)
- : base(dependencies, relationalDependencies)
- {
- }
-
///
protected override RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo)
- {
- if (mappingInfo.ClrType is not { } type
+ => mappingInfo.ClrType is not { } type
|| !type.IsGenericType
- || type.GetGenericTypeDefinition() != typeof(FixedByteArray<>))
- {
- return base.FindMapping(mappingInfo);
- }
-
- return ((IRelationalTypeMappingSource)this).FindMapping(typeof(byte[]));
- }
+ || type.GetGenericTypeDefinition() != typeof(FixedByteArray<>)
+ ? base.FindMapping(mappingInfo)
+ : ((IRelationalTypeMappingSource)this).FindMapping(typeof(byte[]));
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.BinaryFunctions/Extensions/BinaryServiceCollectionExtensions.cs b/src/Zomp.EFCore.BinaryFunctions/Extensions/BinaryServiceCollectionExtensions.cs
index fef2152..901d965 100644
--- a/src/Zomp.EFCore.BinaryFunctions/Extensions/BinaryServiceCollectionExtensions.cs
+++ b/src/Zomp.EFCore.BinaryFunctions/Extensions/BinaryServiceCollectionExtensions.cs
@@ -13,7 +13,7 @@ public static class BinaryServiceCollectionExtensions
public static IServiceCollection AddBinaryFunctionsExtension(
this IServiceCollection serviceCollection)
{
- new EntityFrameworkRelationalServicesBuilder(serviceCollection)
+ _ = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
.TryAdd()
.TryAddProviderSpecificServices(b => b
.TryAddScoped());
diff --git a/src/Zomp.EFCore.BinaryFunctions/Infrastructure/Internal/ExtensionInfo.cs b/src/Zomp.EFCore.BinaryFunctions/Infrastructure/Internal/ExtensionInfo.cs
index cf5a974..240ae45 100644
--- a/src/Zomp.EFCore.BinaryFunctions/Infrastructure/Internal/ExtensionInfo.cs
+++ b/src/Zomp.EFCore.BinaryFunctions/Infrastructure/Internal/ExtensionInfo.cs
@@ -3,17 +3,12 @@
///
/// Information/metadata for the extension.
///
-public class ExtensionInfo : DbContextOptionsExtensionInfo
+///
+/// Initializes a new instance of the class.
+///
+/// The extension.
+public class ExtensionInfo(IDbContextOptionsExtension extension) : DbContextOptionsExtensionInfo(extension)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The extension.
- public ExtensionInfo(IDbContextOptionsExtension extension)
- : base(extension)
- {
- }
-
///
public override bool IsDatabaseProvider
=> false;
diff --git a/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslator.cs b/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslator.cs
index d575f68..c9a3feb 100644
--- a/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslator.cs
+++ b/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslator.cs
@@ -3,22 +3,16 @@
///
/// A SQL translator for binary functions.
///
-public class BinaryTranslator : IMethodCallTranslator
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class BinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : IMethodCallTranslator
{
private static readonly bool[] SubstringArgumentsPropagateNullability = [true, true, true];
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public BinaryTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
+ private readonly IRelationalTypeMappingSource relationalTypeMappingSource = relationalTypeMappingSource;
///
public SqlExpression? Translate(SqlExpression? instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger)
@@ -65,7 +59,7 @@ protected virtual SqlExpression GetBytes(SqlExpression sqlExpression)
///
protected SqlExpression GetFixedBytes(SqlExpression sqlExpression, Type toType)
{
- Type t = Type.MakeGenericSignatureType(typeof(FixedByteArray<>), [toType]);
+ var t = Type.MakeGenericSignatureType(typeof(FixedByteArray<>), [toType]);
var mapping = relationalTypeMappingSource.FindMapping(t);
return new SqlUnaryExpression(ExpressionType.Convert, sqlExpressionFactory.ApplyDefaultTypeMapping(sqlExpression), typeof(byte[]), mapping);
}
@@ -92,19 +86,15 @@ private SqlExpression ToValue(SqlExpression sqlExpression, SqlExpression offset,
Substring(sqlExpression, offset, new SqlConstantExpression(Expression.Constant(Marshal.SizeOf(type)), null)),
type);
- private SqlFunctionExpression Substring(SqlExpression bytearray, SqlExpression start, SqlExpression length)
- {
- return sqlExpressionFactory.Function(
+ private SqlFunctionExpression Substring(SqlExpression bytearray, SqlExpression start, SqlExpression length) => sqlExpressionFactory.Function(
"SUBSTRING",
- new[]
- {
- bytearray,
- start,
- length,
- },
+ [
+ bytearray,
+ start,
+ length,
+ ],
nullable: true,
argumentsPropagateNullability: SubstringArgumentsPropagateNullability,
bytearray.Type,
null);
- }
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslatorPluginFactory.cs b/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslatorPluginFactory.cs
index cf393f5..0cef8a7 100644
--- a/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslatorPluginFactory.cs
+++ b/src/Zomp.EFCore.BinaryFunctions/Query/Internal/BinaryTranslatorPluginFactory.cs
@@ -3,25 +3,16 @@
///
/// Factory for BinaryTranslatorPlugin.
///
-public class BinaryTranslatorPluginFactory : IBinaryTranslatorPluginFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+/// Instance relational type mapping source.
+public class BinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource) : IBinaryTranslatorPluginFactory
{
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public BinaryTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
+ private readonly IRelationalTypeMappingSource relationalTypeMappingSource = relationalTypeMappingSource;
///
- public virtual BinaryTranslator Create()
- {
- return new BinaryTranslator(sqlExpressionFactory, relationalTypeMappingSource);
- }
+ public virtual BinaryTranslator Create() => new(sqlExpressionFactory, relationalTypeMappingSource);
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs
index d13b2ed..44bedd7 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Extensions/NpgsqlDbContextOptionsBuilderExtensions.cs
@@ -11,10 +11,7 @@ public static class NpgsqlDbContextOptionsBuilderExtensions
/// The build being used to configure Postgres.
/// The same builder so that further configuration can be chained.
public static NpgsqlDbContextOptionsBuilder UseWindowFunctions(
- this NpgsqlDbContextOptionsBuilder builder)
- {
- return builder.AddOrUpdateExtension();
- }
+ this NpgsqlDbContextOptionsBuilder builder) => builder.AddOrUpdateExtension();
private static NpgsqlDbContextOptionsBuilder AddOrUpdateExtension(
this NpgsqlDbContextOptionsBuilder builder)
@@ -25,11 +22,11 @@ private static NpgsqlDbContextOptionsBuilder AddOrUpdateExtension(
var extension = coreOptionsBuilder.Options.FindExtension() ?? new NpgsqlDbContextOptionsExtension();
((IDbContextOptionsBuilderInfrastructure)coreOptionsBuilder).AddOrUpdateExtension(extension);
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
return builder;
}
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs
index 1ed31c6..b6bf998 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Infrastructure/Internal/NpgsqlDbContextOptionsExtension.cs
@@ -18,14 +18,9 @@ public void Validate(IDbContextOptions options)
{
}
- private sealed class ExtensionInfo : WindowFunctions.Infrastructure.Internal.ExtensionInfo
+ private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : WindowFunctions.Infrastructure.Internal.ExtensionInfo(extension)
{
- public ExtensionInfo(IDbContextOptionsExtension extension)
- : base(extension)
- {
- }
-
- private new NpgsqlDbContextOptionsExtension Extension
+ public override IDbContextOptionsExtension Extension
=> (NpgsqlDbContextOptionsExtension)base.Extension;
}
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlEvaluatableExpressionFilter.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlEvaluatableExpressionFilter.cs
index 609a8e6..1698de0 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlEvaluatableExpressionFilter.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlEvaluatableExpressionFilter.cs
@@ -3,26 +3,15 @@
///
/// Evaluatable expression filter for Npgsql.
///
-public class WindowFunctionsNpgsqlEvaluatableExpressionFilter : NpgsqlEvaluatableExpressionFilter
+///
+/// Initializes a new instance of the class.
+///
+/// Service dependencies.
+/// Relational service dependencies.
+public class WindowFunctionsNpgsqlEvaluatableExpressionFilter(EvaluatableExpressionFilterDependencies dependencies, RelationalEvaluatableExpressionFilterDependencies relationalDependencies) : NpgsqlEvaluatableExpressionFilter(dependencies, relationalDependencies)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Service dependencies.
- /// Relational service dependencies.
- public WindowFunctionsNpgsqlEvaluatableExpressionFilter(EvaluatableExpressionFilterDependencies dependencies, RelationalEvaluatableExpressionFilterDependencies relationalDependencies)
- : base(dependencies, relationalDependencies)
- {
- }
-
///
public override bool IsEvaluatableExpression(Expression expression, IModel model)
- {
- if (!WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression))
- {
- return false;
- }
-
- return base.IsEvaluatableExpression(expression, model);
- }
+ => WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression)
+ && base.IsEvaluatableExpression(expression, model);
}
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessor.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessor.cs
index eb73935..76e5b2c 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessor.cs
@@ -3,25 +3,22 @@
///
/// A class that processes the including window functions.
///
-public class WindowFunctionsNpgsqlParameterBasedSqlProcessor : NpgsqlParameterBasedSqlProcessor
+///
+/// Initializes a new instance of the class.
+///
+/// Service dependencies.
+/// A bool value indicating if relational nulls should be used.
+public class WindowFunctionsNpgsqlParameterBasedSqlProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
+ : NpgsqlParameterBasedSqlProcessor(dependencies, useRelationalNulls)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Service dependencies.
- /// A bool value indicating if relational nulls should be used.
- public WindowFunctionsNpgsqlParameterBasedSqlProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
- : base(dependencies, useRelationalNulls)
- {
- }
-
- ///
#if !EF_CORE_6
+ ///
protected override Expression ProcessSqlNullability(Expression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache)
=> new WindowFunctionsNpgsqlSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(selectExpression, parametersValues, out canCache);
////protected override Expression ProcessSqlNullability(Expression queryExpression, IReadOnlyDictionary parametersValues, out bool canCache)
//// => new WindowFunctionsNpgsqlSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(queryExpression, parametersValues, out canCache);
#else
+ ///
protected override SelectExpression ProcessSqlNullability(SelectExpression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache)
=> new WindowFunctionsNpgsqlSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(
selectExpression, parametersValues, out canCache);
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessorFactory.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessorFactory.cs
index 2720c97..21e938c 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlParameterBasedSqlProcessorFactory.cs
@@ -3,19 +3,14 @@
///
/// Factory for producing instances.
///
-public class WindowFunctionsNpgsqlParameterBasedSqlProcessorFactory : NpgsqlParameterBasedSqlProcessorFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Relational Parameter Based Sql ProcessorDependencies.
+public class WindowFunctionsNpgsqlParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcessorDependencies dependencies)
+ : NpgsqlParameterBasedSqlProcessorFactory(dependencies)
{
- private readonly RelationalParameterBasedSqlProcessorDependencies dependencies;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Relational Parameter Based Sql ProcessorDependencies.
- public WindowFunctionsNpgsqlParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcessorDependencies dependencies)
- : base(dependencies)
- {
- this.dependencies = dependencies;
- }
+ private readonly RelationalParameterBasedSqlProcessorDependencies dependencies = dependencies;
///
public override RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls)
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGenerator.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGenerator.cs
index f80dd3a..1ea12d5 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGenerator.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGenerator.cs
@@ -3,6 +3,7 @@
///
/// Query SQL generator for Npgsql which includes window functions operations.
///
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class WindowFunctionsNpgsqlQuerySqlGenerator : NpgsqlQuerySqlGenerator
{
#if !EF_CORE_7 && !EF_CORE_6
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGeneratorFactory.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGeneratorFactory.cs
index 8e911be..e3c10ab 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGeneratorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQuerySqlGeneratorFactory.cs
@@ -3,6 +3,7 @@
///
/// Factory for generating .
///
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class WindowFunctionsNpgsqlQuerySqlGeneratorFactory : NpgsqlQuerySqlGeneratorFactory
{
private readonly QuerySqlGeneratorDependencies dependencies;
@@ -39,11 +40,12 @@ public WindowFunctionsNpgsqlQuerySqlGeneratorFactory(QuerySqlGeneratorDependenci
}
#endif
- ///
#if !EF_CORE_7 && !EF_CORE_6
+ ///
public override QuerySqlGenerator Create()
=> new WindowFunctionsNpgsqlQuerySqlGenerator(dependencies, relationalTypeMappingSource, npgsqlOptions.ReverseNullOrderingEnabled, npgsqlOptions.PostgresVersion);
#else
+ ///
public override QuerySqlGenerator Create()
=> new WindowFunctionsNpgsqlQuerySqlGenerator(dependencies, npgsqlOptions.ReverseNullOrderingEnabled, npgsqlOptions.PostgresVersion);
#endif
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitor.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitor.cs
index 07e7afb..75367db 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitor.cs
@@ -9,9 +9,6 @@
public class WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitor(QueryableMethodTranslatingExpressionVisitorDependencies dependencies, RelationalQueryableMethodTranslatingExpressionVisitorDependencies relationalDependencies, QueryCompilationContext queryCompilationContext) : NpgsqlQueryableMethodTranslatingExpressionVisitor(dependencies, relationalDependencies, queryCompilationContext)
{
///
- protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
- {
- return SubQueryProcessor.ProcessSubQuery(this, methodCallExpression)
+ protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) => SubQueryProcessor.ProcessSubQuery(this, methodCallExpression)
?? base.VisitMethodCall(methodCallExpression);
- }
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitorFactory.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitorFactory.cs
index 7706fc5..c819955 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitorFactory.cs
@@ -13,7 +13,5 @@ public class WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitorFac
///
public override QueryableMethodTranslatingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
- {
- return new WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitor(dependencies, relationalDependencies, queryCompilationContext);
- }
+ => new WindowFunctionsNpgsqlQueryableMethodTranslatingExpressionVisitor(dependencies, relationalDependencies, queryCompilationContext);
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlSqlNullabilityProcessor.cs b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlSqlNullabilityProcessor.cs
index 680bddc..00fb5dc 100644
--- a/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlSqlNullabilityProcessor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Npgsql/Query/Internal/WindowFunctionsNpgsqlSqlNullabilityProcessor.cs
@@ -3,18 +3,14 @@
///
/// A class that processes a SQL tree based on nullability of nodes to apply null semantics in use and optimize it based on parameter values.
///
-public class WindowFunctionsNpgsqlSqlNullabilityProcessor : NpgsqlSqlNullabilityProcessor
+///
+/// Initializes a new instance of the class.
+///
+/// Relational Parameter Based Sql Processor Dependencies.
+/// A bool value indicating if relational nulls should be used.
+public class WindowFunctionsNpgsqlSqlNullabilityProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
+ : NpgsqlSqlNullabilityProcessor(dependencies, useRelationalNulls)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Relational Parameter Based Sql Processor Dependencies.
- /// A bool value indicating if relational nulls should be used.
- public WindowFunctionsNpgsqlSqlNullabilityProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
- : base(dependencies, useRelationalNulls)
- {
- }
-
///
protected override SqlExpression VisitCustomSqlExpression(SqlExpression sqlExpression, bool allowOptimizedExpansion, out bool nullable)
{
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs
index 5698b60..f0fae09 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs
@@ -13,7 +13,7 @@ public static class SqlServerDbContextOptionsBuilderExtensions
public static SqlServerDbContextOptionsBuilder UseWindowFunctions(
this SqlServerDbContextOptionsBuilder builder)
{
- builder.AddOrUpdateExtension();
+ _ = builder.AddOrUpdateExtension();
return builder;
}
@@ -26,11 +26,11 @@ private static SqlServerDbContextOptionsBuilder AddOrUpdateExtension(
var extension = coreOptionsBuilder.Options.FindExtension() ?? new SqlServerDbContextOptionsExtension();
((IDbContextOptionsBuilderInfrastructure)coreOptionsBuilder).AddOrUpdateExtension(extension);
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
- coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
+ _ = coreOptionsBuilder.ReplaceService();
return builder;
}
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs
index d3089e9..18f44a0 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Extensions/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs
@@ -10,12 +10,5 @@ public class WindowFunctionsSqlServerEvaluatableExpressionFilter(EvaluatableExpr
{
///
public override bool IsEvaluatableExpression(Expression expression, IModel model)
- {
- if (!WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression))
- {
- return false;
- }
-
- return base.IsEvaluatableExpression(expression, model);
- }
+ => WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression) && base.IsEvaluatableExpression(expression, model);
}
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs
index 24e9680..6447289 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Infrastructure/Internal/SqlServerDbContextOptionsExtension.cs
@@ -18,14 +18,10 @@ public void Validate(IDbContextOptions options)
{
}
- private sealed class ExtensionInfo : WindowFunctions.Infrastructure.Internal.ExtensionInfo
+ private sealed class ExtensionInfo(IDbContextOptionsExtension extension)
+ : WindowFunctions.Infrastructure.Internal.ExtensionInfo(extension)
{
- public ExtensionInfo(IDbContextOptionsExtension extension)
- : base(extension)
- {
- }
-
- private new SqlServerDbContextOptionsExtension Extension
+ public override IDbContextOptionsExtension Extension
=> (SqlServerDbContextOptionsExtension)base.Extension;
}
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs
index 1f4458b..cfbe71a 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerEvaluatableExpressionFilter.cs
@@ -10,12 +10,6 @@ public class WindowFunctionsSqlServerEvaluatableExpressionFilter(EvaluatableExpr
{
///
public override bool IsEvaluatableExpression(Expression expression, IModel model)
- {
- if (!WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression))
- {
- return false;
- }
-
- return base.IsEvaluatableExpression(expression, model);
- }
+ => WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression)
+ && base.IsEvaluatableExpression(expression, model);
}
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessor.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessor.cs
index 87928dc..56d76fa 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessor.cs
@@ -3,6 +3,7 @@
///
/// A class that processes the including window functions.
///
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class WindowFunctionsSqlServerParameterBasedSqlProcessor : SqlServerParameterBasedSqlProcessor
{
///
@@ -15,12 +16,13 @@ public WindowFunctionsSqlServerParameterBasedSqlProcessor(RelationalParameterBas
{
}
- ///
#if !EF_CORE_6
+ ///
protected override Expression ProcessSqlNullability(Expression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache)
=> new WindowFunctionsSqlServerSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(
selectExpression, parametersValues, out canCache);
#else
+ ///
protected override SelectExpression ProcessSqlNullability(SelectExpression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache)
=> new WindowFunctionsSqlServerSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(
selectExpression, parametersValues, out canCache);
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessorFactory.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessorFactory.cs
index d161821..4acf526 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerParameterBasedSqlProcessorFactory.cs
@@ -3,17 +3,13 @@
///
/// Factory for generating instances.
///
-public class WindowFunctionsSqlServerParameterBasedSqlProcessorFactory : SqlServerParameterBasedSqlProcessorFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Service dependencies.
+public class WindowFunctionsSqlServerParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcessorDependencies dependencies)
+ : SqlServerParameterBasedSqlProcessorFactory(dependencies)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Service dependencies.
- public WindowFunctionsSqlServerParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcessorDependencies dependencies)
- : base(dependencies)
- {
- }
-
///
public override RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls)
=> new WindowFunctionsSqlServerParameterBasedSqlProcessor(Dependencies, useRelationalNulls);
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGenerator.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGenerator.cs
index 4e7e7ae..03a42ae 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGenerator.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGenerator.cs
@@ -3,6 +3,7 @@
///
/// A query SQL generator for window functions to get for given .
///
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class WindowFunctionsSqlServerQuerySqlGenerator : SqlServerQuerySqlGenerator
{
#if !EF_CORE_7 && !EF_CORE_6
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGeneratorFactory.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGeneratorFactory.cs
index eb6aae9..e4d40cd 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGeneratorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQuerySqlGeneratorFactory.cs
@@ -3,6 +3,7 @@
///
/// Factory for generating instances.
///
+[SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class WindowFunctionsSqlServerQuerySqlGeneratorFactory : SqlServerQuerySqlGeneratorFactory
{
#if !EF_CORE_7 && !EF_CORE_6
@@ -47,14 +48,16 @@ public WindowFunctionsSqlServerQuerySqlGeneratorFactory(QuerySqlGeneratorDepende
}
#endif
- ///
#if !EF_CORE_7 && !EF_CORE_6
+ ///
public override QuerySqlGenerator Create()
=> new WindowFunctionsSqlServerQuerySqlGenerator(Dependencies, typeMappingSource, sqlServerSingletonOptions);
#elif !EF_CORE_6
+ ///
public override QuerySqlGenerator Create()
=> new WindowFunctionsSqlServerQuerySqlGenerator(Dependencies, typeMappingSource);
#else
+ ///
public override QuerySqlGenerator Create()
=> new WindowFunctionsSqlServerQuerySqlGenerator(Dependencies);
#endif
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor.cs
index dfac20d..a2d9c29 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor.cs
@@ -11,9 +11,6 @@ public class WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor
: SqlServerQueryableMethodTranslatingExpressionVisitor(dependencies, relationalDependencies, queryCompilationContext, sqlServerSingletonOptions)
{
///
- protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
- {
- return SubQueryProcessor.ProcessSubQuery(this, methodCallExpression)
+ protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) => SubQueryProcessor.ProcessSubQuery(this, methodCallExpression)
?? base.VisitMethodCall(methodCallExpression);
- }
}
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs
index a49eb74..b95c762 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs
@@ -15,8 +15,6 @@ public class WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor
///
public override QueryableMethodTranslatingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
- {
- return new WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor(
+ => new WindowFunctionsSqlServerQueryableMethodTranslatingExpressionVisitor(
dependencies, relationalDependencies, (SqlServerQueryCompilationContext)queryCompilationContext, sqlServerSingletonOptions);
- }
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerSqlNullabilityProcessor.cs b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerSqlNullabilityProcessor.cs
index 79e00f0..cb14c6d 100644
--- a/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerSqlNullabilityProcessor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.SqlServer/Query/Internal/WindowFunctionsSqlServerSqlNullabilityProcessor.cs
@@ -3,18 +3,14 @@
///
/// A class that processes a SQL tree based on nullability of nodes to apply null semantics in use and optimize it based on parameter values.
///
-public class WindowFunctionsSqlServerSqlNullabilityProcessor : SqlServerSqlNullabilityProcessor
+///
+/// Initializes a new instance of the class.
+///
+/// Relational Parameter Based Sql Processor Dependencies.
+/// A bool value indicating if relational nulls should be used.
+public class WindowFunctionsSqlServerSqlNullabilityProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
+ : SqlServerSqlNullabilityProcessor(dependencies, useRelationalNulls)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Relational Parameter Based Sql Processor Dependencies.
- /// A bool value indicating if relational nulls should be used.
- public WindowFunctionsSqlServerSqlNullabilityProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
- : base(dependencies, useRelationalNulls)
- {
- }
-
///
protected override SqlExpression VisitCustomSqlExpression(SqlExpression sqlExpression, bool allowOptimizedExpansion, out bool nullable)
{
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
index 5d6d3cf..46bc94b 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Extensions/SqliteDbContextOptionsBuilderExtensions.cs
@@ -11,10 +11,7 @@ public static class SqliteDbContextOptionsBuilderExtensions
/// The build being used to configure Postgres.
/// The same builder so that further configuration can be chained.
public static SqliteDbContextOptionsBuilder UseWindowFunctions(
- this SqliteDbContextOptionsBuilder builder)
- {
- return builder.AddOrUpdateExtension();
- }
+ this SqliteDbContextOptionsBuilder builder) => builder.AddOrUpdateExtension();
private static SqliteDbContextOptionsBuilder AddOrUpdateExtension(
this SqliteDbContextOptionsBuilder sqliteOptionsBuilder)
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsEvaluatableExpressionFilter.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsEvaluatableExpressionFilter.cs
index 89e3de0..5e528f9 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsEvaluatableExpressionFilter.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsEvaluatableExpressionFilter.cs
@@ -3,26 +3,16 @@
///
/// Query SQL generator for Sqlite which includes window functions operations.
///
-public class SqliteWindowFunctionsEvaluatableExpressionFilter : RelationalEvaluatableExpressionFilter
+///
+/// Initializes a new instance of the class.
+///
+/// Service dependencies.
+/// Relational dependencies.
+public class SqliteWindowFunctionsEvaluatableExpressionFilter(EvaluatableExpressionFilterDependencies dependencies, RelationalEvaluatableExpressionFilterDependencies relationalDependencies)
+ : RelationalEvaluatableExpressionFilter(dependencies, relationalDependencies)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Service dependencies.
- /// Relational dependencies.
- public SqliteWindowFunctionsEvaluatableExpressionFilter(EvaluatableExpressionFilterDependencies dependencies, RelationalEvaluatableExpressionFilterDependencies relationalDependencies)
- : base(dependencies, relationalDependencies)
- {
- }
-
///
public override bool IsEvaluatableExpression(Expression expression, IModel model)
- {
- if (!WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression))
- {
- return false;
- }
-
- return base.IsEvaluatableExpression(expression, model);
- }
+ => WindowFunctionsEvaluatableExpressionFilter.IsEvaluatableExpression(expression)
+ && base.IsEvaluatableExpression(expression, model);
}
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslator.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslator.cs
index 9cb436a..85c6be5 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslator.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslator.cs
@@ -3,18 +3,13 @@
///
/// A SQL translator for window functions in SQLite.
///
-public class SqliteWindowFunctionsTranslator : WindowFunctionsTranslator
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+public class SqliteWindowFunctionsTranslator(ISqlExpressionFactory sqlExpressionFactory)
+ : WindowFunctionsTranslator(sqlExpressionFactory)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public SqliteWindowFunctionsTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- }
-
///
protected override SqlExpression Parse(IReadOnlyList arguments, string functionName)
{
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslatorPluginFactory.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslatorPluginFactory.cs
index 4742cca..730b997 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslatorPluginFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/SqliteWindowFunctionsTranslatorPluginFactory.cs
@@ -3,24 +3,16 @@
///
/// Window functions translator plugin factory for SQLite provider.
///
-public class SqliteWindowFunctionsTranslatorPluginFactory : WindowFunctionsTranslatorPluginFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+public class SqliteWindowFunctionsTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory)
+ : WindowFunctionsTranslatorPluginFactory(sqlExpressionFactory)
{
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public SqliteWindowFunctionsTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- : base(sqlExpressionFactory, relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
///
public override WindowFunctionsTranslator Create()
- => new SqliteWindowFunctionsTranslator(sqlExpressionFactory, relationalTypeMappingSource);
+ => new SqliteWindowFunctionsTranslator(sqlExpressionFactory);
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessor.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessor.cs
index ce536db..319797c 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessor.cs
@@ -4,18 +4,14 @@ namespace Zomp.EFCore.WindowFunctions.Sqlite.Query.Internal;
///
/// A class that processes the including window functions.
///
-public class WindowFunctionsSqliteParameterBasedSqlProcessor : SqliteParameterBasedSqlProcessor
+///
+/// Initializes a new instance of the class.
+///
+/// Service dependencies.
+/// A bool value indicating if relational nulls should be used.
+public class WindowFunctionsSqliteParameterBasedSqlProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
+ : SqliteParameterBasedSqlProcessor(dependencies, useRelationalNulls)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Service dependencies.
- /// A bool value indicating if relational nulls should be used.
- public WindowFunctionsSqliteParameterBasedSqlProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
- : base(dependencies, useRelationalNulls)
- {
- }
-
///
protected override Expression ProcessSqlNullability(Expression queryExpression, IReadOnlyDictionary parametersValues, out bool canCache)
=> new WindowFunctionsSqliteSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(queryExpression, parametersValues, out canCache);
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessorFactory.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessorFactory.cs
index b597216..da6aa9b 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteParameterBasedSqlProcessorFactory.cs
@@ -4,19 +4,14 @@ namespace Zomp.EFCore.WindowFunctions.Sqlite.Query.Internal;
///
/// Factory for producing instances.
///
-public class WindowFunctionsSqliteParameterBasedSqlProcessorFactory : SqliteParameterBasedSqlProcessorFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Relational Parameter Based Sql ProcessorDependencies.
+public class WindowFunctionsSqliteParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcessorDependencies dependencies)
+ : SqliteParameterBasedSqlProcessorFactory(dependencies)
{
- private readonly RelationalParameterBasedSqlProcessorDependencies dependencies;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Relational Parameter Based Sql ProcessorDependencies.
- public WindowFunctionsSqliteParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcessorDependencies dependencies)
- : base(dependencies)
- {
- this.dependencies = dependencies;
- }
+ private readonly RelationalParameterBasedSqlProcessorDependencies dependencies = dependencies;
///
public override RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls)
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitor.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitor.cs
index d8c64e3..1346d6c 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitor.cs
@@ -9,9 +9,6 @@
public class WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitor(QueryableMethodTranslatingExpressionVisitorDependencies dependencies, RelationalQueryableMethodTranslatingExpressionVisitorDependencies relationalDependencies, QueryCompilationContext queryCompilationContext) : SqliteQueryableMethodTranslatingExpressionVisitor(dependencies, relationalDependencies, queryCompilationContext)
{
///
- protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression)
- {
- return SubQueryProcessor.ProcessSubQuery(this, methodCallExpression)
+ protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) => SubQueryProcessor.ProcessSubQuery(this, methodCallExpression)
?? base.VisitMethodCall(methodCallExpression);
- }
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitorFactory.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitorFactory.cs
index 67434f6..a4802c8 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitorFactory.cs
@@ -13,7 +13,5 @@ public class WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitorFac
///
public override QueryableMethodTranslatingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
- {
- return new WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitor(dependencies, relationalDependencies, queryCompilationContext);
- }
+ => new WindowFunctionsSqliteQueryableMethodTranslatingExpressionVisitor(dependencies, relationalDependencies, queryCompilationContext);
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteSqlNullabilityProcessor.cs b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteSqlNullabilityProcessor.cs
index e69e814..0549508 100644
--- a/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteSqlNullabilityProcessor.cs
+++ b/src/Zomp.EFCore.WindowFunctions.Sqlite/Query/Internal/WindowFunctionsSqliteSqlNullabilityProcessor.cs
@@ -4,18 +4,14 @@ namespace Zomp.EFCore.WindowFunctions.Sqlite.Query.Internal;
///
/// A class that processes a SQL tree based on nullability of nodes to apply null semantics in use and optimize it based on parameter values.
///
-public class WindowFunctionsSqliteSqlNullabilityProcessor : SqliteSqlNullabilityProcessor
+///
+/// Initializes a new instance of the class.
+///
+/// Relational Parameter Based Sql Processor Dependencies.
+/// A bool value indicating if relational nulls should be used.
+public class WindowFunctionsSqliteSqlNullabilityProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
+ : SqliteSqlNullabilityProcessor(dependencies, useRelationalNulls)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Relational Parameter Based Sql Processor Dependencies.
- /// A bool value indicating if relational nulls should be used.
- public WindowFunctionsSqliteSqlNullabilityProcessor(RelationalParameterBasedSqlProcessorDependencies dependencies, bool useRelationalNulls)
- : base(dependencies, useRelationalNulls)
- {
- }
-
///
protected override SqlExpression VisitCustomSqlExpression(SqlExpression sqlExpression, bool allowOptimizedExpansion, out bool nullable)
{
diff --git a/src/Zomp.EFCore.WindowFunctions/Extensions/WindowsServiceCollectionExtensions.cs b/src/Zomp.EFCore.WindowFunctions/Extensions/WindowsServiceCollectionExtensions.cs
index 4846015..5f81cb9 100644
--- a/src/Zomp.EFCore.WindowFunctions/Extensions/WindowsServiceCollectionExtensions.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Extensions/WindowsServiceCollectionExtensions.cs
@@ -13,7 +13,7 @@ public static class WindowsServiceCollectionExtensions
public static IServiceCollection AddWindowedFunctionsExtension(
this IServiceCollection serviceCollection)
{
- new EntityFrameworkRelationalServicesBuilder(serviceCollection)
+ _ = new EntityFrameworkRelationalServicesBuilder(serviceCollection)
.TryAdd()
.TryAddProviderSpecificServices(b => b
.TryAddScoped());
diff --git a/src/Zomp.EFCore.WindowFunctions/Infrastructure/Internal/ExtensionInfo.cs b/src/Zomp.EFCore.WindowFunctions/Infrastructure/Internal/ExtensionInfo.cs
index b9b52df..67e5092 100644
--- a/src/Zomp.EFCore.WindowFunctions/Infrastructure/Internal/ExtensionInfo.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Infrastructure/Internal/ExtensionInfo.cs
@@ -3,17 +3,12 @@
///
/// Information/metadata for the extension.
///
-public class ExtensionInfo : DbContextOptionsExtensionInfo
+///
+/// Initializes a new instance of the class.
+///
+/// The extension.
+public class ExtensionInfo(IDbContextOptionsExtension extension) : DbContextOptionsExtensionInfo(extension)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// The extension.
- public ExtensionInfo(IDbContextOptionsExtension extension)
- : base(extension)
- {
- }
-
///
public override bool IsDatabaseProvider
=> false;
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/CompareNameAndDeclaringType.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/CompareNameAndDeclaringType.cs
index 3317995..dbcb6ce 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/CompareNameAndDeclaringType.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/CompareNameAndDeclaringType.cs
@@ -4,18 +4,9 @@ internal sealed class CompareNameAndDeclaringType : IEqualityComparer x is null || y is null
+ ? x is null && y is null
+ : x.Name.Equals(y.Name, StringComparison.Ordinal) && x.DeclaringType == y.DeclaringType;
- return x.Name.Equals(y.Name, StringComparison.Ordinal) && x.DeclaringType == y.DeclaringType;
- }
-
- public int GetHashCode(MethodInfo method)
- {
- return HashCode.Combine(method.Name.GetHashCode(StringComparison.Ordinal), method.DeclaringType?.GetHashCode());
- }
+ public int GetHashCode(MethodInfo method) => HashCode.Combine(method.Name.GetHashCode(StringComparison.Ordinal), method.DeclaringType?.GetHashCode());
}
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/ExpressionVisitorExtensions.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/ExpressionVisitorExtensions.cs
index 20c7268..b759130 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/ExpressionVisitorExtensions.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/ExpressionVisitorExtensions.cs
@@ -25,44 +25,44 @@ public static Expression VisitWindowFunction(this ExpressionVisitor expressionVi
{
// Fixme: need a way to avoid reflection of private fields.
var fi = typeof(QuerySqlGenerator).GetField("_relationalCommandBuilder", BindingFlags.NonPublic | BindingFlags.Instance);
- IRelationalCommandBuilder relationalCommandBuilder = (IRelationalCommandBuilder)fi!.GetValue(expressionVisitor)!;
- relationalCommandBuilder.Append($"{windowFunctionExpression.Function}(");
+ var relationalCommandBuilder = (IRelationalCommandBuilder)fi!.GetValue(expressionVisitor)!;
+ _ = relationalCommandBuilder.Append($"{windowFunctionExpression.Function}(");
if (windowFunctionExpression.Arguments.Count == 0
&& windowFunctionExpression.Function.Equals(nameof(DbFunctionsExtensions.Count), StringComparison.OrdinalIgnoreCase))
{
- relationalCommandBuilder.Append($"*");
+ _ = relationalCommandBuilder.Append($"*");
}
else
{
GenerateList(relationalCommandBuilder, windowFunctionExpression.Arguments, e => expressionVisitor.Visit(e));
}
- relationalCommandBuilder.Append(") ");
+ _ = relationalCommandBuilder.Append(") ");
if (windowFunctionExpression.NullHandling is { } nullHandling)
{
- relationalCommandBuilder.Append(nullHandling == NullHandling.RespectNulls
+ _ = relationalCommandBuilder.Append(nullHandling == NullHandling.RespectNulls
? "RESPECT NULLS " : "IGNORE NULLS ");
}
- relationalCommandBuilder.Append("OVER(");
+ _ = relationalCommandBuilder.Append("OVER(");
if (windowFunctionExpression.Partitions.Any())
{
- relationalCommandBuilder.Append("PARTITION BY ");
+ _ = relationalCommandBuilder.Append("PARTITION BY ");
GenerateList(relationalCommandBuilder, windowFunctionExpression.Partitions, e => expressionVisitor.Visit(e));
- relationalCommandBuilder.Append(" ");
+ _ = relationalCommandBuilder.Append(" ");
}
if (windowFunctionExpression.Orderings.Any())
{
- relationalCommandBuilder.Append("ORDER BY ");
+ _ = relationalCommandBuilder.Append("ORDER BY ");
GenerateList(relationalCommandBuilder, windowFunctionExpression.Orderings, e => expressionVisitor.Visit(e));
ProcessRowOrRange(windowFunctionExpression, relationalCommandBuilder);
}
- relationalCommandBuilder.Append(")");
+ _ = relationalCommandBuilder.Append(")");
return windowFunctionExpression;
}
@@ -74,15 +74,15 @@ private static void ProcessRowOrRange(WindowFunctionExpression windowFunctionExp
return;
}
- relationalCommandBuilder.Append(" ");
+ _ = relationalCommandBuilder.Append(" ");
- relationalCommandBuilder.Append(windowFunctionExpression.RowOrRange.IsRows ? "ROWS " : "RANGE ");
+ _ = relationalCommandBuilder.Append(windowFunctionExpression.RowOrRange.IsRows ? "ROWS " : "RANGE ");
- if (windowFunctionExpression.RowOrRange.End is { } following)
+ if (windowFunctionExpression.RowOrRange.End is { })
{
- relationalCommandBuilder.Append("BETWEEN ");
+ _ = relationalCommandBuilder.Append("BETWEEN ");
ProcessWindowFrame(relationalCommandBuilder, windowFunctionExpression.RowOrRange.Start, false);
- relationalCommandBuilder.Append(" AND ");
+ _ = relationalCommandBuilder.Append(" AND ");
ProcessWindowFrame(relationalCommandBuilder, windowFunctionExpression.RowOrRange.End, true);
return;
}
@@ -92,13 +92,13 @@ private static void ProcessRowOrRange(WindowFunctionExpression windowFunctionExp
private static void ProcessWindowFrame(IRelationalCommandBuilder relationalCommandBuilder, WindowFrame windowFrame, bool isStart)
{
- relationalCommandBuilder.Append(windowFrame.ToString()!);
+ _ = relationalCommandBuilder.Append(windowFrame.ToString()!);
if (windowFrame.IsDirectional)
{
- relationalCommandBuilder.Append(" ");
- bool isFollowing = windowFrame is BoundedWindowFrame bwf ? bwf.IsFollowing : isStart;
- relationalCommandBuilder.Append(isFollowing ? "FOLLOWING" : "PRECEDING");
+ _ = relationalCommandBuilder.Append(" ");
+ var isFollowing = windowFrame is BoundedWindowFrame bwf ? bwf.IsFollowing : isStart;
+ _ = relationalCommandBuilder.Append(isFollowing ? "FOLLOWING" : "PRECEDING");
}
}
@@ -127,8 +127,6 @@ internal sealed class ParameterReplacer(ParameterExpression source, Expression t
private readonly Expression target = target;
protected override Expression VisitParameter(ParameterExpression node)
- {
- return node == source ? target : base.VisitParameter(node);
- }
+ => node == source ? target : base.VisitParameter(node);
}
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/JoinDetector.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/JoinDetector.cs
index b5d5708..9b48666 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/JoinDetector.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/JoinDetector.cs
@@ -14,7 +14,7 @@ internal sealed class JoinDetector : ExpressionVisitor
types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });
*/
- public IList WindowFunctionsCollection { get; } = new List();
+ public IList WindowFunctionsCollection { get; } = [];
///
protected override Expression VisitMethodCall(MethodCallExpression node)
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionInsideWhereDetector.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionInsideWhereDetector.cs
index b1e0f8e..ddde0ef 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionInsideWhereDetector.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionInsideWhereDetector.cs
@@ -36,7 +36,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
if (suspendWhereStack is not null)
{
- clauseStack.Pop();
+ _ = clauseStack.Pop();
}
SubqueryType? subqueryType = node.Method.DeclaringType != typeof(Queryable) ? null
@@ -54,7 +54,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
var wfNode = WindowFunctionsEvaluatableExpressionFilter.WindowFunctionMethods.Contains(node.Method, CompareNameAndDeclaringType.Default)
? node : null;
- clauseStack.TryPeek(out var clause);
+ _ = clauseStack.TryPeek(out var clause);
if (wfNode is not null)
{
@@ -75,7 +75,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
if (wfNode is not null)
{
_ = clause ?? throw new InvalidOperationException("Window Function outside of select or where?");
- clause.WindowFunctionStack.Pop();
+ _ = clause.WindowFunctionStack.Pop();
}
var method = @base.Method;
@@ -169,7 +169,7 @@ private static LambdaExpression BuildSubqueries(
var parameter = lambda.Parameters[0];
var newParameter = parameter;
var lastLevel = isWhere ? 0 : 1;
- var subqueryList = windowFunctions[^1];
+ var subqueryList = windowFunctions[^1].ToList();
IDictionary replacementMap;
var level = windowFunctions.Count - 1;
WindowFunctionRewriter wfr;
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsRelationalQueryTranslationPreprocessorFactory.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsRelationalQueryTranslationPreprocessorFactory.cs
index 5303b76..907e6b9 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsRelationalQueryTranslationPreprocessorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsRelationalQueryTranslationPreprocessorFactory.cs
@@ -10,7 +10,5 @@ public class WindowFunctionsRelationalQueryTranslationPreprocessorFactory(QueryT
{
///
public override QueryTranslationPreprocessor Create(QueryCompilationContext queryCompilationContext)
- {
- return new WindowFunctionsRelationalQueryTranslationPreprocessor(Dependencies, RelationalDependencies, queryCompilationContext);
- }
+ => new WindowFunctionsRelationalQueryTranslationPreprocessor(Dependencies, RelationalDependencies, queryCompilationContext);
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslator.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslator.cs
index 5adb4cd..8d650e2 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslator.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslator.cs
@@ -3,21 +3,13 @@
///
/// A SQL translator for window functions.
///
-public class WindowFunctionsTranslator : IMethodCallTranslator
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+public class WindowFunctionsTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMethodCallTranslator
{
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public WindowFunctionsTranslator(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
///
public SqlExpression? Translate(SqlExpression? instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger)
@@ -95,12 +87,9 @@ protected virtual SqlExpression Parse(IReadOnlyList arguments, st
return new WindowFunctionExpression(functionName, directArgs, nullHandling, over?.PartitionByExpression?.List, over?.OrderingExpression?.List, over?.OrderingExpression?.RowOrRangeClause, RelationalTypeMapping.NullMapping);
}
- private static OverExpression GetOrderingSqlExpression(IReadOnlyList arguments)
- {
- return arguments is not { Count: > 0 } || arguments[0] is not OverExpression orderingSqlExpression
+ private static OverExpression GetOrderingSqlExpression(IReadOnlyList arguments) => arguments is not { Count: > 0 } || arguments[0] is not OverExpression orderingSqlExpression
? throw new InvalidOperationException($"Must be applied to {nameof(OverExpression)}")
: orderingSqlExpression;
- }
private static BoundedWindowFrame GetWindowFrame(SqlExpression sqlExpression, bool isFollowing)
=> (sqlExpression as SqlConstantExpression) switch
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslatorPluginFactory.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslatorPluginFactory.cs
index 1360276..2dce1b3 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslatorPluginFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowFunctionsTranslatorPluginFactory.cs
@@ -3,25 +3,15 @@
///
/// Factory for WindowFunctionsTranslatorPlugin.
///
-public class WindowFunctionsTranslatorPluginFactory : IWindowFunctionsTranslatorPluginFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Instance of sql expression factory.
+public class WindowFunctionsTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory)
+ : IWindowFunctionsTranslatorPluginFactory
{
- private readonly ISqlExpressionFactory sqlExpressionFactory;
- private readonly IRelationalTypeMappingSource relationalTypeMappingSource;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of sql expression factory.
- /// Instance relational type mapping source.
- public WindowFunctionsTranslatorPluginFactory(ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource relationalTypeMappingSource)
- {
- this.sqlExpressionFactory = sqlExpressionFactory;
- this.relationalTypeMappingSource = relationalTypeMappingSource;
- }
+ private readonly ISqlExpressionFactory sqlExpressionFactory = sqlExpressionFactory;
///
- public virtual WindowFunctionsTranslator Create()
- {
- return new WindowFunctionsTranslator(sqlExpressionFactory, relationalTypeMappingSource);
- }
+ public virtual WindowFunctionsTranslator Create() => new(sqlExpressionFactory);
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGenerator.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGenerator.cs
index 33f6247..62c4b48 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGenerator.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGenerator.cs
@@ -3,17 +3,12 @@
///
/// A query SQL generator to get for given .
///
-public class WindowQuerySqlGenerator : QuerySqlGenerator
+///
+/// Initializes a new instance of the class.
+///
+/// Query Sql Generator Dependencies.
+public class WindowQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies) : QuerySqlGenerator(dependencies)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Query Sql Generator Dependencies.
- public WindowQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies)
- : base(dependencies)
- {
- }
-
///
protected override Expression VisitExtension(Expression extensionExpression)
=> extensionExpression switch
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGeneratorFactory.cs b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGeneratorFactory.cs
index cf6e6af..f4f60be 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGeneratorFactory.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/Internal/WindowQuerySqlGeneratorFactory.cs
@@ -3,17 +3,13 @@
///
/// A factory for creating instances.
///
-public class WindowQuerySqlGeneratorFactory : QuerySqlGeneratorFactory
+///
+/// Initializes a new instance of the class.
+///
+/// Query Sql Generator Dependencies.
+public class WindowQuerySqlGeneratorFactory(QuerySqlGeneratorDependencies dependencies)
+ : QuerySqlGeneratorFactory(dependencies)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// Query Sql Generator Dependencies.
- public WindowQuerySqlGeneratorFactory(QuerySqlGeneratorDependencies dependencies)
- : base(dependencies)
- {
- }
-
///
public override QuerySqlGenerator Create()
=> new WindowQuerySqlGenerator(Dependencies);
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/ChainedSqlExpression.cs b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/ChainedSqlExpression.cs
index 7ca4014..2229bd6 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/ChainedSqlExpression.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/ChainedSqlExpression.cs
@@ -1,20 +1,11 @@
namespace Zomp.EFCore.WindowFunctions.Query.SqlExpressions;
-internal abstract class ChainedSqlExpression : SqlExpression
+internal abstract class ChainedSqlExpression(T first) : SqlExpression(typeof(ChainedSqlExpression), null)
where T : Expression
{
- public ChainedSqlExpression(T first)
- : base(typeof(ChainedSqlExpression), null)
- {
- List = new List(new T[] { first });
- }
-
- public IReadOnlyList List { get; }
+ public IReadOnlyList List { get; } = new List([first]);
public void Add(T item) => ((List)List).Add(item);
- protected override void Print(ExpressionPrinter expressionPrinter)
- {
- expressionPrinter.VisitCollection(List);
- }
+ protected override void Print(ExpressionPrinter expressionPrinter) => expressionPrinter.VisitCollection(List);
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OrderingSqlExpression.cs b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OrderingSqlExpression.cs
index 4ebfba5..d625f64 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OrderingSqlExpression.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OrderingSqlExpression.cs
@@ -1,11 +1,6 @@
namespace Zomp.EFCore.WindowFunctions.Query.SqlExpressions;
-internal sealed class OrderingSqlExpression : ChainedSqlExpression
+internal sealed class OrderingSqlExpression(OrderingExpression ordering) : ChainedSqlExpression(ordering)
{
- public OrderingSqlExpression(OrderingExpression ordering)
- : base(ordering)
- {
- }
-
public RowOrRangeExpression? RowOrRangeClause { get; set; }
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OverExpression.cs b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OverExpression.cs
index d49d7af..be7a050 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OverExpression.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/OverExpression.cs
@@ -3,33 +3,23 @@
///
/// Contains OrderBy and PartitionBy clauses.
///
-internal sealed class OverExpression : SqlExpression
+internal sealed class OverExpression(OrderingSqlExpression? orderingExpression, PartitionByExpression? partitionByExpression, bool isLatestPartitionBy)
+ : SqlExpression(typeof(OverExpression), null)
{
- public OverExpression(OrderingSqlExpression? orderingExpression, PartitionByExpression? partitionByExpression, bool isLatestPartitionBy)
- : base(typeof(OverExpression), null)
- {
- OrderingExpression = orderingExpression;
- PartitionByExpression = partitionByExpression;
- IsLatestPartitionBy = isLatestPartitionBy;
- }
-
///
/// Gets the partition by clause.
///
- public PartitionByExpression? PartitionByExpression { get; }
+ public PartitionByExpression? PartitionByExpression { get; } = partitionByExpression;
///
/// Gets a value indicating whether the last element in the chain was Partition clause.
///
- public bool IsLatestPartitionBy { get; }
+ public bool IsLatestPartitionBy { get; } = isLatestPartitionBy;
///
/// Gets the order by clause.
///
- public OrderingSqlExpression? OrderingExpression { get; }
+ public OrderingSqlExpression? OrderingExpression { get; } = orderingExpression;
- protected override void Print(ExpressionPrinter expressionPrinter)
- {
- throw new NotImplementedException();
- }
+ protected override void Print(ExpressionPrinter expressionPrinter) => throw new NotImplementedException();
}
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/PartitionByExpression.cs b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/PartitionByExpression.cs
index 2c9dec2..4248c2b 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/PartitionByExpression.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/PartitionByExpression.cs
@@ -1,9 +1,5 @@
namespace Zomp.EFCore.WindowFunctions.Query.SqlExpressions;
-internal sealed class PartitionByExpression : ChainedSqlExpression
+internal sealed class PartitionByExpression(SqlExpression partition) : ChainedSqlExpression(partition)
{
- public PartitionByExpression(SqlExpression partition)
- : base(partition)
- {
- }
}
\ No newline at end of file
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/RowOrRangeExpression.cs b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/RowOrRangeExpression.cs
index e980fd0..09f10d4 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/RowOrRangeExpression.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/RowOrRangeExpression.cs
@@ -3,37 +3,29 @@
///
/// An expression that represents rows or range clause of the over clause.
///
-public class RowOrRangeExpression : SqlExpression
+///
+/// Initializes a new instance of the class.
+///
+/// "ROWS" or "RANGE" keyword.
+/// starting window frame.
+/// ending window frame.
+public class RowOrRangeExpression(bool isRows, WindowFrame start, WindowFrame? end = null)
+ : SqlExpression(typeof(RowOrRangeExpression), null)
{
- ///
- /// Initializes a new instance of the class.
- ///
- /// "ROWS" or "RANGE" keyword.
- /// starting window frame.
- /// ending window frame.
- public RowOrRangeExpression(bool isRows, WindowFrame start, WindowFrame? end = null)
-
- : base(typeof(RowOrRangeExpression), null)
- {
- IsRows = isRows;
- Start = start;
- End = end;
- }
-
///
/// Gets a value indicating whether "ROWS" or "RANGE" is specified.
///
- public bool IsRows { get; }
+ public bool IsRows { get; } = isRows;
///
/// Gets the starting window frame.
///
- public WindowFrame Start { get; }
+ public WindowFrame Start { get; } = start;
///
/// Gets the ending window frame.
///
- public WindowFrame? End { get; }
+ public WindowFrame? End { get; } = end;
///
public override bool Equals(object? obj)
@@ -57,15 +49,15 @@ public override int GetHashCode()
protected override void Print(ExpressionPrinter expressionPrinter)
{
ArgumentNullException.ThrowIfNull(expressionPrinter);
- expressionPrinter.Append(" ");
+ _ = expressionPrinter.Append(" ");
- expressionPrinter.Append(IsRows ? "ROWS " : "RANGE ");
+ _ = expressionPrinter.Append(IsRows ? "ROWS " : "RANGE ");
- if (End is { } following)
+ if (End is { })
{
- expressionPrinter.Append("BETWEEN ");
+ _ = expressionPrinter.Append("BETWEEN ");
ProcessWindowFrame(expressionPrinter, Start, false);
- expressionPrinter.Append(" AND ");
+ _ = expressionPrinter.Append(" AND ");
ProcessWindowFrame(expressionPrinter, End, true);
return;
}
@@ -75,13 +67,13 @@ protected override void Print(ExpressionPrinter expressionPrinter)
private static void ProcessWindowFrame(ExpressionPrinter expressionPrinter, WindowFrame windowFrame, bool isStart)
{
- expressionPrinter.Append(windowFrame.ToString()!);
+ _ = expressionPrinter.Append(windowFrame.ToString()!);
if (windowFrame.IsDirectional)
{
- expressionPrinter.Append(" ");
- bool isFollowing = windowFrame is BoundedWindowFrame bwf ? bwf.IsFollowing : isStart;
- expressionPrinter.Append(isFollowing ? "FOLLOWING" : "PRECEDING");
+ _ = expressionPrinter.Append(" ");
+ var isFollowing = windowFrame is BoundedWindowFrame bwf ? bwf.IsFollowing : isStart;
+ _ = expressionPrinter.Append(isFollowing ? "FOLLOWING" : "PRECEDING");
}
}
diff --git a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/WindowFunctionExpression.cs b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/WindowFunctionExpression.cs
index 10b98ad..0dfa3a2 100644
--- a/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/WindowFunctionExpression.cs
+++ b/src/Zomp.EFCore.WindowFunctions/Query/SqlExpressions/WindowFunctionExpression.cs
@@ -42,12 +42,12 @@ public class WindowFunctionExpression(
///
/// Gets the list of expressions used in partitioning.
///
- public virtual IReadOnlyList Partitions { get; } = partitions ?? Array.Empty();
+ public virtual IReadOnlyList Partitions { get; } = partitions ?? [];
///
/// Gets list of ordering expressions used to order inside the given partition.
///
- public virtual IReadOnlyList Orderings { get; } = orderings ?? Array.Empty();
+ public virtual IReadOnlyList Orderings { get; } = orderings ?? [];
///
/// Gets the function name.
@@ -143,43 +143,43 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
protected override void Print(ExpressionPrinter expressionPrinter)
{
ArgumentNullException.ThrowIfNull(expressionPrinter);
- expressionPrinter.Append($"{Function}(");
+ _ = expressionPrinter.Append($"{Function}(");
if (Arguments.Count == 0
&& Function.Equals(nameof(DbFunctionsExtensions.Count), StringComparison.OrdinalIgnoreCase))
{
- expressionPrinter.Append($"*");
+ _ = expressionPrinter.Append($"*");
}
else
{
expressionPrinter.VisitCollection(Arguments);
}
- expressionPrinter.Append(") ");
+ _ = expressionPrinter.Append(") ");
if (NullHandling is { } nullHandling)
{
- expressionPrinter.Append(nullHandling == WindowFunctions.NullHandling.RespectNulls
+ _ = expressionPrinter.Append(nullHandling == WindowFunctions.NullHandling.RespectNulls
? "RESPECT NULLS " : "IGNORE NULLS ");
}
- expressionPrinter.Append("OVER(");
+ _ = expressionPrinter.Append("OVER(");
if (Partitions.Any())
{
- expressionPrinter.Append("PARTITION BY ");
+ _ = expressionPrinter.Append("PARTITION BY ");
expressionPrinter.VisitCollection(Partitions);
- expressionPrinter.Append(" ");
+ _ = expressionPrinter.Append(" ");
}
if (Orderings.Any())
{
- expressionPrinter.Append("ORDER BY ");
+ _ = expressionPrinter.Append("ORDER BY ");
expressionPrinter.VisitCollection(Orderings);
- expressionPrinter.Visit(RowOrRange);
+ _ = expressionPrinter.Visit(RowOrRange);
}
- expressionPrinter.Append(")");
+ _ = expressionPrinter.Append(")");
}
private bool Equals(WindowFunctionExpression windowFunctionsExpression)
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
index b003bd1..145c270 100644
--- a/tests/Directory.Build.props
+++ b/tests/Directory.Build.props
@@ -12,6 +12,9 @@
$(NoWarn);CA1711;CA1707
+
+ $(NoWarn);CA1515
+
$(NoWarn);CA2007
diff --git a/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlFixture.cs b/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlFixture.cs
index a10b038..3d842fa 100644
--- a/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlFixture.cs
+++ b/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.BinaryFunctions.Npgsql.Tests;
-public class NpgsqlFixture : TestFixture
+public sealed class NpgsqlFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs b/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs
index 60d1389..559d081 100644
--- a/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs
+++ b/tests/Zomp.EFCore.BinaryFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs
@@ -8,7 +8,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseNpgsql(
+ _ = optionsBuilder.UseNpgsql(
ConnectionString,
o => o.UseBinaryFunctions());
}
diff --git a/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerFixture.cs b/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerFixture.cs
index 8d491c6..8419fd3 100644
--- a/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerFixture.cs
+++ b/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.BinaryFunctions.SqlServer.Tests;
-public class SqlServerFixture : TestFixture
+public sealed class SqlServerFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerTestDbContext.cs b/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerTestDbContext.cs
index 7b1aa39..8ae06b8 100644
--- a/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerTestDbContext.cs
+++ b/tests/Zomp.EFCore.BinaryFunctions.SqlServer.Tests/SqlServerTestDbContext.cs
@@ -8,7 +8,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseSqlServer(
+ _ = optionsBuilder.UseSqlServer(
ConnectionString,
sqlOptions => sqlOptions.UseBinaryFunctions());
}
diff --git a/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteFixture.cs b/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteFixture.cs
index df5ad2e..435daa8 100644
--- a/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteFixture.cs
+++ b/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.BinaryFunctions.Sqlite.Tests;
-public class SqliteFixture : TestFixture
+public sealed class SqliteFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteTestDbContext.cs b/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteTestDbContext.cs
index 256ce60..561d6b3 100644
--- a/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteTestDbContext.cs
+++ b/tests/Zomp.EFCore.BinaryFunctions.Sqlite.Tests/SqliteTestDbContext.cs
@@ -10,7 +10,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseSqlite(Connection, z => z.UseBinaryFunctions());
+ _ = optionsBuilder.UseSqlite(Connection, z => z.UseBinaryFunctions());
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
@@ -18,7 +18,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
base.OnModelCreating(modelBuilder);
// Convert https://github.com/dotnet/efcore/issues/15078#issuecomment-475784385
- modelBuilder.Entity().Property(r => r.SomeGuid)
+ _ = modelBuilder.Entity().Property(r => r.SomeGuid)
.HasConversion(
g => g.ToByteArray(),
b => new Guid(b));
diff --git a/tests/Zomp.EFCore.BinaryFunctions.Testing/BinaryTests.cs b/tests/Zomp.EFCore.BinaryFunctions.Testing/BinaryTests.cs
index bac6311..42d9425 100644
--- a/tests/Zomp.EFCore.BinaryFunctions.Testing/BinaryTests.cs
+++ b/tests/Zomp.EFCore.BinaryFunctions.Testing/BinaryTests.cs
@@ -158,7 +158,7 @@ protected virtual void Dispose(bool disposing)
private static byte[] ReverseEndianAndCombine(Guid x, int y)
{
var bytes = new byte[20];
- x.TryWriteBytes(bytes);
+ _ = x.TryWriteBytes(bytes);
BinaryPrimitives.WriteInt32BigEndian(bytes.AsSpan(16), y);
return bytes;
}
diff --git a/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGenerator.cs b/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGenerator.cs
index f04ccdc..21a2b93 100644
--- a/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGenerator.cs
+++ b/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGenerator.cs
@@ -12,6 +12,7 @@ namespace Zomp.EFCore.Combined.Npgsql.Tests;
/// Query SQL generator for Npgsql which includes binary operations and window functions.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "EF1001:Internal EF Core API usage.", Justification = "Temporary")]
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class CombinedNpgsqlQuerySqlGenerator : BinaryNpgsqlQuerySqlGenerator
{
#if !EF_CORE_7 && !EF_CORE_6
diff --git a/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGeneratorFactory.cs b/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGeneratorFactory.cs
index 1c56e1e..e1aec70 100644
--- a/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGeneratorFactory.cs
+++ b/tests/Zomp.EFCore.Combined.Npgsql.Tests/CombinedNpgsqlQuerySqlGeneratorFactory.cs
@@ -11,6 +11,7 @@ namespace Zomp.EFCore.Combined.Npgsql.Tests;
/// Factory for generating .
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "EF1001:Internal EF Core API usage.", Justification = "Temporary")]
+[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290:Use primary constructor", Justification = "Multiple versions")]
public class CombinedNpgsqlQuerySqlGeneratorFactory : BinaryNpgsqlQuerySqlGeneratorFactory
{
private readonly QuerySqlGeneratorDependencies dependencies;
diff --git a/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlFixture.cs b/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlFixture.cs
index 0f05c03..ab8d609 100644
--- a/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlFixture.cs
+++ b/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.Combined.Npgsql.Tests;
-public class NpgsqlFixture : TestFixture
+public sealed class NpgsqlFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlTestDbContext.cs b/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlTestDbContext.cs
index df2b8e8..dca189b 100644
--- a/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlTestDbContext.cs
+++ b/tests/Zomp.EFCore.Combined.Npgsql.Tests/NpgsqlTestDbContext.cs
@@ -10,12 +10,10 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseNpgsql(
+ _ = optionsBuilder.UseNpgsql(
ConnectionString,
o => o.UseWindowFunctions().UseBinaryFunctions())
-
- // Fixme: Find a way to remove this line.
- .ReplaceService();
+ .ReplaceService(); /*Fixme: Find a way to remove this line.*/
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
diff --git a/tests/Zomp.EFCore.Combined.Npgsql.Tests/TestBase.cs b/tests/Zomp.EFCore.Combined.Npgsql.Tests/TestBase.cs
index 5072525..cd95d03 100644
--- a/tests/Zomp.EFCore.Combined.Npgsql.Tests/TestBase.cs
+++ b/tests/Zomp.EFCore.Combined.Npgsql.Tests/TestBase.cs
@@ -1,15 +1,8 @@
namespace Zomp.EFCore.Combined.Npgsql.Tests;
-public class TestBase : IDisposable
+public class TestBase(ITestOutputHelper output) : IDisposable
{
- private readonly NpgsqlTestDbContext dbContext;
-
- public TestBase(ITestOutputHelper output)
- {
- dbContext = new NpgsqlTestDbContext(output.ToLoggerFactory());
- }
-
- protected NpgsqlTestDbContext DbContext => dbContext;
+ protected NpgsqlTestDbContext DbContext { get; } = new NpgsqlTestDbContext(output.ToLoggerFactory());
public void Dispose()
{
@@ -21,10 +14,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- if (dbContext != null)
- {
- dbContext.Dispose();
- }
+ DbContext?.Dispose();
}
}
}
diff --git a/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerFixture.cs b/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerFixture.cs
index 1f5b7a6..c854558 100644
--- a/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerFixture.cs
+++ b/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.Combined.SqlServer.Tests;
-public class SqlServerFixture : TestFixture
+public sealed class SqlServerFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerTestDbContext.cs b/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerTestDbContext.cs
index bb5640a..ef84e2c 100644
--- a/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerTestDbContext.cs
+++ b/tests/Zomp.EFCore.Combined.SqlServer.Tests/SqlServerTestDbContext.cs
@@ -8,7 +8,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseSqlServer(
+ _ = optionsBuilder.UseSqlServer(
ConnectionString,
sqlOptions => sqlOptions.UseWindowFunctions().UseBinaryFunctions());
}
diff --git a/tests/Zomp.EFCore.Combined.SqlServer.Tests/TestBase.cs b/tests/Zomp.EFCore.Combined.SqlServer.Tests/TestBase.cs
index 81b521d..e619ded 100644
--- a/tests/Zomp.EFCore.Combined.SqlServer.Tests/TestBase.cs
+++ b/tests/Zomp.EFCore.Combined.SqlServer.Tests/TestBase.cs
@@ -1,15 +1,8 @@
namespace Zomp.EFCore.Combined.SqlServer.Tests;
-public class TestBase : IDisposable
+public class TestBase(ITestOutputHelper output) : IDisposable
{
- private readonly SqlServerTestDbContext dbContext;
-
- public TestBase(ITestOutputHelper output)
- {
- dbContext = new SqlServerTestDbContext(output.ToLoggerFactory());
- }
-
- protected SqlServerTestDbContext DbContext => dbContext;
+ protected SqlServerTestDbContext DbContext { get; } = new SqlServerTestDbContext(output.ToLoggerFactory());
public void Dispose()
{
@@ -21,10 +14,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- if (dbContext != null)
- {
- dbContext.Dispose();
- }
+ DbContext?.Dispose();
}
}
}
diff --git a/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteFixture.cs b/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteFixture.cs
index c1c1ad0..afc48e7 100644
--- a/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteFixture.cs
+++ b/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.Combined.Sqlite.Tests;
-public class SqliteFixture : TestFixture
+public sealed class SqliteFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteTestDbContext.cs b/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteTestDbContext.cs
index 5cf220c..8d8cd09 100644
--- a/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteTestDbContext.cs
+++ b/tests/Zomp.EFCore.Combined.Sqlite.Tests/SqliteTestDbContext.cs
@@ -10,7 +10,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseSqlite(
+ _ = optionsBuilder.UseSqlite(
Connection,
sqlOptions => sqlOptions.UseWindowFunctions().UseBinaryFunctions());
}
@@ -20,7 +20,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
base.OnModelCreating(modelBuilder);
// Convert https://github.com/dotnet/efcore/issues/15078#issuecomment-475784385
- modelBuilder.Entity().Property(r => r.SomeGuid)
+ _ = modelBuilder.Entity().Property(r => r.SomeGuid)
.HasConversion(
g => g.ToByteArray(),
b => new Guid(b));
diff --git a/tests/Zomp.EFCore.Combined.Sqlite.Tests/TestBase.cs b/tests/Zomp.EFCore.Combined.Sqlite.Tests/TestBase.cs
index 84dcf76..9bf23e1 100644
--- a/tests/Zomp.EFCore.Combined.Sqlite.Tests/TestBase.cs
+++ b/tests/Zomp.EFCore.Combined.Sqlite.Tests/TestBase.cs
@@ -1,15 +1,8 @@
namespace Zomp.EFCore.Combined.Sqlite.Tests;
-public class TestBase : IDisposable
+public class TestBase(ITestOutputHelper output) : IDisposable
{
- private readonly SqliteTestDbContext dbContext;
-
- public TestBase(ITestOutputHelper output)
- {
- dbContext = new SqliteTestDbContext(output.ToLoggerFactory());
- }
-
- protected SqliteTestDbContext DbContext => dbContext;
+ protected SqliteTestDbContext DbContext { get; } = new(output.ToLoggerFactory());
public void Dispose()
{
@@ -21,10 +14,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- if (dbContext != null)
- {
- dbContext.Dispose();
- }
+ DbContext?.Dispose();
}
}
}
diff --git a/tests/Zomp.EFCore.Combined.Testing/CombinedTests.cs b/tests/Zomp.EFCore.Combined.Testing/CombinedTests.cs
index 09a738b..2a85463 100644
--- a/tests/Zomp.EFCore.Combined.Testing/CombinedTests.cs
+++ b/tests/Zomp.EFCore.Combined.Testing/CombinedTests.cs
@@ -1,13 +1,8 @@
namespace Zomp.EFCore.Combined.Testing;
-public class CombinedTests
+public class CombinedTests(TestDbContext dbContext)
{
- private readonly TestDbContext dbContext;
-
- public CombinedTests(TestDbContext dbContext)
- {
- this.dbContext = dbContext;
- }
+ private readonly TestDbContext dbContext = dbContext;
public void LastNonNullArithmetic()
{
@@ -17,7 +12,7 @@ public void LastNonNullArithmetic()
LastNonNull =
EF.Functions.BinaryCast(
EF.Functions.Max(
- r.Col1.HasValue ? r.Id * (1L << 32) | r.Col1.Value & uint.MaxValue : (long?)null,
+ r.Col1.HasValue ? (r.Id * (1L << 32)) | (r.Col1.Value & uint.MaxValue) : (long?)null,
EF.Functions.Over().OrderBy(r.Id))),
});
diff --git a/tests/Zomp.EFCore.Testing/TestDbContext.cs b/tests/Zomp.EFCore.Testing/TestDbContext.cs
index 8d4a3c3..3c5d790 100644
--- a/tests/Zomp.EFCore.Testing/TestDbContext.cs
+++ b/tests/Zomp.EFCore.Testing/TestDbContext.cs
@@ -20,9 +20,7 @@ protected static string GetSqlServerConnectionString(string databaseName)
///
protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity().Property(x => x.Id).ValueGeneratedNever();
- }
+ => _ = modelBuilder.Entity().Property(x => x.Id).ValueGeneratedNever();
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -30,7 +28,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
if (loggerFactory is not null)
{
- optionsBuilder.UseLoggerFactory(loggerFactory);
+ _ = optionsBuilder.UseLoggerFactory(loggerFactory);
}
}
diff --git a/tests/Zomp.EFCore.Testing/TestFixture.cs b/tests/Zomp.EFCore.Testing/TestFixture.cs
index 59be81d..0ab3d34 100644
--- a/tests/Zomp.EFCore.Testing/TestFixture.cs
+++ b/tests/Zomp.EFCore.Testing/TestFixture.cs
@@ -17,12 +17,12 @@ public class TestFixture : IAsyncLifetime
public async virtual Task InitializeAsync()
{
ArgumentNullException.ThrowIfNull(TestDBContext);
- await TestDBContext.Database.EnsureDeletedAsync();
- await TestDBContext.Database.EnsureCreatedAsync();
+ _ = await TestDBContext.Database.EnsureDeletedAsync();
+ _ = await TestDBContext.Database.EnsureCreatedAsync();
await TestDBContext.AddRangeAsync(TestRows);
- await TestDBContext.SaveChangesAsync();
+ _ = await TestDBContext.SaveChangesAsync();
}
///
@@ -31,7 +31,7 @@ public async virtual Task DisposeAsync()
ArgumentNullException.ThrowIfNull(TestDBContext);
if (!TestDbContext.Settings.PreserveData)
{
- await TestDBContext.Database.EnsureDeletedAsync();
+ _ = await TestDBContext.Database.EnsureDeletedAsync();
}
}
diff --git a/tests/Zomp.EFCore.Testing/TestRowEqualityComparer.cs b/tests/Zomp.EFCore.Testing/TestRowEqualityComparer.cs
index f38e906..32d896b 100644
--- a/tests/Zomp.EFCore.Testing/TestRowEqualityComparer.cs
+++ b/tests/Zomp.EFCore.Testing/TestRowEqualityComparer.cs
@@ -4,22 +4,13 @@ public class TestRowEqualityComparer : IEqualityComparer
{
public static TestRowEqualityComparer Default { get; } = new();
- public bool Equals(TestRow? x, TestRow? y)
- {
- if (x is null || y is null)
- {
- return x is null && y is null;
- }
-
- return x.Id == y.Id
+ public bool Equals(TestRow? x, TestRow? y) => x is null || y is null
+ ? x is null && y is null
+ : x.Id == y.Id
&& x.Col1 == y.Col1
&& x.SomeGuid == y.SomeGuid
&& x.Date == y.Date
&& x.IdBytes.SequenceEqual(y.IdBytes);
- }
- public int GetHashCode([DisallowNull] TestRow obj)
- {
- return HashCode.Combine(obj.Id.GetHashCode(), obj.Col1.GetHashCode(), obj.SomeGuid.GetHashCode(), obj.Date.GetHashCode());
- }
+ public int GetHashCode([DisallowNull] TestRow obj) => HashCode.Combine(obj.Id.GetHashCode(), obj.Col1.GetHashCode(), obj.SomeGuid.GetHashCode(), obj.Date.GetHashCode());
}
\ No newline at end of file
diff --git a/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlFixture.cs b/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlFixture.cs
index bd9643a..9a6247f 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlFixture.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.WindowFunctions.Npgsql.Tests;
-public class NpgsqlFixture : TestFixture
+public sealed class NpgsqlFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs b/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs
index e2a19b3..9423de1 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/NpgsqlTestDbContext.cs
@@ -8,7 +8,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseNpgsql(
+ _ = optionsBuilder.UseNpgsql(
ConnectionString,
o => o.UseWindowFunctions());
}
diff --git a/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/TestBase.cs b/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/TestBase.cs
index 8d7c312..462eb3d 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/TestBase.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Npgsql.Tests/TestBase.cs
@@ -1,15 +1,8 @@
namespace Zomp.EFCore.WindowFunctions.Npgsql.Tests;
-public class TestBase : IDisposable
+public class TestBase(ITestOutputHelper output) : IDisposable
{
- private readonly NpgsqlTestDbContext dbContext;
-
- public TestBase(ITestOutputHelper output)
- {
- dbContext = new NpgsqlTestDbContext(output.ToLoggerFactory());
- }
-
- protected NpgsqlTestDbContext DbContext => dbContext;
+ protected NpgsqlTestDbContext DbContext { get; } = new NpgsqlTestDbContext(output.ToLoggerFactory());
public void Dispose()
{
@@ -21,10 +14,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- if (dbContext != null)
- {
- dbContext.Dispose();
- }
+ DbContext?.Dispose();
}
}
}
diff --git a/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerFixture.cs b/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerFixture.cs
index 629e19b..10a1f50 100644
--- a/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerFixture.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.WindowFunctions.SqlServer.Tests;
-public class SqlServerFixture : TestFixture
+public sealed class SqlServerFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerTestDbContext.cs b/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerTestDbContext.cs
index 8b53b19..b2e17e2 100644
--- a/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerTestDbContext.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/SqlServerTestDbContext.cs
@@ -8,7 +8,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseSqlServer(
+ _ = optionsBuilder.UseSqlServer(
ConnectionString,
sqlOptions => sqlOptions.UseWindowFunctions());
}
diff --git a/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/TestBase.cs b/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/TestBase.cs
index fe6a65a..aa8ef2e 100644
--- a/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/TestBase.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.SqlServer.Tests/TestBase.cs
@@ -1,15 +1,8 @@
namespace Zomp.EFCore.WindowFunctions.SqlServer.Tests;
-public class TestBase : IDisposable
+public class TestBase(ITestOutputHelper output) : IDisposable
{
- private readonly SqlServerTestDbContext dbContext;
-
- public TestBase(ITestOutputHelper output)
- {
- dbContext = new SqlServerTestDbContext(output.ToLoggerFactory());
- }
-
- protected SqlServerTestDbContext DbContext => dbContext;
+ protected SqlServerTestDbContext DbContext { get; } = new SqlServerTestDbContext(output.ToLoggerFactory());
public void Dispose()
{
@@ -21,10 +14,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- if (dbContext != null)
- {
- dbContext.Dispose();
- }
+ DbContext?.Dispose();
}
}
}
diff --git a/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteFixture.cs b/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteFixture.cs
index 1733c58..f9e4476 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteFixture.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteFixture.cs
@@ -1,6 +1,6 @@
namespace Zomp.EFCore.WindowFunctions.Sqlite.Tests;
-public class SqliteFixture : TestFixture
+public sealed class SqliteFixture : TestFixture
{
public async override Task InitializeAsync()
{
diff --git a/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteTestDbContext.cs b/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteTestDbContext.cs
index f75f837..b01d841 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteTestDbContext.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/SqliteTestDbContext.cs
@@ -10,7 +10,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
- optionsBuilder.UseSqlite(
+ _ = optionsBuilder.UseSqlite(
Connection,
sqlOptions => sqlOptions.UseWindowFunctions());
}
@@ -20,7 +20,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
base.OnModelCreating(modelBuilder);
// Convert https://github.com/dotnet/efcore/issues/15078#issuecomment-475784385
- modelBuilder.Entity().Property(r => r.SomeGuid)
+ _ = modelBuilder.Entity().Property(r => r.SomeGuid)
.HasConversion(
g => g.ToByteArray(),
b => new Guid(b));
diff --git a/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/TestBase.cs b/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/TestBase.cs
index 98e2291..14ae23d 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/TestBase.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Sqlite.Tests/TestBase.cs
@@ -1,15 +1,8 @@
namespace Zomp.EFCore.WindowFunctions.Sqlite.Tests;
-public class TestBase : IDisposable
+public class TestBase(ITestOutputHelper output) : IDisposable
{
- private readonly SqliteTestDbContext dbContext;
-
- public TestBase(ITestOutputHelper output)
- {
- dbContext = new SqliteTestDbContext(output.ToLoggerFactory());
- }
-
- protected SqliteTestDbContext DbContext => dbContext;
+ protected SqliteTestDbContext DbContext { get; } = new SqliteTestDbContext(output.ToLoggerFactory());
public void Dispose()
{
@@ -21,10 +14,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- if (dbContext != null)
- {
- dbContext.Dispose();
- }
+ DbContext?.Dispose();
}
}
}
diff --git a/tests/Zomp.EFCore.WindowFunctions.Testing/AvgTests.cs b/tests/Zomp.EFCore.WindowFunctions.Testing/AvgTests.cs
index 1cfedd3..d35cfa6 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Testing/AvgTests.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Testing/AvgTests.cs
@@ -11,7 +11,7 @@ public void AvgBasic()
var result = query.ToList().Distinct();
- Assert.Single(result);
+ _ = Assert.Single(result);
var expected = ExpectedAverage(TestRows, r => r.Id);
diff --git a/tests/Zomp.EFCore.WindowFunctions.Testing/DecimalRoundingEqualityComparer.cs b/tests/Zomp.EFCore.WindowFunctions.Testing/DecimalRoundingEqualityComparer.cs
index e79d3c0..1206fe8 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Testing/DecimalRoundingEqualityComparer.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Testing/DecimalRoundingEqualityComparer.cs
@@ -2,33 +2,15 @@
namespace Zomp.EFCore.WindowFunctions.Testing;
-public class DecimalRoundingEqualityComparer : IEqualityComparer
+public class DecimalRoundingEqualityComparer(int roundingDecimals) : IEqualityComparer
{
- private readonly decimal epsilon;
-
- public DecimalRoundingEqualityComparer(int roundingDecimals)
- {
- epsilon = (decimal)Math.Pow(0.1, roundingDecimals);
- }
+ private readonly decimal epsilon = (decimal)Math.Pow(0.1, roundingDecimals);
public bool Equals(decimal? x, decimal? y)
{
- if (x == null && y == null)
- {
- return true;
- }
-
- if (x is null || y is null)
- {
- return false;
- }
-
- return Math.Abs(x.Value - y.Value) < this.epsilon;
+ return (x == null && y == null) || (x is not null && y is not null && Math.Abs(x.Value - y.Value) < epsilon);
}
[SuppressMessage("Design", "CA1065:Do not raise exceptions in unexpected locations", Justification = "Testing code")]
- public int GetHashCode([DisallowNull] decimal? obj)
- {
- throw new NotImplementedException();
- }
+ public int GetHashCode([DisallowNull] decimal? obj) => throw new NotImplementedException();
}
diff --git a/tests/Zomp.EFCore.WindowFunctions.Testing/RankTests.cs b/tests/Zomp.EFCore.WindowFunctions.Testing/RankTests.cs
index 67ffa75..156c045 100644
--- a/tests/Zomp.EFCore.WindowFunctions.Testing/RankTests.cs
+++ b/tests/Zomp.EFCore.WindowFunctions.Testing/RankTests.cs
@@ -70,7 +70,7 @@ public void DenseRankBasic()
[Fact]
public void PercentRankBasic()
{
- bool nullsLast = DbContext.IsPostgreSQL;
+ var nullsLast = DbContext.IsPostgreSQL;
var query = DbContext.TestRows
.Select(r => EF.Functions.PercentRank(EF.Functions.Over().OrderBy(r.Col1)));