From b7e7dc275263acd4312ea518f2696fd739eaf998 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Tue, 7 Dec 2021 10:39:11 +0000 Subject: [PATCH] Static analysis: redundancies in symbol declarations Part of #26805. --- ...osmosManyToManyJoinEntityTypeConvention.cs | 11 +++-- .../CosmosSqlTranslatingExpressionVisitor.cs | 2 +- .../Storage/Internal/CosmosDatabaseCreator.cs | 3 +- .../Design/Internal/CSharpHelper.cs | 8 ++-- .../Design/Internal/DatabaseOperations.cs | 2 - .../Design/Internal/MigrationsOperations.cs | 2 - .../CSharpRuntimeModelCodeGenerator.cs | 5 +-- .../Internal/CompiledModelScaffolder.cs | 8 +--- .../RelationalScaffoldingModelFactory.cs | 3 -- ...yExpressionTranslatingExpressionVisitor.cs | 2 +- ...nalCSharpRuntimeAnnotationCodeGenerator.cs | 8 ---- .../RelationalCommandDiagnosticsLogger.cs | 2 +- .../Diagnostics/RelationalLoggerExtensions.cs | 39 +++++++++--------- .../RelationalEntityTypeBuilderExtensions.cs | 12 +++--- .../RelationalForeignKeyExtensions.cs | 1 - .../Extensions/RelationalIndexExtensions.cs | 1 - .../Metadata/Builders/TableBuilder.cs | 2 +- .../Metadata/Builders/TableBuilder`.cs | 2 +- .../TableValuedDbFunctionConvention.cs | 6 +-- .../Internal/MigrationsModelDiffer.cs | 24 +++++------ ...lExpressionSimplifyingExpressionVisitor.cs | 2 +- ...lationalSqlTranslatingExpressionVisitor.cs | 2 +- .../Query/SqlExpressions/SelectExpression.cs | 1 - .../RelationalExecutionStrategyExtensions.cs | 10 ++--- .../Storage/RelationalTypeMappingInfo.cs | 2 +- .../Update/Internal/CommandBatchPreparer.cs | 1 - .../SqlServerGeometryMethodTranslator.cs | 4 +- .../Internal/SqlServerLoggerExtensions.cs | 2 +- .../SqlServerServiceCollectionExtensions.cs | 2 +- .../Conventions/SqlServerIndexConvention.cs | 4 +- .../SqlServerValueGenerationConvention.cs | 4 +- .../SqlServerMigrationsSqlGenerator.cs | 6 +-- ...rchConditionConvertingExpressionVisitor.cs | 3 -- .../SqlServerFromPartsFunctionTranslator.cs | 2 +- ...ServerFullTextSearchFunctionsTranslator.cs | 2 +- .../Query/Internal/SqlServerMathTranslator.cs | 2 +- .../SqliteServiceCollectionExtensions.cs | 2 +- .../SqliteByteArrayMethodTranslator.cs | 6 +-- .../Internal/SqliteCharMethodTranslator.cs | 2 +- .../Query/Internal/SqliteExpression.cs | 2 +- .../Query/Internal/SqliteMathTranslator.cs | 2 +- .../SqliteMethodCallTranslatorProvider.cs | 2 +- .../Internal/SqliteStringMethodTranslator.cs | 2 +- .../Internal/SqliteSubstrMethodTranslator.cs | 2 +- .../Internal/InternalEntityEntry.cs | 4 +- .../Internal/SnapshotFactoryFactory`.cs | 2 +- .../Internal/ValueGenerationManager.cs | 6 +-- src/EFCore/DbContextOptionsBuilder.cs | 2 +- .../Diagnostics/CoreLoggerExtensions.cs | 8 ++-- ...ityFrameworkServiceCollectionExtensions.cs | 4 +- .../EntityFrameworkServicesBuilder.cs | 4 +- src/EFCore/Internal/ServiceProviderCache.cs | 2 +- .../BaseTypeDiscoveryConvention.cs | 7 ++-- .../Conventions/ModelCleanupConvention.cs | 5 +-- .../NavigationAttributeConventionBase.cs | 8 ++-- .../RelationshipDiscoveryConvention.cs | 7 ++-- .../Internal/InternalPropertyBuilder.cs | 2 +- .../NavigationExpandingExpressionVisitor.cs | 9 ++--- .../Storage/ExecutionStrategyExtensions.cs | 30 +++++++------- .../ValueConversion/GuidToBytesConverter.cs | 2 +- .../Internal/StringGuidConverter.cs | 2 +- .../ValueConversion/ValueConverterSelector.cs | 40 +++++++++---------- src/Shared/EnumerableMethods.cs | 8 ++-- .../CommandLineApplication.cs | 4 +- .../FakeScaffoldingModelFactory.cs | 3 +- 65 files changed, 160 insertions(+), 211 deletions(-) diff --git a/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs b/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs index 625724ada78..7408e390138 100644 --- a/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs +++ b/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs @@ -93,7 +93,7 @@ private void ConfigurePartitionKeyJoinEntityType( CreateSkipNavigationForeignKey(skipNavigation.Inverse!, joinEntityTypeBuilder, partitionKey); } - private IConventionForeignKey CreateSkipNavigationForeignKey( + private void CreateSkipNavigationForeignKey( IConventionSkipNavigation skipNavigation, IConventionEntityTypeBuilder joinEntityTypeBuilder, IConventionProperty partitionKeyProperty) @@ -101,19 +101,20 @@ private IConventionForeignKey CreateSkipNavigationForeignKey( if (skipNavigation.ForeignKey != null && !skipNavigation.Builder.CanSetForeignKey(null)) { - return skipNavigation.ForeignKey; + return; } var principalKey = skipNavigation.DeclaringEntityType.FindPrimaryKey(); if (principalKey == null || principalKey.Properties.All(p => p.Name != partitionKeyProperty.Name)) { - return CreateSkipNavigationForeignKey(skipNavigation, joinEntityTypeBuilder); + CreateSkipNavigationForeignKey(skipNavigation, joinEntityTypeBuilder); + return; } if (skipNavigation.ForeignKey?.Properties.Contains(partitionKeyProperty) == true) { - return skipNavigation.ForeignKey; + return; } var dependentProperties = new IConventionProperty[principalKey.Properties.Count]; @@ -136,8 +137,6 @@ private IConventionForeignKey CreateSkipNavigationForeignKey( .Metadata; skipNavigation.Builder.HasForeignKey(foreignKey); - - return foreignKey; } private void ProcessJoinPartitionKey(IConventionSkipNavigation skipNavigation) diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs index 54155a4a2be..bdeb3973e27 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs @@ -916,7 +916,7 @@ private static bool CanEvaluate(Expression expression) switch (expression) #pragma warning restore IDE0066 // Convert switch statement to expression { - case ConstantExpression constantExpression: + case ConstantExpression: return true; case NewExpression newExpression: diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs index a85b44721d2..021532c1693 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs @@ -163,10 +163,9 @@ private IUpdateAdapter AddSeedData() var updateAdapter = _updateAdapterFactory.CreateStandalone(); foreach (var entityType in _designTimeModel.Model.GetEntityTypes()) { - IEntityType? targetEntityType = null; foreach (var targetSeed in entityType.GetSeedData()) { - targetEntityType ??= updateAdapter.Model.FindEntityType(entityType.Name)!; + updateAdapter.Model.FindEntityType(entityType.Name); var entry = updateAdapter.CreateEntry(targetSeed, entityType); entry.EntityState = EntityState.Added; } diff --git a/src/EFCore.Design/Design/Internal/CSharpHelper.cs b/src/EFCore.Design/Design/Internal/CSharpHelper.cs index 9cc748be464..868f587fd7d 100644 --- a/src/EFCore.Design/Design/Internal/CSharpHelper.cs +++ b/src/EFCore.Design/Design/Internal/CSharpHelper.cs @@ -264,23 +264,21 @@ public virtual string Identifier(string name, ICollection? scope = null, return _keywords.Contains(identifier) ? "@" + identifier : identifier; } - private static StringBuilder ChangeFirstLetterCase(StringBuilder builder, bool capitalize) + private static void ChangeFirstLetterCase(StringBuilder builder, bool capitalize) { if (builder.Length == 0) { - return builder; + return; } var first = builder[index: 0]; if (char.IsUpper(first) == capitalize) { - return builder; + return; } builder.Remove(startIndex: 0, length: 1) .Insert(index: 0, value: capitalize ? char.ToUpperInvariant(first) : char.ToLowerInvariant(first)); - - return builder; } /// diff --git a/src/EFCore.Design/Design/Internal/DatabaseOperations.cs b/src/EFCore.Design/Design/Internal/DatabaseOperations.cs index f8fe93b3c0c..b889e918b8b 100644 --- a/src/EFCore.Design/Design/Internal/DatabaseOperations.cs +++ b/src/EFCore.Design/Design/Internal/DatabaseOperations.cs @@ -11,7 +11,6 @@ namespace Microsoft.EntityFrameworkCore.Design.Internal; /// public class DatabaseOperations { - private readonly IOperationReporter _reporter; private readonly string _projectDir; private readonly string? _rootNamespace; private readonly string? _language; @@ -35,7 +34,6 @@ public DatabaseOperations( bool nullable, string[]? args) { - _reporter = reporter; _projectDir = projectDir; _rootNamespace = rootNamespace; _language = language; diff --git a/src/EFCore.Design/Design/Internal/MigrationsOperations.cs b/src/EFCore.Design/Design/Internal/MigrationsOperations.cs index 43d278e9319..6d87f54d907 100644 --- a/src/EFCore.Design/Design/Internal/MigrationsOperations.cs +++ b/src/EFCore.Design/Design/Internal/MigrationsOperations.cs @@ -18,7 +18,6 @@ public class MigrationsOperations private readonly string _projectDir; private readonly string? _rootNamespace; private readonly string? _language; - private readonly bool _nullable; private readonly DesignTimeServicesBuilder _servicesBuilder; private readonly DbContextOperations _contextOperations; private readonly string[] _args; @@ -44,7 +43,6 @@ public MigrationsOperations( _projectDir = projectDir; _rootNamespace = rootNamespace; _language = language; - _nullable = nullable; _args = args ?? Array.Empty(); _contextOperations = new DbContextOperations( reporter, diff --git a/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs b/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs index a6558d4eafc..53c79d68e40 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs @@ -58,7 +58,7 @@ public virtual IReadOnlyCollection GenerateModel( CompiledModelCodeGenerationOptions options) { var scaffoldedFiles = new List(); - var modelCode = CreateModel(model, options.ModelNamespace, options.ContextType, options.UseNullableReferenceTypes); + var modelCode = CreateModel(options.ModelNamespace, options.ContextType, options.UseNullableReferenceTypes); var modelFileName = options.ContextType.ShortDisplayName() + ModelSuffix + FileExtension; scaffoldedFiles.Add(new ScaffoldedFile { Path = modelFileName, Code = modelCode }); @@ -115,7 +115,6 @@ private static string GenerateHeader(SortedSet namespaces, string curren } private string CreateModel( - IModel model, string @namespace, Type contextType, bool nullable) @@ -306,7 +305,7 @@ private string CreateModelBuilder( mainBuilder.AppendLine(); } - foreach (var (entityType, namePair) in entityTypeIds) + foreach (var (_, namePair) in entityTypeIds) { var (variableName, entityClassName) = namePair; diff --git a/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs b/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs index 9b0b6e288bc..539424fd218 100644 --- a/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs +++ b/src/EFCore.Design/Scaffolding/Internal/CompiledModelScaffolder.cs @@ -3,7 +3,6 @@ using System.Globalization; using System.Text; -using Microsoft.EntityFrameworkCore.Design.Internal; using Microsoft.EntityFrameworkCore.Internal; namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal; @@ -16,20 +15,15 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal; /// public class CompiledModelScaffolder : ICompiledModelScaffolder { - private readonly IOperationReporter _reporter; - /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public CompiledModelScaffolder( - ICompiledModelCodeGeneratorSelector modelCodeGeneratorSelector, - IOperationReporter reporter) + public CompiledModelScaffolder(ICompiledModelCodeGeneratorSelector modelCodeGeneratorSelector) { ModelCodeGeneratorSelector = modelCodeGeneratorSelector; - _reporter = reporter; } /// diff --git a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs index 5d4981caf08..88f8f48bed7 100644 --- a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs +++ b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs @@ -32,7 +32,6 @@ public class RelationalScaffoldingModelFactory : IScaffoldingModelFactory private readonly IPluralizer _pluralizer; private readonly ICSharpUtilities _cSharpUtilities; private readonly IScaffoldingTypeMapper _scaffoldingTypeMapper; - private readonly LoggingDefinitions _loggingDefinitions; private readonly IModelRuntimeInitializer _modelRuntimeInitializer; /// @@ -47,7 +46,6 @@ public RelationalScaffoldingModelFactory( IPluralizer pluralizer, ICSharpUtilities cSharpUtilities, IScaffoldingTypeMapper scaffoldingTypeMapper, - LoggingDefinitions loggingDefinitions, IModelRuntimeInitializer modelRuntimeInitializer) { _reporter = reporter; @@ -55,7 +53,6 @@ public RelationalScaffoldingModelFactory( _pluralizer = pluralizer; _cSharpUtilities = cSharpUtilities; _scaffoldingTypeMapper = scaffoldingTypeMapper; - _loggingDefinitions = loggingDefinitions; _modelRuntimeInitializer = modelRuntimeInitializer; } diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs index 11b9e87184e..afbbb7974b1 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs @@ -1264,7 +1264,7 @@ private static bool CanEvaluate(Expression expression) switch (expression) #pragma warning restore IDE0066 // Convert switch statement to expression { - case ConstantExpression constantExpression: + case ConstantExpression: return true; case NewExpression newExpression: diff --git a/src/EFCore.Relational/Design/Internal/RelationalCSharpRuntimeAnnotationCodeGenerator.cs b/src/EFCore.Relational/Design/Internal/RelationalCSharpRuntimeAnnotationCodeGenerator.cs index ec480d815ee..d0304ce766d 100644 --- a/src/EFCore.Relational/Design/Internal/RelationalCSharpRuntimeAnnotationCodeGenerator.cs +++ b/src/EFCore.Relational/Design/Internal/RelationalCSharpRuntimeAnnotationCodeGenerator.cs @@ -457,14 +457,6 @@ public override void Generate(IForeignKey foreignKey, CSharpRuntimeAnnotationCod base.Generate(foreignKey, parameters); } - /// - public override void Generate(INavigation navigation, CSharpRuntimeAnnotationCodeGeneratorParameters parameters) - => base.Generate(navigation, parameters); - - /// - public override void Generate(ISkipNavigation navigation, CSharpRuntimeAnnotationCodeGeneratorParameters parameters) - => base.Generate(navigation, parameters); - /// public override void Generate(IIndex index, CSharpRuntimeAnnotationCodeGeneratorParameters parameters) { diff --git a/src/EFCore.Relational/Diagnostics/Internal/RelationalCommandDiagnosticsLogger.cs b/src/EFCore.Relational/Diagnostics/Internal/RelationalCommandDiagnosticsLogger.cs index 5602979a0aa..dc344fa3fab 100644 --- a/src/EFCore.Relational/Diagnostics/Internal/RelationalCommandDiagnosticsLogger.cs +++ b/src/EFCore.Relational/Diagnostics/Internal/RelationalCommandDiagnosticsLogger.cs @@ -1293,7 +1293,7 @@ public virtual InterceptionResult DataReaderDisposing( var eventData = new DataReaderDisposingEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), command, dataReader, connection.Context, diff --git a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs index 02edf1f83b9..597bc0a8427 100644 --- a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs +++ b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs @@ -546,7 +546,7 @@ private static TransactionEventData BroadcastTransactionCommitting( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -672,7 +672,7 @@ private static TransactionEndEventData BroadcastTransactionCommitted( { var eventData = new TransactionEndEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -799,7 +799,7 @@ private static TransactionEndEventData BroadcastTransactionRolledBack( { var eventData = new TransactionEndEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -925,7 +925,7 @@ private static TransactionEventData BroadcastTransactionRollingBack( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1050,7 +1050,7 @@ private static TransactionEventData BroadcastCreatingTransactionSavepoint( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1169,7 +1169,7 @@ private static TransactionEventData BroadcastCreatedTransactionSavepoint( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1294,7 +1294,7 @@ private static TransactionEventData BroadcastRollingBackToTransactionSavepoint( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1413,7 +1413,7 @@ private static TransactionEventData BroadcastRolledBackToTransactionSavepoint( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1538,7 +1538,7 @@ private static TransactionEventData BroadcastReleasingTransactionSavepoint( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1657,7 +1657,7 @@ private static TransactionEventData BroadcastReleasedTransactionSavepoint( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1706,7 +1706,7 @@ public static void TransactionDisposed( { var eventData = new TransactionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1741,7 +1741,7 @@ public static void TransactionError( { var definition = RelationalResources.LogTransactionError(diagnostics); - LogTransactionError(diagnostics, exception, definition); + LogTransactionError(diagnostics, definition); if (diagnostics.NeedsEventData( definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -1791,7 +1791,7 @@ public static Task TransactionErrorAsync( { var definition = RelationalResources.LogTransactionError(diagnostics); - LogTransactionError(diagnostics, exception, definition); + LogTransactionError(diagnostics, definition); if (diagnostics.NeedsEventData( definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -1835,7 +1835,7 @@ private static TransactionErrorEventData BroadcastTransactionError( { var eventData = new TransactionErrorEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), transaction, connection.Context, transactionId, @@ -1853,7 +1853,6 @@ private static TransactionErrorEventData BroadcastTransactionError( private static void LogTransactionError( IDiagnosticsLogger diagnostics, - Exception exception, EventDefinition definition) { if (diagnostics.ShouldLog(definition)) @@ -1884,7 +1883,7 @@ public static void AmbientTransactionWarning( { var eventData = new ConnectionEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), connection.DbConnection, connection.Context, connection.ConnectionId, @@ -2199,7 +2198,7 @@ public static void MigrationsNotApplied( { var eventData = new MigratorEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), migrator); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); @@ -2332,7 +2331,7 @@ public static void MultipleCollectionIncludeWarning( { var eventData = new EventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage()); + (d, _) => ((EventDefinition)d).GenerateMessage()); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); } @@ -2889,7 +2888,7 @@ public static void BatchExecutorFailedToRollbackToSavepoint( { var eventData = new DbContextTypeErrorEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), contextType, exception); @@ -2919,7 +2918,7 @@ public static void BatchExecutorFailedToReleaseSavepoint( { var eventData = new DbContextTypeErrorEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), contextType, exception); diff --git a/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs b/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs index 74ad32b2bf1..1729ecfc88d 100644 --- a/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs @@ -51,7 +51,7 @@ public static EntityTypeBuilder ToTable( { Check.NotNull(buildAction, nameof(buildAction)); - buildAction(new TableBuilder(null, null, entityTypeBuilder.Metadata)); + buildAction(new TableBuilder(entityTypeBuilder.Metadata)); return entityTypeBuilder; } @@ -76,7 +76,7 @@ public static EntityTypeBuilder ToTable( entityTypeBuilder.Metadata.SetTableName(name); entityTypeBuilder.Metadata.SetSchema(null); - buildAction(new TableBuilder(name, null, entityTypeBuilder.Metadata)); + buildAction(new TableBuilder(entityTypeBuilder.Metadata)); return entityTypeBuilder; } @@ -192,7 +192,7 @@ public static EntityTypeBuilder ToTable( entityTypeBuilder.Metadata.SetTableName(name); entityTypeBuilder.Metadata.SetSchema(schema); - buildAction(new TableBuilder(name, schema, entityTypeBuilder.Metadata)); + buildAction(new TableBuilder(entityTypeBuilder.Metadata)); return entityTypeBuilder; } @@ -281,7 +281,7 @@ public static OwnedNavigationBuilder ToTable( { Check.NotNull(buildAction, nameof(buildAction)); - buildAction(new TableBuilder(null, null, referenceOwnershipBuilder.OwnedEntityType)); + buildAction(new TableBuilder(referenceOwnershipBuilder.OwnedEntityType)); return referenceOwnershipBuilder; } @@ -344,7 +344,7 @@ public static OwnedNavigationBuilder ToTable( referenceOwnershipBuilder.OwnedEntityType.SetTableName(name); referenceOwnershipBuilder.OwnedEntityType.SetSchema(null); - buildAction(new TableBuilder(name, null, referenceOwnershipBuilder.OwnedEntityType)); + buildAction(new TableBuilder(referenceOwnershipBuilder.OwnedEntityType)); return referenceOwnershipBuilder; } @@ -423,7 +423,7 @@ public static OwnedNavigationBuilder ToTable( referenceOwnershipBuilder.OwnedEntityType.SetTableName(name); referenceOwnershipBuilder.OwnedEntityType.SetSchema(schema); - buildAction(new TableBuilder(name, schema, referenceOwnershipBuilder.OwnedEntityType)); + buildAction(new TableBuilder(referenceOwnershipBuilder.OwnedEntityType)); return referenceOwnershipBuilder; } diff --git a/src/EFCore.Relational/Extensions/RelationalForeignKeyExtensions.cs b/src/EFCore.Relational/Extensions/RelationalForeignKeyExtensions.cs index c49221d40d4..1be45e2ac3b 100644 --- a/src/EFCore.Relational/Extensions/RelationalForeignKeyExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalForeignKeyExtensions.cs @@ -53,7 +53,6 @@ public static class RelationalForeignKeyExtensions public static string GetDefaultName(this IReadOnlyForeignKey foreignKey) { var tableName = foreignKey.DeclaringEntityType.GetTableName(); - var schema = foreignKey.DeclaringEntityType.GetSchema(); var principalTableName = foreignKey.PrincipalEntityType.GetTableName(); var name = new StringBuilder() diff --git a/src/EFCore.Relational/Extensions/RelationalIndexExtensions.cs b/src/EFCore.Relational/Extensions/RelationalIndexExtensions.cs index 6c935073bc1..705c7004d33 100644 --- a/src/EFCore.Relational/Extensions/RelationalIndexExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalIndexExtensions.cs @@ -43,7 +43,6 @@ public static string GetDatabaseName(this IReadOnlyIndex index) public static string GetDefaultDatabaseName(this IReadOnlyIndex index) { var tableName = index.DeclaringEntityType.GetTableName(); - var schema = index.DeclaringEntityType.GetSchema(); var baseName = new StringBuilder() .Append("IX_") .Append(tableName) diff --git a/src/EFCore.Relational/Metadata/Builders/TableBuilder.cs b/src/EFCore.Relational/Metadata/Builders/TableBuilder.cs index 2ca8d1b9a8a..17fd6089340 100644 --- a/src/EFCore.Relational/Metadata/Builders/TableBuilder.cs +++ b/src/EFCore.Relational/Metadata/Builders/TableBuilder.cs @@ -18,7 +18,7 @@ public class TableBuilder /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - public TableBuilder(string? name, string? schema, IMutableEntityType entityType) + public TableBuilder(IMutableEntityType entityType) { Metadata = entityType; } diff --git a/src/EFCore.Relational/Metadata/Builders/TableBuilder`.cs b/src/EFCore.Relational/Metadata/Builders/TableBuilder`.cs index 3a43e10094b..4774f3a9b48 100644 --- a/src/EFCore.Relational/Metadata/Builders/TableBuilder`.cs +++ b/src/EFCore.Relational/Metadata/Builders/TableBuilder`.cs @@ -19,7 +19,7 @@ public class TableBuilder : TableBuilder /// [EntityFrameworkInternal] public TableBuilder(string? name, string? schema, IMutableEntityType entityType) - : base(name, schema, entityType) + : base(entityType) { } diff --git a/src/EFCore.Relational/Metadata/Conventions/TableValuedDbFunctionConvention.cs b/src/EFCore.Relational/Metadata/Conventions/TableValuedDbFunctionConvention.cs index 2e1aff35257..438188a0b89 100644 --- a/src/EFCore.Relational/Metadata/Conventions/TableValuedDbFunctionConvention.cs +++ b/src/EFCore.Relational/Metadata/Conventions/TableValuedDbFunctionConvention.cs @@ -42,7 +42,7 @@ public virtual void ProcessModelFinalizing( { foreach (var function in modelBuilder.Metadata.GetDbFunctions()) { - ProcessDbFunctionAdded(function.Builder, context); + ProcessDbFunctionAdded(function.Builder); } } @@ -50,10 +50,8 @@ public virtual void ProcessModelFinalizing( /// Called when an is added to the model. /// /// The builder for the . - /// Additional information associated with convention execution. private void ProcessDbFunctionAdded( - IConventionDbFunctionBuilder dbFunctionBuilder, - IConventionContext context) + IConventionDbFunctionBuilder dbFunctionBuilder) { var function = dbFunctionBuilder.Metadata; if (function.IsScalar) diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs index 420377dcba1..b5ed77c1839 100644 --- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs +++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs @@ -281,7 +281,7 @@ protected virtual IReadOnlyList Sort( } createTableOperations = (List)createTableGraph.TopologicalSort( - (principalCreateTableOperation, createTableOperation, cyclicAddForeignKeyOperations) => + (_, createTableOperation, cyclicAddForeignKeyOperations) => { foreach (var cyclicAddForeignKeyOperation in cyclicAddForeignKeyOperations) { @@ -317,7 +317,7 @@ protected virtual IReadOnlyList Sort( var newDiffContext = new DiffContext(); dropTableOperations = (List)dropTableGraph.TopologicalSort( - (dropTableOperation, principalDropTableOperation, foreignKeys) => + (_, _, foreignKeys) => { dropForeignKeyOperations.AddRange(foreignKeys.SelectMany(c => Remove(c, newDiffContext))); @@ -487,7 +487,7 @@ protected virtual IEnumerable Diff( Diff, Add, Remove, - (s, t, c) => s == t); + (s, t, _) => s == t); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -542,7 +542,7 @@ protected virtual IEnumerable Diff( Diff, Add, Remove, - (s, t, c) => string.Equals( + (s, t, _) => string.Equals( s.Schema, t.Schema, StringComparison.OrdinalIgnoreCase) @@ -550,12 +550,12 @@ protected virtual IEnumerable Diff( s.Name, t.Name, StringComparison.OrdinalIgnoreCase), - (s, t, c) => string.Equals( + (s, t, _) => string.Equals( s.Name, t.Name, StringComparison.OrdinalIgnoreCase), - (s, t, c) => string.Equals(GetMainType(s).Name, GetMainType(t).Name, StringComparison.OrdinalIgnoreCase), - (s, t, c) => s.EntityTypeMappings.Any( + (s, t, _) => string.Equals(GetMainType(s).Name, GetMainType(t).Name, StringComparison.OrdinalIgnoreCase), + (s, t, _) => s.EntityTypeMappings.Any( se => t.EntityTypeMappings.Any( te => string.Equals(se.EntityType.Name, te.EntityType.Name, StringComparison.OrdinalIgnoreCase)))); @@ -884,14 +884,14 @@ protected virtual IEnumerable Diff( Diff, (t, c) => Add(t, c), Remove, - (s, t, c) => string.Equals(s.Name, t.Name, StringComparison.OrdinalIgnoreCase), + (s, t, _) => string.Equals(s.Name, t.Name, StringComparison.OrdinalIgnoreCase), (s, t, c) => s.PropertyMappings.Any( sm => t.PropertyMappings.Any( tm => string.Equals(sm.Property.Name, tm.Property.Name, StringComparison.OrdinalIgnoreCase) && EntityTypePathEquals(sm.Property.DeclaringEntityType, tm.Property.DeclaringEntityType, c))), - (s, t, c) => s.PropertyMappings.Any( + (s, t, _) => s.PropertyMappings.Any( sm => t.PropertyMappings.Any( tm => @@ -903,7 +903,7 @@ protected virtual IEnumerable Diff( tm => string.Equals(sm.Property.Name, tm.Property.Name, StringComparison.OrdinalIgnoreCase) && EntityTypePathEquals(sm.Property.DeclaringEntityType, tm.Property.DeclaringEntityType, c))), - (s, t, c) => ColumnStructureEquals(s, t)); + (s, t, _) => ColumnStructureEquals(s, t)); private bool ColumnStructureEquals(IColumn source, IColumn target) { @@ -1553,10 +1553,10 @@ protected virtual IEnumerable Diff( Diff, Add, Remove, - (s, t, c) => string.Equals(s.Schema, t.Schema, StringComparison.OrdinalIgnoreCase) + (s, t, _) => string.Equals(s.Schema, t.Schema, StringComparison.OrdinalIgnoreCase) && string.Equals(s.Name, t.Name, StringComparison.OrdinalIgnoreCase) && s.Type == t.Type, - (s, t, c) => string.Equals(s.Name, t.Name, StringComparison.OrdinalIgnoreCase) + (s, t, _) => string.Equals(s.Name, t.Name, StringComparison.OrdinalIgnoreCase) && s.Type == t.Type); /// diff --git a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs index e56ec773e06..67295949edb 100644 --- a/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs @@ -84,7 +84,7 @@ protected override Expression VisitExtension(Expression extensionExpression) sqlFunctionExpression.Name, distinctArguments, sqlFunctionExpression.IsNullable, - argumentsPropagateNullability: distinctArguments.Select(a => false).ToArray(), + argumentsPropagateNullability: distinctArguments.Select(_ => false).ToArray(), sqlFunctionExpression.Type, sqlFunctionExpression.TypeMapping) : distinctArguments[0]; diff --git a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs index afb92afcf60..b2fa6f840bd 100644 --- a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs @@ -1315,7 +1315,7 @@ private static bool CanEvaluate(Expression expression) switch (expression) #pragma warning restore IDE0066 // Convert switch statement to expression { - case ConstantExpression constantExpression: + case ConstantExpression: return true; case NewExpression newExpression: diff --git a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs index 693254cbc12..f627beb5085 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs @@ -919,7 +919,6 @@ void GetOrderingsFromInnerTable( Expression CopyProjectionToOuter(SelectExpression innerSelectExpression, Expression innerShaperExpression) { var projectionIndexMap = new int[innerSelectExpression._projection.Count]; - var innerTableReferenceExpression = _tableReferences[^1]; for (var j = 0; j < projectionIndexMap.Length; j++) { var projection = MakeNullable(innerSelectExpression._projection[j].Expression, nullable: true); diff --git a/src/EFCore.Relational/Storage/RelationalExecutionStrategyExtensions.cs b/src/EFCore.Relational/Storage/RelationalExecutionStrategyExtensions.cs index b030fff6357..a0ae36e5c82 100644 --- a/src/EFCore.Relational/Storage/RelationalExecutionStrategyExtensions.cs +++ b/src/EFCore.Relational/Storage/RelationalExecutionStrategyExtensions.cs @@ -41,7 +41,7 @@ public static void ExecuteInTransaction( Action operation, Func verifySucceeded, IsolationLevel isolationLevel) - => strategy.ExecuteInTransaction(null, s => operation(), s => verifySucceeded(), isolationLevel); + => strategy.ExecuteInTransaction(null, _ => operation(), _ => verifySucceeded(), isolationLevel); /// /// Executes the specified asynchronous operation in a transaction. Allows to check whether @@ -73,7 +73,7 @@ public static Task ExecuteInTransactionAsync( Func operation, Func> verifySucceeded, IsolationLevel isolationLevel) - => strategy.ExecuteInTransactionAsync(null, (s, ct) => operation(), (s, ct) => verifySucceeded(), isolationLevel); + => strategy.ExecuteInTransactionAsync(null, (_, _) => operation(), (_, _) => verifySucceeded(), isolationLevel); /// /// Executes the specified asynchronous operation in a transaction. Allows to check whether @@ -112,7 +112,7 @@ public static Task ExecuteInTransactionAsync( IsolationLevel isolationLevel, CancellationToken cancellationToken = default) => strategy.ExecuteInTransactionAsync( - null, (s, ct) => operation(ct), (s, ct) => verifySucceeded(ct), isolationLevel, cancellationToken); + null, (_, ct) => operation(ct), (_, ct) => verifySucceeded(ct), isolationLevel, cancellationToken); /// /// Executes the specified operation in a transaction and returns the result. Allows to check whether @@ -141,7 +141,7 @@ public static TResult ExecuteInTransaction( Func operation, Func verifySucceeded, IsolationLevel isolationLevel) - => strategy.ExecuteInTransaction(null, s => operation(), s => verifySucceeded(), isolationLevel); + => strategy.ExecuteInTransaction(null, _ => operation(), _ => verifySucceeded(), isolationLevel); /// /// Executes the specified asynchronous operation in a transaction and returns the result. Allows to check whether @@ -181,7 +181,7 @@ public static Task ExecuteInTransactionAsync( IsolationLevel isolationLevel, CancellationToken cancellationToken = default) => strategy.ExecuteInTransactionAsync( - null, (s, ct) => operation(ct), (s, ct) => verifySucceeded(ct), isolationLevel, cancellationToken); + null, (_, ct) => operation(ct), (_, ct) => verifySucceeded(ct), isolationLevel, cancellationToken); /// /// Executes the specified operation in a transaction. Allows to check whether diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs index cdbaca780a2..47091833c5f 100644 --- a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs +++ b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Storage; /// See Implementation of database providers and extensions /// for more information and examples. /// -public readonly record struct RelationalTypeMappingInfo : IEquatable +public readonly record struct RelationalTypeMappingInfo { private readonly TypeMappingInfo _coreTypeMappingInfo; diff --git a/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs b/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs index 85885d97c2d..aae7e654500 100644 --- a/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs +++ b/src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs @@ -157,7 +157,6 @@ protected virtual IEnumerable CreateModificationCo } var mappings = (IReadOnlyCollection)entry.EntityType.GetTableMappings(); - var mappingCount = mappings.Count; IModificationCommand? firstCommands = null; foreach (var mapping in mappings) { diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs index 8d0a6969285..ccad5491b55 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs @@ -116,7 +116,7 @@ public SqlServerGeometryMethodTranslator( ? new[] { false } : functionName == "STRelate" ? new[] { true, false } - : finalArguments.Select(a => true).ToArray(); + : finalArguments.Select(_ => true).ToArray(); return _sqlExpressionFactory.Function( instance, @@ -172,7 +172,7 @@ public SqlServerGeometryMethodTranslator( finalArguments, nullable: true, instancePropagatesNullability: true, - argumentsPropagateNullability: finalArguments.Select(a => true), + argumentsPropagateNullability: finalArguments.Select(_ => true), typeof(double)), typeMappedArguments[1]); } diff --git a/src/EFCore.SqlServer/Extensions/Internal/SqlServerLoggerExtensions.cs b/src/EFCore.SqlServer/Extensions/Internal/SqlServerLoggerExtensions.cs index a8796e91049..dc7cb7321c4 100644 --- a/src/EFCore.SqlServer/Extensions/Internal/SqlServerLoggerExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/Internal/SqlServerLoggerExtensions.cs @@ -590,7 +590,7 @@ public static void SavepointsDisabledBecauseOfMARS( { var eventData = new EventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage()); + (d, _) => ((EventDefinition)d).GenerateMessage()); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); } diff --git a/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs index 55ef623197a..3a96307e01c 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs @@ -65,7 +65,7 @@ public static IServiceCollection AddSqlServer( Check.NotEmpty(connectionString, nameof(connectionString)); return serviceCollection.AddDbContext( - (serviceProvider, options) => + (_, options) => { optionsAction?.Invoke(options); options.UseSqlServer(connectionString, sqlServerOptionsAction); diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs index 4dec4285373..2f57e6cf813 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs @@ -156,7 +156,7 @@ public virtual void ProcessPropertyAnnotationChanged( } } - private IConventionIndexBuilder SetIndexFilter(IConventionIndexBuilder indexBuilder, bool columnNameChanged = false) + private void SetIndexFilter(IConventionIndexBuilder indexBuilder, bool columnNameChanged = false) { var index = indexBuilder.Metadata; if (index.IsUnique @@ -177,8 +177,6 @@ private IConventionIndexBuilder SetIndexFilter(IConventionIndexBuilder indexBuil indexBuilder.HasFilter(null); } } - - return indexBuilder; } private string CreateIndexFilter(List nullableColumns) diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationConvention.cs index 8fb8728cc1c..5489dc0e1a2 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationConvention.cs @@ -130,13 +130,13 @@ public override void ProcessEntityTypeAnnotationChanged( IReadOnlyProperty property, in StoreObjectIdentifier storeObject, ITypeMappingSource typeMappingSource) - => GetTemporalValueGenerated(property, storeObject) + => GetTemporalValueGenerated(property) ?? RelationalValueGenerationConvention.GetValueGenerated(property, storeObject) ?? (property.GetValueGenerationStrategy(storeObject, typeMappingSource) != SqlServerValueGenerationStrategy.None ? ValueGenerated.OnAdd : null); - private ValueGenerated? GetTemporalValueGenerated(IReadOnlyProperty property, in StoreObjectIdentifier storeObject) + private ValueGenerated? GetTemporalValueGenerated(IReadOnlyProperty property) { var entityType = property.DeclaringEntityType; return entityType.IsTemporal() diff --git a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs index abebe767796..e2723746f68 100644 --- a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs +++ b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs @@ -2280,7 +2280,7 @@ private IReadOnlyList RewriteOperations( operations.Add(operation); break; - case DropTableOperation dropTableOperation: + case DropTableOperation: DisableVersioning(table!, schema, historyTableName!, historyTableSchema); operations.Add(operation); @@ -2490,7 +2490,7 @@ alterTableOperation.OldTable[SqlServerAnnotationNames.TemporalHistoryTableSchema void DisableVersioning(string table, string? schema, string historyTableName, string? historyTableSchema) { - if (!versioningMap.TryGetValue((table, schema), out var result)) + if (!versioningMap.TryGetValue((table, schema), out _)) { versioningMap[(table, schema)] = (historyTableName, historyTableSchema); @@ -2541,7 +2541,7 @@ void EnableVersioning(string table, string? schema, string historyTableName, str void DisablePeriod(string table, string? schema, string periodStartColumnName, string periodEndColumnName) { - if (!periodMap.TryGetValue((table, schema), out var result)) + if (!periodMap.TryGetValue((table, schema), out _)) { periodMap[(table, schema)] = (periodStartColumnName, periodEndColumnName); diff --git a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs index ebe58ee32c7..da1fe7c7729 100644 --- a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs @@ -620,12 +620,10 @@ protected override Expression VisitRowNumber(RowNumberExpression rowNumberExpres { var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; - var changed = false; var partitions = new List(); foreach (var partition in rowNumberExpression.Partitions) { var newPartition = (SqlExpression)Visit(partition); - changed |= newPartition != partition; partitions.Add(newPartition); } @@ -633,7 +631,6 @@ protected override Expression VisitRowNumber(RowNumberExpression rowNumberExpres foreach (var ordering in rowNumberExpression.Orderings) { var newOrdering = (OrderingExpression)Visit(ordering); - changed |= newOrdering != ordering; orderings.Add(newOrdering); } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs index 1678d07e047..7d94c8251cc 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs @@ -88,7 +88,7 @@ public SqlServerFromPartsFunctionTranslator( value.FunctionName, arguments.Skip(1), nullable: true, - argumentsPropagateNullability: arguments.Skip(1).Select(a => true), + argumentsPropagateNullability: arguments.Skip(1).Select(_ => true), _dateFromPartsMethodInfo.ReturnType, _typeMappingSource.FindMapping(_dateFromPartsMethodInfo.ReturnType, value.ReturnType)); } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs index fcb5b24a9b8..6efc701275a 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs @@ -93,7 +93,7 @@ public SqlServerFullTextSearchFunctionsTranslator(ISqlExpressionFactory sqlExpre functionArguments, nullable: true, // TODO: don't propagate for now - argumentsPropagateNullability: functionArguments.Select(a => false).ToList(), + argumentsPropagateNullability: functionArguments.Select(_ => false).ToList(), typeof(bool)); } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs index de8b5f18147..9b0be4a8c4d 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs @@ -126,7 +126,7 @@ public SqlServerMathTranslator(ISqlExpressionFactory sqlExpressionFactory) sqlFunctionName, newArguments, nullable: true, - argumentsPropagateNullability: newArguments.Select(a => true).ToArray(), + argumentsPropagateNullability: newArguments.Select(_ => true).ToArray(), method.ReturnType, sqlFunctionName == "SIGN" ? null : typeMapping); } diff --git a/src/EFCore.Sqlite.Core/Extensions/SqliteServiceCollectionExtensions.cs b/src/EFCore.Sqlite.Core/Extensions/SqliteServiceCollectionExtensions.cs index b622db2a213..ffda8bb98dc 100644 --- a/src/EFCore.Sqlite.Core/Extensions/SqliteServiceCollectionExtensions.cs +++ b/src/EFCore.Sqlite.Core/Extensions/SqliteServiceCollectionExtensions.cs @@ -63,7 +63,7 @@ public static IServiceCollection AddSqlite( Check.NotEmpty(connectionString, nameof(connectionString)); return serviceCollection.AddDbContext( - (serviceProvider, options) => + (_, options) => { optionsAction?.Invoke(options); options.UseSqlite(connectionString, sqliteOptionsAction); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs index 0782ffbfeb5..4edcc6bbca6 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs @@ -14,7 +14,6 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal; public class SqliteByteArrayMethodTranslator : IMethodCallTranslator { private readonly ISqlExpressionFactory _sqlExpressionFactory; - private readonly IRelationalTypeMappingSource _typeMappingSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -22,12 +21,9 @@ public class SqliteByteArrayMethodTranslator : IMethodCallTranslator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public SqliteByteArrayMethodTranslator( - ISqlExpressionFactory sqlExpressionFactory, - IRelationalTypeMappingSource typeMappingSource) + public SqliteByteArrayMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) { _sqlExpressionFactory = sqlExpressionFactory; - _typeMappingSource = typeMappingSource; } /// diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs index c8cf768eba1..37140f8b297 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteCharMethodTranslator.cs @@ -50,7 +50,7 @@ public SqliteCharMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) sqlFunctionName, arguments, nullable: true, - argumentsPropagateNullability: arguments.Select(a => true).ToList(), + argumentsPropagateNullability: arguments.Select(_ => true).ToList(), method.ReturnType, arguments[0].TypeMapping); } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs index bea50787c7b..9cb150812ce 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs @@ -53,7 +53,7 @@ public static SqlFunctionExpression Strftime( "strftime", finalArguments, nullable: true, - argumentsPropagateNullability: finalArguments.Select(a => true), + argumentsPropagateNullability: finalArguments.Select(_ => true), returnType, typeMapping); } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs index 08405a6283d..ca718cc4799 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs @@ -98,7 +98,7 @@ public SqliteMathTranslator(ISqlExpressionFactory sqlExpressionFactory) sqlFunctionName, finalArguments, nullable: true, - argumentsPropagateNullability: finalArguments.Select(a => true).ToList(), + argumentsPropagateNullability: finalArguments.Select(_ => true).ToList(), method.ReturnType, typeMapping); } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMethodCallTranslatorProvider.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMethodCallTranslatorProvider.cs index cd82b00c823..f8c4233c6b3 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMethodCallTranslatorProvider.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMethodCallTranslatorProvider.cs @@ -25,7 +25,7 @@ public SqliteMethodCallTranslatorProvider(RelationalMethodCallTranslatorProvider AddTranslators( new IMethodCallTranslator[] { - new SqliteByteArrayMethodTranslator(sqlExpressionFactory, dependencies.RelationalTypeMappingSource), + new SqliteByteArrayMethodTranslator(sqlExpressionFactory), new SqliteCharMethodTranslator(sqlExpressionFactory), new SqliteDateTimeAddTranslator(sqlExpressionFactory), new SqliteGlobMethodTranslator(sqlExpressionFactory), diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs index 94ce300de10..9c6e9353e13 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs @@ -446,7 +446,7 @@ private string EscapeLikePattern(string pattern) functionName, sqlArguments, nullable: true, - argumentsPropagateNullability: sqlArguments.Select(a => true).ToList(), + argumentsPropagateNullability: sqlArguments.Select(_ => true).ToList(), typeof(string), typeMapping); } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteSubstrMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteSubstrMethodTranslator.cs index ea579a6193a..71e06a605e1 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteSubstrMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteSubstrMethodTranslator.cs @@ -52,7 +52,7 @@ public SqliteSubstrMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) "substr", arguments.Skip(1), nullable: true, - arguments.Skip(1).Select(a => true).ToArray(), + arguments.Skip(1).Select(_ => true).ToArray(), typeof(byte[]), arguments[1].TypeMapping); } diff --git a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs index e697d9ec4d4..937b9417b76 100644 --- a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs +++ b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs @@ -341,7 +341,7 @@ private void SetEntityState(EntityState oldState, EntityState newState, bool acc FireStateChanged(oldState); - HandleSharedIdentityEntry(oldState, newState, entityType); + HandleSharedIdentityEntry(newState); if ((newState == EntityState.Deleted || newState == EntityState.Detached) @@ -352,7 +352,7 @@ private void SetEntityState(EntityState oldState, EntityState newState, bool acc } } - private void HandleSharedIdentityEntry(EntityState oldState, EntityState newState, IEntityType entityType) + private void HandleSharedIdentityEntry(EntityState newState) { var sharedIdentityEntry = SharedIdentityEntry; if (sharedIdentityEntry == null) diff --git a/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory`.cs b/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory`.cs index 38aeef54e39..756a5a70d31 100644 --- a/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory`.cs +++ b/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory`.cs @@ -21,7 +21,7 @@ public virtual Func Create(IEntityType entityType) { if (GetPropertyCount(entityType) == 0) { - return e => Snapshot.Empty; + return _ => Snapshot.Empty; } var parameter = Expression.Parameter(typeof(TInput), "source"); diff --git a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs index 2dc8b7b37e9..887b60cb503 100644 --- a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs +++ b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs @@ -78,7 +78,7 @@ public virtual void Generate(InternalEntityEntry entry, bool includePrimaryKey = continue; } - var valueGenerator = GetValueGenerator(entry, property); + var valueGenerator = GetValueGenerator(property); var generatedValue = valueGenerator.Next(entityEntry); var temporary = valueGenerator.GeneratesTemporaryValues; @@ -125,7 +125,7 @@ public virtual async Task GenerateAsync( continue; } - var valueGenerator = GetValueGenerator(entry, property); + var valueGenerator = GetValueGenerator(property); var generatedValue = await valueGenerator.NextAsync(entityEntry, cancellationToken) .ConfigureAwait(false); var temporary = valueGenerator.GeneratesTemporaryValues; @@ -142,7 +142,7 @@ public virtual async Task GenerateAsync( } } - private ValueGenerator GetValueGenerator(InternalEntityEntry entry, IProperty property) + private ValueGenerator GetValueGenerator(IProperty property) => _valueGeneratorSelector.Select(property, property.DeclaringEntityType); /// diff --git a/src/EFCore/DbContextOptionsBuilder.cs b/src/EFCore/DbContextOptionsBuilder.cs index 9634d531699..a7ac734643f 100644 --- a/src/EFCore/DbContextOptionsBuilder.cs +++ b/src/EFCore/DbContextOptionsBuilder.cs @@ -122,7 +122,7 @@ public virtual DbContextOptionsBuilder LogTo( Action action, LogLevel minimumLevel = LogLevel.Debug, DbContextLoggerOptions? options = null) - => LogTo(action, (i, l) => l >= minimumLevel, options); + => LogTo(action, (_, l) => l >= minimumLevel, options); /// /// Logs the specified events using the supplied action. For example, use diff --git a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs index d107ec8e79f..a72d7aec15b 100644 --- a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs +++ b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs @@ -573,7 +573,7 @@ public static void SensitiveDataLoggingEnabledWarning( { var eventData = new EventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage()); + (d, _) => ((EventDefinition)d).GenerateMessage()); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); } @@ -750,7 +750,7 @@ public static void ServiceProviderCreated( { var eventData = new ServiceProviderEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), serviceProvider); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); @@ -777,7 +777,7 @@ public static void ManyServiceProvidersCreatedWarning( { var eventData = new ServiceProvidersEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), serviceProviders); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); @@ -1101,7 +1101,7 @@ public static void RedundantAddServicesCallWarning( { var eventData = new ServiceProviderEventData( definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), + (d, _) => ((EventDefinition)d).GenerateMessage(), serviceProvider); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); diff --git a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs index 9100f1c5b7c..6a21dca25f1 100644 --- a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs +++ b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs @@ -115,7 +115,7 @@ public static IServiceCollection AddDbContext optionsAction(b), contextLifetime, optionsLifetime); + : (_, b) => optionsAction(b), contextLifetime, optionsLifetime); /// /// Registers the given as a service in the , @@ -738,7 +738,7 @@ public static IServiceCollection AddDbContextFactory( serviceCollection, optionsAction == null ? null - : (p, b) => optionsAction(b), + : (_, b) => optionsAction(b), lifetime); /// diff --git a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs index 163e30a4a89..b48aa3f67bd 100644 --- a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs +++ b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs @@ -289,7 +289,7 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices() TryAdd(); TryAdd(); TryAdd(); - TryAdd(p => new MemoryCache(new MemoryCacheOptions { SizeLimit = 10240 })); + TryAdd(_ => new MemoryCache(new MemoryCacheOptions { SizeLimit = 10240 })); TryAdd(); TryAdd(); TryAdd(); @@ -302,7 +302,7 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices() // This has to be lazy to avoid creating instances that are not disposed ServiceCollectionMap - .TryAddSingleton(p => new DiagnosticListener(DbLoggerCategory.Name)); + .TryAddSingleton(_ => new DiagnosticListener(DbLoggerCategory.Name)); ServiceCollectionMap.GetInfrastructure() .AddDependencySingleton() diff --git a/src/EFCore/Internal/ServiceProviderCache.cs b/src/EFCore/Internal/ServiceProviderCache.cs index 488d9604c34..837c62d936c 100644 --- a/src/EFCore/Internal/ServiceProviderCache.cs +++ b/src/EFCore/Internal/ServiceProviderCache.cs @@ -76,7 +76,7 @@ public virtual IServiceProvider GetOrAdd(IDbContextOptions options, bool provide optionsExtension.Info.PopulateDebugInfo(debugInfo); } - debugInfo = debugInfo.OrderBy(v => debugInfo.Keys).ToDictionary(d => d.Key, v => v.Value); + debugInfo = debugInfo.OrderBy(_ => debugInfo.Keys).ToDictionary(d => d.Key, v => v.Value); var services = new ServiceCollection(); var hasProvider = ApplyServices(options, services); diff --git a/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs index 00651db6a31..0673f17b251 100644 --- a/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs @@ -45,12 +45,11 @@ public virtual void ProcessEntityTypeAdded( Check.DebugAssert( entityType.GetDeclaredForeignKeys().FirstOrDefault(fk => fk.IsOwnership) == null, "Ownerships present on non-owned entity type"); - ProcessEntityType(entityTypeBuilder, context); + ProcessEntityType(entityTypeBuilder); } private static void ProcessEntityType( - IConventionEntityTypeBuilder entityTypeBuilder, - IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder) { var entityType = entityTypeBuilder.Metadata; var model = entityType.Model; @@ -127,7 +126,7 @@ public virtual void ProcessForeignKeyRemoved( if (foreignKey.IsOwnership && !entityTypeBuilder.Metadata.IsOwned()) { - ProcessEntityType(entityTypeBuilder, context); + ProcessEntityType(entityTypeBuilder); } } } diff --git a/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs b/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs index 5aa66277ffb..eeff662fc76 100644 --- a/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs +++ b/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs @@ -30,13 +30,12 @@ public virtual void ProcessModelFinalizing( IConventionModelBuilder modelBuilder, IConventionContext context) { - RemoveEntityTypesUnreachableByNavigations(modelBuilder, context); + RemoveEntityTypesUnreachableByNavigations(modelBuilder); RemoveNavigationlessForeignKeys(modelBuilder); } private static void RemoveEntityTypesUnreachableByNavigations( - IConventionModelBuilder modelBuilder, - IConventionContext context) + IConventionModelBuilder modelBuilder) { var model = modelBuilder.Metadata; var rootEntityTypes = GetRoots(model, ConfigurationSource.DataAnnotation); diff --git a/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs b/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs index b76689ed7b1..e4e7b7e1143 100644 --- a/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs +++ b/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs @@ -305,7 +305,7 @@ protected static IEnumerable GetAttributes( IConventionEntityType entityType, IConventionNavigation navigation) where TCustomAttribute : Attribute - => GetAttributes(entityType, navigation.GetIdentifyingMemberInfo()); + => GetAttributes(navigation.GetIdentifyingMemberInfo()); /// /// Returns the attributes applied to the given skip navigation. @@ -318,11 +318,9 @@ protected static IEnumerable GetAttributes( IConventionEntityType entityType, IConventionSkipNavigation skipNavigation) where TCustomAttribute : Attribute - => GetAttributes(entityType, skipNavigation.GetIdentifyingMemberInfo()); + => GetAttributes(skipNavigation.GetIdentifyingMemberInfo()); - private static IEnumerable GetAttributes( - IConventionEntityType entityType, - MemberInfo? memberInfo) + private static IEnumerable GetAttributes(MemberInfo? memberInfo) where TCustomAttribute : Attribute { if (memberInfo == null) diff --git a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs index aabc82f6257..d99e0c360d6 100644 --- a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs @@ -75,7 +75,7 @@ private IReadOnlyList FindRelationshipCandidates( if (entityType.FindNavigation(navigationPropertyInfo) == null && entityType.FindSkipNavigation(navigationPropertyInfo) == null - && (!IsCandidateNavigationProperty(entityType, targetClrType, navigationPropertyInfo.GetSimpleMemberName(), navigationPropertyInfo) + && (!IsCandidateNavigationProperty(entityType, navigationPropertyInfo.GetSimpleMemberName(), navigationPropertyInfo) || IsNewSharedType(targetClrType, entityType))) { continue; @@ -195,7 +195,7 @@ private IReadOnlyList FindRelationshipCandidates( || (candidateTargetEntityType.FindNavigation(inversePropertyInfo) == null && candidateTargetEntityType.FindSkipNavigation(inversePropertyInfo) == null && !IsCandidateNavigationProperty( - candidateTargetEntityType, entityType.ClrType, inversePropertyInfo.GetSimpleMemberName(), inversePropertyInfo))) + candidateTargetEntityType, inversePropertyInfo.GetSimpleMemberName(), inversePropertyInfo))) { continue; } @@ -1084,7 +1084,7 @@ public virtual void ProcessNavigationRemoved( || !sourceEntityTypeBuilder.ModelBuilder.IsIgnored(targetEntityTypeBuilder.Metadata.Name)) && memberInfo != null && IsCandidateNavigationProperty( - sourceEntityTypeBuilder.Metadata, targetEntityTypeBuilder.Metadata.ClrType, navigationName, memberInfo) + sourceEntityTypeBuilder.Metadata, navigationName, memberInfo) && Dependencies.MemberClassifier.FindCandidateNavigationPropertyType( memberInfo, targetEntityTypeBuilder.Metadata.Model, out _) != null) @@ -1114,7 +1114,6 @@ private void Process( private bool IsCandidateNavigationProperty( IConventionEntityType sourceEntityType, - Type targetClrType, string navigationName, MemberInfo memberInfo) => sourceEntityType.Builder?.IsIgnored(navigationName) == false diff --git a/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs b/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs index ba8a4288beb..755e20eda87 100644 --- a/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs @@ -355,7 +355,7 @@ public virtual bool CanSetAfterSave(PropertySaveBehavior? behavior, Configuratio } return HasValueGenerator( - (_, __) + (_, _) => { try diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs index bf4908a6c47..5bbc36a4960 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs @@ -625,8 +625,7 @@ when QueryableMethods.IsSumWithSelector(method): return ProcessOrderByThenBy( groupBySource, genericMethod, - methodCallExpression.Arguments[1].UnwrapLambdaFromQuote(), - thenBy: false); + methodCallExpression.Arguments[1].UnwrapLambdaFromQuote()); case nameof(Queryable.ThenBy) when genericMethod == QueryableMethods.ThenBy: @@ -635,8 +634,7 @@ when QueryableMethods.IsSumWithSelector(method): return ProcessOrderByThenBy( groupBySource, genericMethod, - methodCallExpression.Arguments[1].UnwrapLambdaFromQuote(), - thenBy: true); + methodCallExpression.Arguments[1].UnwrapLambdaFromQuote()); case nameof(Queryable.Select) when genericMethod == QueryableMethods.Select: @@ -1433,8 +1431,7 @@ private Expression ProcessAllAnyCountLongCount( private GroupByNavigationExpansionExpression ProcessOrderByThenBy( GroupByNavigationExpansionExpression groupBySource, MethodInfo genericMethod, - LambdaExpression keySelector, - bool thenBy) + LambdaExpression keySelector) { keySelector = ProcessLambdaExpression(groupBySource, keySelector); diff --git a/src/EFCore/Storage/ExecutionStrategyExtensions.cs b/src/EFCore/Storage/ExecutionStrategyExtensions.cs index 12b3d912c69..fa460b68a9f 100644 --- a/src/EFCore/Storage/ExecutionStrategyExtensions.cs +++ b/src/EFCore/Storage/ExecutionStrategyExtensions.cs @@ -106,7 +106,7 @@ public static Task ExecuteAsync( Check.NotNull(operation, nameof(operation)); return strategy.ExecuteAsync( - operation, async (operationScoped, ct) => + operation, async (operationScoped, _) => { await operationScoped().ConfigureAwait(false); return true; @@ -172,7 +172,7 @@ public static Task ExecuteAsync( { Check.NotNull(operation, nameof(operation)); - return strategy.ExecuteAsync(operation, (operationScoped, ct) => operationScoped(), default); + return strategy.ExecuteAsync(operation, (operationScoped, _) => operationScoped(), default); } /// @@ -233,7 +233,7 @@ public static Task ExecuteAsync( Check.NotNull(operation, nameof(operation)); return strategy.ExecuteAsync( - new { operation, state }, async (t, ct) => + new { operation, state }, async (t, _) => { await t.operation(t.state).ConfigureAwait(false); return true; @@ -306,7 +306,7 @@ public static Task ExecuteAsync( Check.NotNull(operation, nameof(operation)); return strategy.ExecuteAsync( - new { operation, state }, (t, ct) => t.operation(t.state), default); + new { operation, state }, (t, _) => t.operation(t.state), default); } /// @@ -389,8 +389,8 @@ public static TResult Execute( Func>? verifySucceeded) => strategy.Execute( state, - (c, s) => operation(s), - verifySucceeded == null ? null : (c, s) => verifySucceeded(s)); + (_, s) => operation(s), + verifySucceeded == null ? null : (_, s) => verifySucceeded(s)); /// /// Executes the specified asynchronous operation and returns the result. @@ -428,10 +428,10 @@ public static Task ExecuteAsync( CancellationToken cancellationToken = default) => strategy.ExecuteAsync( state, - (c, s, ct) => operation(s, ct), + (_, s, ct) => operation(s, ct), verifySucceeded == null ? null - : (c, s, ct) => verifySucceeded(s, ct), cancellationToken); + : (_, s, ct) => verifySucceeded(s, ct), cancellationToken); /// /// Executes the specified operation in a transaction. Allows to check whether @@ -456,7 +456,7 @@ public static void ExecuteInTransaction( this IExecutionStrategy strategy, Action operation, Func verifySucceeded) - => strategy.ExecuteInTransaction(null, s => operation(), s => verifySucceeded()); + => strategy.ExecuteInTransaction(null, _ => operation(), _ => verifySucceeded()); /// /// Executes the specified asynchronous operation in a transaction. Allows to check whether @@ -486,7 +486,7 @@ public static Task ExecuteInTransactionAsync( this IExecutionStrategy strategy, Func operation, Func> verifySucceeded) - => strategy.ExecuteInTransactionAsync(null, (s, ct) => operation(), (s, ct) => verifySucceeded()); + => strategy.ExecuteInTransactionAsync(null, (_, _) => operation(), (_, _) => verifySucceeded()); /// /// Executes the specified asynchronous operation in a transaction. Allows to check whether @@ -523,7 +523,7 @@ public static Task ExecuteInTransactionAsync( Func> verifySucceeded, CancellationToken cancellationToken = default) => strategy.ExecuteInTransactionAsync( - null, (s, ct) => operation(ct), (s, ct) => verifySucceeded(ct), cancellationToken); + null, (_, ct) => operation(ct), (_, ct) => verifySucceeded(ct), cancellationToken); /// /// Executes the specified operation in a transaction and returns the result. Allows to check whether @@ -550,7 +550,7 @@ public static TResult ExecuteInTransaction( this IExecutionStrategy strategy, Func operation, Func verifySucceeded) - => strategy.ExecuteInTransaction(null, s => operation(), s => verifySucceeded()); + => strategy.ExecuteInTransaction(null, _ => operation(), _ => verifySucceeded()); /// /// Executes the specified asynchronous operation in a transaction and returns the result. Allows to check whether @@ -588,7 +588,7 @@ public static Task ExecuteInTransactionAsync( Func> verifySucceeded, CancellationToken cancellationToken = default) => strategy.ExecuteInTransactionAsync( - null, (s, ct) => operation(ct), (s, ct) => verifySucceeded(ct), cancellationToken); + null, (_, ct) => operation(ct), (_, ct) => verifySucceeded(ct), cancellationToken); /// /// Executes the specified operation in a transaction. Allows to check whether @@ -789,7 +789,7 @@ public static TResult ExecuteInTransaction( } return s.Result; - }, (c, s) => new ExecutionResult(s.CommitFailed && s.VerifySucceeded(s.State), s.Result)); + }, (_, s) => new ExecutionResult(s.CommitFailed && s.VerifySucceeded(s.State), s.Result)); /// /// Executes the specified asynchronous operation in a transaction and returns the result. Allows to check whether @@ -846,7 +846,7 @@ public static Task ExecuteInTransactionAsync( } return s.Result; - }, async (c, s, ct) => new ExecutionResult( + }, async (_, s, ct) => new ExecutionResult( s.CommitFailed && await s.VerifySucceeded(s.State, ct).ConfigureAwait(false), s.Result), cancellationToken); diff --git a/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs b/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs index d6ddd271c4b..87f089965e1 100644 --- a/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs +++ b/src/EFCore/Storage/ValueConversion/GuidToBytesConverter.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Storage.ValueConversion; public class GuidToBytesConverter : ValueConverter { private static readonly ConverterMappingHints _defaultHints - = new(size: 16, valueGeneratorFactory: (p, t) => new SequentialGuidValueGenerator()); + = new(size: 16, valueGeneratorFactory: (_, _) => new SequentialGuidValueGenerator()); /// /// Creates a new instance of this converter. diff --git a/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs b/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs index 7f6f249d420..a6e2fe71f17 100644 --- a/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs +++ b/src/EFCore/Storage/ValueConversion/Internal/StringGuidConverter.cs @@ -19,7 +19,7 @@ public class StringGuidConverter : ValueConverter // ReSharper disable once StaticMemberInGenericType protected static readonly ConverterMappingHints DefaultHints - = new(size: 36, valueGeneratorFactory: (p, t) => new SequentialGuidValueGenerator()); + = new(size: 36, valueGeneratorFactory: (_, _) => new SequentialGuidValueGenerator()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs b/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs index eebdeeb9484..e3d8610d625 100644 --- a/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs +++ b/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs @@ -119,7 +119,7 @@ public virtual IEnumerable Select( static k => new ValueConverterInfo( k.ModelClrType, typeof(byte[]), - info => new BoolToZeroOneConverter().ComposeWith( + _ => new BoolToZeroOneConverter().ComposeWith( NumberToBytesConverter.DefaultInfo.Create()), new ConverterMappingHints(size: 1))); } @@ -138,7 +138,7 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(string)), - k => GuidToStringConverter.DefaultInfo); + _ => GuidToStringConverter.DefaultInfo); } if (providerClrType == null @@ -146,7 +146,7 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(byte[])), - k => GuidToBytesConverter.DefaultInfo); + _ => GuidToBytesConverter.DefaultInfo); } } else if (modelClrType == typeof(byte[])) @@ -156,7 +156,7 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(string)), - k => BytesToStringConverter.DefaultInfo); + _ => BytesToStringConverter.DefaultInfo); } } else if (modelClrType == typeof(Uri)) @@ -166,7 +166,7 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(string)), - k => UriToStringConverter.DefaultInfo); + _ => UriToStringConverter.DefaultInfo); } } else if (modelClrType == typeof(string)) @@ -176,7 +176,7 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(byte[])), - k => StringToBytesConverter.DefaultInfo); + _ => StringToBytesConverter.DefaultInfo); } else if (providerClrType.IsEnum) { @@ -199,43 +199,43 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(DateTime)), - k => StringToDateTimeConverter.DefaultInfo); + _ => StringToDateTimeConverter.DefaultInfo); } else if (providerClrType == typeof(DateTimeOffset)) { yield return _converters.GetOrAdd( (modelClrType, typeof(DateTimeOffset)), - k => StringToDateTimeOffsetConverter.DefaultInfo); + _ => StringToDateTimeOffsetConverter.DefaultInfo); } else if (providerClrType == typeof(TimeSpan)) { yield return _converters.GetOrAdd( (modelClrType, typeof(TimeSpan)), - k => StringToTimeSpanConverter.DefaultInfo); + _ => StringToTimeSpanConverter.DefaultInfo); } else if (providerClrType == typeof(Guid)) { yield return _converters.GetOrAdd( (modelClrType, typeof(Guid)), - k => StringToGuidConverter.DefaultInfo); + _ => StringToGuidConverter.DefaultInfo); } else if (providerClrType == typeof(bool)) { yield return _converters.GetOrAdd( (modelClrType, typeof(bool)), - k => StringToBoolConverter.DefaultInfo); + _ => StringToBoolConverter.DefaultInfo); } else if (providerClrType == typeof(char)) { yield return _converters.GetOrAdd( (modelClrType, typeof(char)), - k => StringToCharConverter.DefaultInfo); + _ => StringToCharConverter.DefaultInfo); } else if (providerClrType == typeof(Uri)) { yield return _converters.GetOrAdd( (modelClrType, typeof(Uri)), - k => StringToUriConverter.DefaultInfo); + _ => StringToUriConverter.DefaultInfo); } } else if (modelClrType == typeof(DateTime) @@ -272,7 +272,7 @@ public virtual IEnumerable Select( yield return modelClrType == typeof(DateTimeOffset) ? _converters.GetOrAdd( (modelClrType, typeof(byte[])), - k => DateTimeOffsetToBytesConverter.DefaultInfo) + _ => DateTimeOffsetToBytesConverter.DefaultInfo) : _converters.GetOrAdd( (modelClrType, typeof(byte[])), static k => new ValueConverterInfo( @@ -293,14 +293,14 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(string)), - k => IPAddressToStringConverter.DefaultInfo); + _ => IPAddressToStringConverter.DefaultInfo); } if (providerClrType == typeof(byte[])) { yield return _converters.GetOrAdd( (modelClrType, typeof(byte[])), - k => IPAddressToBytesConverter.DefaultInfo); + _ => IPAddressToBytesConverter.DefaultInfo); } } else if (modelClrType == typeof(PhysicalAddress)) @@ -310,14 +310,14 @@ public virtual IEnumerable Select( { yield return _converters.GetOrAdd( (modelClrType, typeof(string)), - k => PhysicalAddressToStringConverter.DefaultInfo); + _ => PhysicalAddressToStringConverter.DefaultInfo); } if (providerClrType == typeof(byte[])) { yield return _converters.GetOrAdd( (modelClrType, typeof(byte[])), - k => PhysicalAddressToBytesConverter.DefaultInfo); + _ => PhysicalAddressToBytesConverter.DefaultInfo); } } else if (_numerics.Contains(modelClrType) @@ -368,7 +368,7 @@ private IEnumerable CharToBytes( { yield return _converters.GetOrAdd( (underlyingModelType, typeof(byte[])), - k => NumberToBytesConverter.DefaultInfo); + _ => NumberToBytesConverter.DefaultInfo); } } @@ -400,7 +400,7 @@ private IEnumerable EnumToStringOrBytes( return new ValueConverterInfo( k.ModelClrType, typeof(byte[]), - i => toNumber.Create().ComposeWith(toBytes.Create()), + _ => toNumber.Create().ComposeWith(toBytes.Create()), toBytes.MappingHints); }); } diff --git a/src/Shared/EnumerableMethods.cs b/src/Shared/EnumerableMethods.cs index bb0dd4b53a1..55229e46c8e 100644 --- a/src/Shared/EnumerableMethods.cs +++ b/src/Shared/EnumerableMethods.cs @@ -284,7 +284,7 @@ static EnumerableMethods() nameof(Enumerable.AsEnumerable), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) }); - Cast = GetMethod(nameof(Enumerable.Cast), 1, types => new[] { typeof(IEnumerable) }); + Cast = GetMethod(nameof(Enumerable.Cast), 1, _ => new[] { typeof(IEnumerable) }); Concat = GetMethod( nameof(Enumerable.Concat), 1, @@ -435,7 +435,7 @@ static EnumerableMethods() nameof(Enumerable.Min), 2, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) }); - OfType = GetMethod(nameof(Enumerable.OfType), 1, types => new[] { typeof(IEnumerable) }); + OfType = GetMethod(nameof(Enumerable.OfType), 1, _ => new[] { typeof(IEnumerable) }); OrderBy = GetMethod( nameof(Enumerable.OrderBy), 2, @@ -563,12 +563,12 @@ static EnumerableMethods() nameof(Enumerable.Average), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], type) }); MaxWithoutSelectorMethods[type] = GetMethod( - nameof(Enumerable.Max), 0, types => new[] { typeof(IEnumerable<>).MakeGenericType(type) }); + nameof(Enumerable.Max), 0, _ => new[] { typeof(IEnumerable<>).MakeGenericType(type) }); MaxWithSelectorMethods[type] = GetMethod( nameof(Enumerable.Max), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], type) }); MinWithoutSelectorMethods[type] = GetMethod( - nameof(Enumerable.Min), 0, types => new[] { typeof(IEnumerable<>).MakeGenericType(type) }); + nameof(Enumerable.Min), 0, _ => new[] { typeof(IEnumerable<>).MakeGenericType(type) }); MinWithSelectorMethods[type] = GetMethod( nameof(Enumerable.Min), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], type) }); diff --git a/src/ef/CommandLineUtils/CommandLineApplication.cs b/src/ef/CommandLineUtils/CommandLineApplication.cs index 32d4644c01f..65bb79cfffb 100644 --- a/src/ef/CommandLineUtils/CommandLineApplication.cs +++ b/src/ef/CommandLineUtils/CommandLineApplication.cs @@ -34,7 +34,7 @@ public CommandLineApplication(bool throwOnUnexpectedArg = true) Commands = new List(); RemainingArguments = new List(); ApplicationArguments = new List(); - Invoke = args => 0; + Invoke = _ => 0; } public CommandLineApplication? Parent { get; set; } @@ -133,7 +133,7 @@ public int Execute(params string[] args) var isLongOption = arg.StartsWith("--", StringComparison.Ordinal); if (isLongOption || arg.StartsWith("-", StringComparison.Ordinal)) { - var result = ParseOption(isLongOption, command, args, ref index, out var option); + var result = ParseOption(isLongOption, command, args, ref index, out _); if (result == ParseOptionResult.ShowHelp) { command.ShowHelp(); diff --git a/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs b/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs index b9a27931608..68d2d8acb27 100644 --- a/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs +++ b/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs @@ -15,10 +15,9 @@ public FakeScaffoldingModelFactory( IPluralizer pluralizer, ICSharpUtilities cSharpUtilities, IScaffoldingTypeMapper scaffoldingTypeMapper, - LoggingDefinitions loggingDefinitions, IModelRuntimeInitializer modelRuntimeInitializer) : base( - reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, loggingDefinitions, + reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, modelRuntimeInitializer) { }