diff --git a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs index 488c5e2771d..f5909b97590 100644 --- a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs +++ b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Design.Internal { @@ -285,9 +284,6 @@ public override IReadOnlyList GenerateFluentApiCalls( /// protected override bool IsHandledByConvention(IModel model, IAnnotation annotation) { - Check.NotNull(model, nameof(model)); - Check.NotNull(annotation, nameof(annotation)); - if (annotation.Name == RelationalAnnotationNames.DefaultSchema) { return (string?)annotation.Value == "dbo"; diff --git a/src/EFCore.SqlServer/Design/Internal/SqlServerDesignTimeServices.cs b/src/EFCore.SqlServer/Design/Internal/SqlServerDesignTimeServices.cs index 9e8e5f98c9e..43e33f7378c 100644 --- a/src/EFCore.SqlServer/Design/Internal/SqlServerDesignTimeServices.cs +++ b/src/EFCore.SqlServer/Design/Internal/SqlServerDesignTimeServices.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.Design.Internal; using Microsoft.EntityFrameworkCore.Scaffolding; using Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; [assembly: DesignTimeProviderServices("Microsoft.EntityFrameworkCore.SqlServer.Design.Internal.SqlServerDesignTimeServices")] @@ -28,9 +27,8 @@ public class SqlServerDesignTimeServices : IDesignTimeServices /// public virtual void ConfigureDesignTimeServices(IServiceCollection serviceCollection) { - Check.NotNull(serviceCollection, nameof(serviceCollection)); - serviceCollection.AddEntityFrameworkSqlServer(); + #pragma warning disable EF1001 // Internal EF Core API usage. new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection) .TryAdd() diff --git a/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs index 60b1184edf9..8c1853ca2bc 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs @@ -44,8 +44,6 @@ public static DbContextOptionsBuilder UseSqlServer( this DbContextOptionsBuilder optionsBuilder, Action? sqlServerOptionsAction = null) { - Check.NotNull(optionsBuilder, nameof(optionsBuilder)); - ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(GetOrCreateExtension(optionsBuilder)); ConfigureWarnings(optionsBuilder); @@ -72,7 +70,6 @@ public static DbContextOptionsBuilder UseSqlServer( string connectionString, Action? sqlServerOptionsAction = null) { - Check.NotNull(optionsBuilder, nameof(optionsBuilder)); Check.NotEmpty(connectionString, nameof(connectionString)); var extension = (SqlServerOptionsExtension)GetOrCreateExtension(optionsBuilder).WithConnectionString(connectionString); @@ -107,7 +104,6 @@ public static DbContextOptionsBuilder UseSqlServer( DbConnection connection, Action? sqlServerOptionsAction = null) { - Check.NotNull(optionsBuilder, nameof(optionsBuilder)); Check.NotNull(connection, nameof(connection)); var extension = (SqlServerOptionsExtension)GetOrCreateExtension(optionsBuilder).WithConnection(connection); diff --git a/src/EFCore.SqlServer/Extensions/SqlServerDbSetExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerDbSetExtensions.cs index e44c573ae30..e95970ab3a3 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerDbSetExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerDbSetExtensions.cs @@ -5,7 +5,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.SqlServer.Query.Internal; -using Microsoft.EntityFrameworkCore.Utilities; // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore @@ -40,8 +39,6 @@ public static IQueryable TemporalAsOf( DateTime utcPointInTime) where TEntity : class { - Check.NotNull(source, nameof(source)); - var queryableSource = (IQueryable)source; var queryRootExpression = (QueryRootExpression)queryableSource.Expression; var entityType = queryRootExpression.EntityType; @@ -88,8 +85,6 @@ public static IQueryable TemporalFromTo( DateTime utcTo) where TEntity : class { - Check.NotNull(source, nameof(source)); - var queryableSource = (IQueryable)source; var queryRootExpression = (QueryRootExpression)queryableSource.Expression; var entityType = queryRootExpression.EntityType; @@ -137,8 +132,6 @@ public static IQueryable TemporalBetween( DateTime utcTo) where TEntity : class { - Check.NotNull(source, nameof(source)); - var queryableSource = (IQueryable)source; var queryRootExpression = (QueryRootExpression)queryableSource.Expression; var entityType = queryRootExpression.EntityType; @@ -186,8 +179,6 @@ public static IQueryable TemporalContainedIn( DateTime utcTo) where TEntity : class { - Check.NotNull(source, nameof(source)); - var queryableSource = (IQueryable)source; var queryRootExpression = (QueryRootExpression)queryableSource.Expression; var entityType = queryRootExpression.EntityType; @@ -219,8 +210,6 @@ public static IQueryable TemporalAll( this DbSet source) where TEntity : class { - Check.NotNull(source, nameof(source)); - var queryableSource = (IQueryable)source; var queryRootExpression = (QueryRootExpression)queryableSource.Expression; var entityType = queryRootExpression.EntityType; diff --git a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs index d6a2cc878f1..d9f58b8e6f1 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs @@ -32,8 +32,6 @@ public static EntityTypeBuilder IsMemoryOptimized( this EntityTypeBuilder entityTypeBuilder, bool memoryOptimized = true) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - entityTypeBuilder.Metadata.SetIsMemoryOptimized(memoryOptimized); return entityTypeBuilder; @@ -70,8 +68,6 @@ public static OwnedNavigationBuilder IsMemoryOptimized( this OwnedNavigationBuilder collectionOwnershipBuilder, bool memoryOptimized = true) { - Check.NotNull(collectionOwnershipBuilder, nameof(collectionOwnershipBuilder)); - collectionOwnershipBuilder.OwnedEntityType.SetIsMemoryOptimized(memoryOptimized); return collectionOwnershipBuilder; @@ -140,11 +136,7 @@ public static bool CanSetIsMemoryOptimized( this IConventionEntityTypeBuilder entityTypeBuilder, bool? memoryOptimized, bool fromDataAnnotation = false) - { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - - return entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.MemoryOptimized, memoryOptimized, fromDataAnnotation); - } + => entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.MemoryOptimized, memoryOptimized, fromDataAnnotation); /// /// Configures the table as temporal. @@ -190,11 +182,7 @@ public static bool CanSetIsTemporal( this IConventionEntityTypeBuilder entityTypeBuilder, bool temporal = true, bool fromDataAnnotation = false) - { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - - return entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.IsTemporal, temporal, fromDataAnnotation); - } + => entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.IsTemporal, temporal, fromDataAnnotation); /// /// Configures a history table name for the entity mapped to a temporal table. @@ -241,7 +229,6 @@ public static bool CanSetHistoryTableName( string name, bool fromDataAnnotation = false) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NotNull(name, nameof(name)); return entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.TemporalHistoryTableName, name, fromDataAnnotation); @@ -291,11 +278,7 @@ public static bool CanSetHistoryTableSchema( this IConventionEntityTypeBuilder entityTypeBuilder, string? schema, bool fromDataAnnotation = false) - { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - - return entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.TemporalHistoryTableSchema, schema, fromDataAnnotation); - } + => entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.TemporalHistoryTableSchema, schema, fromDataAnnotation); /// /// Configures a period start property for the entity mapped to a temporal table. @@ -341,12 +324,8 @@ public static bool CanSetPeriodStart( this IConventionEntityTypeBuilder entityTypeBuilder, string? propertyName, bool fromDataAnnotation = false) - { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - - return entityTypeBuilder.CanSetAnnotation( + => entityTypeBuilder.CanSetAnnotation( SqlServerAnnotationNames.TemporalPeriodStartPropertyName, propertyName, fromDataAnnotation); - } /// /// Configures a period end property for the entity mapped to a temporal table. @@ -392,11 +371,7 @@ public static bool CanSetPeriodEnd( this IConventionEntityTypeBuilder entityTypeBuilder, string? propertyName, bool fromDataAnnotation = false) - { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - - return entityTypeBuilder.CanSetAnnotation( + => entityTypeBuilder.CanSetAnnotation( SqlServerAnnotationNames.TemporalPeriodEndPropertyName, propertyName, fromDataAnnotation); - } } } diff --git a/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs index 08b4f5060dd..111d321e84e 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs @@ -38,8 +38,6 @@ public static class SqlServerIndexBuilderExtensions /// A builder to further configure the index. public static IndexBuilder IsClustered(this IndexBuilder indexBuilder, bool clustered = true) { - Check.NotNull(indexBuilder, nameof(indexBuilder)); - indexBuilder.Metadata.SetIsClustered(clustered); return indexBuilder; @@ -106,11 +104,7 @@ public static bool CanSetIsClustered( this IConventionIndexBuilder indexBuilder, bool? clustered, bool fromDataAnnotation = false) - { - Check.NotNull(indexBuilder, nameof(indexBuilder)); - - return indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.Clustered, clustered, fromDataAnnotation); - } + => indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.Clustered, clustered, fromDataAnnotation); /// /// Configures index include properties when targeting SQL Server. @@ -125,7 +119,6 @@ public static bool CanSetIsClustered( /// A builder to further configure the index. public static IndexBuilder IncludeProperties(this IndexBuilder indexBuilder, params string[] propertyNames) { - Check.NotNull(indexBuilder, nameof(indexBuilder)); Check.NotNull(propertyNames, nameof(propertyNames)); indexBuilder.Metadata.SetIncludeProperties(propertyNames); @@ -148,7 +141,6 @@ public static IndexBuilder IncludeProperties( this IndexBuilder indexBuilder, params string[] propertyNames) { - Check.NotNull(indexBuilder, nameof(indexBuilder)); Check.NotNull(propertyNames, nameof(propertyNames)); indexBuilder.Metadata.SetIncludeProperties(propertyNames); @@ -180,7 +172,6 @@ public static IndexBuilder IncludeProperties( this IndexBuilder indexBuilder, Expression> includeExpression) { - Check.NotNull(indexBuilder, nameof(indexBuilder)); Check.NotNull(includeExpression, nameof(includeExpression)); IncludeProperties( @@ -236,15 +227,11 @@ public static bool CanSetIncludeProperties( this IConventionIndexBuilder indexBuilder, IReadOnlyList? propertyNames, bool fromDataAnnotation = false) - { - Check.NotNull(indexBuilder, nameof(indexBuilder)); - - return (fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention) + => (fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention) .Overrides(indexBuilder.Metadata.GetIncludePropertiesConfigurationSource()) || indexBuilder.Metadata.GetIncludeProperties() is var currentProperties && ((propertyNames is null && currentProperties is null) || (propertyNames is not null && currentProperties is not null && propertyNames.SequenceEqual(currentProperties))); - } /// /// Configures whether the index is created with online option when targeting SQL Server. @@ -259,8 +246,6 @@ public static bool CanSetIncludeProperties( /// A builder to further configure the index. public static IndexBuilder IsCreatedOnline(this IndexBuilder indexBuilder, bool createdOnline = true) { - Check.NotNull(indexBuilder, nameof(indexBuilder)); - indexBuilder.Metadata.SetIsCreatedOnline(createdOnline); return indexBuilder; @@ -332,11 +317,7 @@ public static bool CanSetIsCreatedOnline( this IConventionIndexBuilder indexBuilder, bool? createdOnline, bool fromDataAnnotation = false) - { - Check.NotNull(indexBuilder, nameof(indexBuilder)); - - return indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.CreatedOnline, createdOnline, fromDataAnnotation); - } + => indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.CreatedOnline, createdOnline, fromDataAnnotation); /// /// Configures whether the index is created with fill factor option when targeting SQL Server. @@ -351,8 +332,6 @@ public static bool CanSetIsCreatedOnline( /// A builder to further configure the index. public static IndexBuilder HasFillFactor(this IndexBuilder indexBuilder, int fillFactor) { - Check.NotNull(indexBuilder, nameof(indexBuilder)); - indexBuilder.Metadata.SetFillFactor(fillFactor); return indexBuilder; @@ -420,10 +399,6 @@ public static bool CanSetFillFactor( this IConventionIndexBuilder indexBuilder, int? fillFactor, bool fromDataAnnotation = false) - { - Check.NotNull(indexBuilder, nameof(indexBuilder)); - - return indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.FillFactor, fillFactor, fromDataAnnotation); - } + => indexBuilder.CanSetAnnotation(SqlServerAnnotationNames.FillFactor, fillFactor, fromDataAnnotation); } } diff --git a/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs index 5b3e71c53c4..30953b334f2 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore @@ -31,8 +30,6 @@ public static class SqlServerKeyBuilderExtensions /// The same builder instance so that multiple calls can be chained. public static KeyBuilder IsClustered(this KeyBuilder keyBuilder, bool clustered = true) { - Check.NotNull(keyBuilder, nameof(keyBuilder)); - keyBuilder.Metadata.SetIsClustered(clustered); return keyBuilder; @@ -99,10 +96,6 @@ public static bool CanSetIsClustered( this IConventionKeyBuilder keyBuilder, bool? clustered, bool fromDataAnnotation = false) - { - Check.NotNull(keyBuilder, nameof(keyBuilder)); - - return keyBuilder.CanSetAnnotation(SqlServerAnnotationNames.Clustered, clustered, fromDataAnnotation); - } + => keyBuilder.CanSetAnnotation(SqlServerAnnotationNames.Clustered, clustered, fromDataAnnotation); } } diff --git a/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs index c177c7b4a3c..1c64ab13c7d 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs @@ -37,7 +37,6 @@ public static ModelBuilder UseHiLo( string? name = null, string? schema = null) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullButNotEmpty(name, nameof(name)); Check.NullButNotEmpty(schema, nameof(schema)); @@ -109,7 +108,6 @@ public static bool CanSetHiLoSequence( string? schema, bool fromDataAnnotation = false) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullButNotEmpty(name, nameof(name)); Check.NullButNotEmpty(schema, nameof(schema)); @@ -136,8 +134,6 @@ public static ModelBuilder UseIdentityColumns( long seed = 1, int increment = 1) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - var model = modelBuilder.Model; model.SetValueGenerationStrategy(SqlServerValueGenerationStrategy.IdentityColumn); @@ -214,11 +210,7 @@ public static bool CanSetIdentityColumnSeed( this IConventionModelBuilder modelBuilder, long? seed, bool fromDataAnnotation = false) - { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - - return modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentitySeed, seed, fromDataAnnotation); - } + => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentitySeed, seed, fromDataAnnotation); /// /// Configures the default increment for SQL Server IDENTITY. @@ -265,11 +257,7 @@ public static bool CanSetIdentityColumnIncrement( this IConventionModelBuilder modelBuilder, int? increment, bool fromDataAnnotation = false) - { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - - return modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentityIncrement, increment, fromDataAnnotation); - } + => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentityIncrement, increment, fromDataAnnotation); /// /// Configures the default value generation strategy for key properties marked as , @@ -328,12 +316,8 @@ public static bool CanSetValueGenerationStrategy( this IConventionModelBuilder modelBuilder, SqlServerValueGenerationStrategy? valueGenerationStrategy, bool fromDataAnnotation = false) - { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - - return modelBuilder.CanSetAnnotation( + => modelBuilder.CanSetAnnotation( SqlServerAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation); - } /// /// Configures the maximum size for Azure SQL Database. @@ -353,7 +337,6 @@ public static bool CanSetValueGenerationStrategy( /// The same builder instance so that multiple calls can be chained. public static ModelBuilder HasDatabaseMaxSize(this ModelBuilder modelBuilder, string maxSize) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NotNull(maxSize, nameof(maxSize)); modelBuilder.Model.SetDatabaseMaxSize(maxSize); @@ -411,11 +394,7 @@ public static bool CanSetDatabaseMaxSize( this IConventionModelBuilder modelBuilder, string? maxSize, bool fromDataAnnotation = false) - { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - - return modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.MaxDatabaseSize, maxSize, fromDataAnnotation); - } + => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.MaxDatabaseSize, maxSize, fromDataAnnotation); /// /// Configures the service tier (EDITION) for Azure SQL Database as a string literal. @@ -435,7 +414,6 @@ public static bool CanSetDatabaseMaxSize( /// The same builder instance so that multiple calls can be chained. public static ModelBuilder HasServiceTier(this ModelBuilder modelBuilder, string serviceTier) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NotNull(serviceTier, nameof(serviceTier)); modelBuilder.Model.SetServiceTierSql("'" + serviceTier.Replace("'", "''") + "'"); @@ -461,7 +439,6 @@ public static ModelBuilder HasServiceTier(this ModelBuilder modelBuilder, string /// The same builder instance so that multiple calls can be chained. public static ModelBuilder HasServiceTierSql(this ModelBuilder modelBuilder, string serviceTier) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NotNull(serviceTier, nameof(serviceTier)); modelBuilder.Model.SetServiceTierSql(serviceTier); @@ -519,11 +496,7 @@ public static bool CanSetServiceTierSql( this IConventionModelBuilder modelBuilder, string? serviceTier, bool fromDataAnnotation = false) - { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - - return modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.ServiceTierSql, serviceTier, fromDataAnnotation); - } + => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.ServiceTierSql, serviceTier, fromDataAnnotation); /// /// Configures the performance level (SERVICE_OBJECTIVE) for Azure SQL Database as a string literal. @@ -543,7 +516,6 @@ public static bool CanSetServiceTierSql( /// The same builder instance so that multiple calls can be chained. public static ModelBuilder HasPerformanceLevel(this ModelBuilder modelBuilder, string performanceLevel) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NotNull(performanceLevel, nameof(performanceLevel)); modelBuilder.Model.SetPerformanceLevelSql("'" + performanceLevel.Replace("'", "''") + "'"); @@ -569,7 +541,6 @@ public static ModelBuilder HasPerformanceLevel(this ModelBuilder modelBuilder, s /// The same builder instance so that multiple calls can be chained. public static ModelBuilder HasPerformanceLevelSql(this ModelBuilder modelBuilder, string performanceLevel) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NotNull(performanceLevel, nameof(performanceLevel)); modelBuilder.Model.SetPerformanceLevelSql(performanceLevel); @@ -627,10 +598,6 @@ public static bool CanSetPerformanceLevelSql( this IConventionModelBuilder modelBuilder, string? performanceLevel, bool fromDataAnnotation = false) - { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - - return modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.PerformanceLevelSql, performanceLevel, fromDataAnnotation); - } + => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.PerformanceLevelSql, performanceLevel, fromDataAnnotation); } } diff --git a/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs index dad21c0a469..982b390fa0e 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs @@ -37,7 +37,6 @@ public static PropertyBuilder UseHiLo( string? name = null, string? schema = null) { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); Check.NullButNotEmpty(name, nameof(name)); Check.NullButNotEmpty(schema, nameof(schema)); @@ -133,7 +132,6 @@ public static bool CanSetHiLoSequence( string? schema, bool fromDataAnnotation = false) { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); Check.NullButNotEmpty(name, nameof(name)); Check.NullButNotEmpty(schema, nameof(schema)); @@ -159,8 +157,6 @@ public static PropertyBuilder UseIdentityColumn( long seed = 1, int increment = 1) { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); - var property = propertyBuilder.Metadata; property.SetValueGenerationStrategy(SqlServerValueGenerationStrategy.IdentityColumn); property.SetIdentitySeed(seed); @@ -275,11 +271,7 @@ public static bool CanSetIdentityColumnSeed( this IConventionPropertyBuilder propertyBuilder, long? seed, bool fromDataAnnotation = false) - { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); - - return propertyBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentitySeed, seed, fromDataAnnotation); - } + => propertyBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentitySeed, seed, fromDataAnnotation); /// /// Configures the increment for SQL Server IDENTITY. @@ -326,11 +318,7 @@ public static bool CanSetIdentityColumnIncrement( this IConventionPropertyBuilder propertyBuilder, int? increment, bool fromDataAnnotation = false) - { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); - - return propertyBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentityIncrement, increment, fromDataAnnotation); - } + => propertyBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentityIncrement, increment, fromDataAnnotation); /// /// Configures the value generation strategy for the key property, when targeting SQL Server. @@ -389,14 +377,10 @@ public static bool CanSetValueGenerationStrategy( this IConventionPropertyBuilder propertyBuilder, SqlServerValueGenerationStrategy? valueGenerationStrategy, bool fromDataAnnotation = false) - { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); - - return (valueGenerationStrategy == null + => (valueGenerationStrategy == null || SqlServerPropertyExtensions.IsCompatibleWithValueGeneration(propertyBuilder.Metadata)) && propertyBuilder.CanSetAnnotation( SqlServerAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation); - } /// /// Configures whether the property's column is created as sparse when targeting SQL Server. @@ -412,8 +396,6 @@ public static bool CanSetValueGenerationStrategy( /// See https://docs.microsoft.com/sql/relational-databases/tables/use-sparse-columns. public static PropertyBuilder IsSparse(this PropertyBuilder propertyBuilder, bool sparse = true) { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); - propertyBuilder.Metadata.SetIsSparse(sparse); return propertyBuilder; @@ -484,10 +466,6 @@ public static bool CanSetIsSparse( this IConventionPropertyBuilder property, bool? sparse, bool fromDataAnnotation = false) - { - Check.NotNull(property, nameof(property)); - - return property.CanSetAnnotation(SqlServerAnnotationNames.Sparse, sparse, fromDataAnnotation); - } + => property.CanSetAnnotation(SqlServerAnnotationNames.Sparse, sparse, fromDataAnnotation); } } diff --git a/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs index e3d1d8fbaf0..be62bc027f2 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerServiceCollectionExtensions.cs @@ -75,7 +75,6 @@ public static IServiceCollection AddSqlServer( Action? optionsAction = null) where TContext : DbContext { - Check.NotNull(serviceCollection, nameof(serviceCollection)); Check.NotEmpty(connectionString, nameof(connectionString)); return serviceCollection.AddDbContext( @@ -110,8 +109,6 @@ public static IServiceCollection AddSqlServer( [EditorBrowsable(EditorBrowsableState.Never)] public static IServiceCollection AddEntityFrameworkSqlServer(this IServiceCollection serviceCollection) { - Check.NotNull(serviceCollection, nameof(serviceCollection)); - new EntityFrameworkRelationalServicesBuilder(serviceCollection) .TryAdd() .TryAdd>() diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs index f7e26b3fd0e..5c562459856 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.Metadata.Conventions @@ -28,9 +27,6 @@ public SqlServerDbFunctionConvention( ProviderConventionSetBuilderDependencies dependencies, RelationalConventionSetBuilderDependencies relationalDependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(relationalDependencies, nameof(relationalDependencies)); - Dependencies = dependencies; RelationalDependencies = relationalDependencies; } diff --git a/src/EFCore.SqlServer/Migrations/Internal/SqlServerHistoryRepository.cs b/src/EFCore.SqlServer/Migrations/Internal/SqlServerHistoryRepository.cs index 2f32634250a..58cd249cd02 100644 --- a/src/EFCore.SqlServer/Migrations/Internal/SqlServerHistoryRepository.cs +++ b/src/EFCore.SqlServer/Migrations/Internal/SqlServerHistoryRepository.cs @@ -6,7 +6,6 @@ using System.Text; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Migrations.Internal { @@ -116,8 +115,6 @@ public override string GetCreateIfNotExistsScript() /// public override string GetBeginIfNotExistsScript(string migrationId) { - Check.NotEmpty(migrationId, nameof(migrationId)); - var stringTypeMapping = Dependencies.TypeMappingSource.GetMapping(typeof(string)); return new StringBuilder() @@ -140,8 +137,6 @@ public override string GetBeginIfNotExistsScript(string migrationId) /// public override string GetBeginIfExistsScript(string migrationId) { - Check.NotEmpty(migrationId, nameof(migrationId)); - var stringTypeMapping = Dependencies.TypeMappingSource.GetMapping(typeof(string)); return new StringBuilder() diff --git a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs index 5d55ff5f137..9836e73c21c 100644 --- a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs +++ b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs @@ -94,9 +94,6 @@ public override IReadOnlyList Generate( /// The command builder to use to build the commands. protected override void Generate(MigrationOperation operation, IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - switch (operation) { case SqlServerCreateDatabaseOperation createDatabaseOperation: @@ -240,9 +237,6 @@ protected override void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - if (operation[RelationalAnnotationNames.ColumnOrder] != operation.OldColumn[RelationalAnnotationNames.ColumnOrder]) { Dependencies.MigrationsLogger.ColumnOrderIgnoredWarning(operation); @@ -458,9 +452,6 @@ protected override void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - if (string.IsNullOrEmpty(operation.Table)) { throw new InvalidOperationException(SqlServerStrings.IndexTableRequired); @@ -485,9 +476,6 @@ protected override void Generate( /// The command builder to use to build the commands. protected override void Generate(RenameSequenceOperation operation, IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - var name = operation.Name; if (operation.NewName != null && operation.NewName != name) @@ -522,9 +510,6 @@ protected override void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .Append("ALTER SEQUENCE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name, operation.Schema)) @@ -680,9 +665,6 @@ protected override void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - var name = operation.Name; if (operation.NewName != null && operation.NewName != name) @@ -758,9 +740,6 @@ protected override void Generate( MigrationCommandListBuilder builder, bool terminate = true) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - var table = model?.GetRelationalModel().FindTable(operation.Table, operation.Schema); var hasNullableColumns = operation.Columns.Any(c => table?.FindColumn(c)?.IsNullable != false); @@ -852,9 +831,6 @@ protected override void Generate( /// The command builder to use to build the commands. protected override void Generate(EnsureSchemaOperation operation, IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - if (string.Equals(operation.Name, "dbo", StringComparison.OrdinalIgnoreCase)) { return; @@ -888,9 +864,6 @@ protected override void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .Append("CREATE SEQUENCE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name, operation.Schema)); @@ -927,9 +900,6 @@ protected virtual void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .Append("CREATE DATABASE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name)); @@ -993,8 +963,6 @@ protected virtual void Generate( private static string ExpandFileName(string fileName) { - Check.NotNull(fileName, nameof(fileName)); - if (fileName.StartsWith("|DataDirectory|", StringComparison.OrdinalIgnoreCase)) { var dataDirectory = AppDomain.CurrentDomain.GetData("DataDirectory") as string; @@ -1021,9 +989,6 @@ protected virtual void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .AppendLine("IF SERVERPROPERTY('EngineEdition') <> 5") .AppendLine("BEGIN"); @@ -1059,9 +1024,6 @@ protected override void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - if (operation[SqlServerAnnotationNames.EditionOptions] is string editionOptions) { builder @@ -1251,9 +1213,6 @@ protected override void Generate( MigrationCommandListBuilder builder, bool terminate) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - if (string.IsNullOrEmpty(operation.Table)) { throw new InvalidOperationException(SqlServerStrings.IndexTableRequired); @@ -1299,9 +1258,6 @@ protected override void Generate( MigrationCommandListBuilder builder, bool terminate = true) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - DropDefaultConstraint(operation.Schema, operation.Table, operation.Name, builder); base.Generate(operation, model, builder, terminate: false); @@ -1350,9 +1306,6 @@ protected override void Generate( IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - Rename( Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema) + "." @@ -1372,9 +1325,6 @@ protected override void Generate( /// The command builder to use to build the commands. protected override void Generate(SqlOperation operation, IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - var batches = Regex.Split( Regex.Replace( operation.Sql, @@ -1435,9 +1385,6 @@ protected override void Generate( MigrationCommandListBuilder builder, bool terminate = true) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - GenerateIdentityInsert(builder, operation, on: true); var sqlBuilder = new StringBuilder(); @@ -1514,10 +1461,6 @@ protected override void SequenceOptions( IModel? model, MigrationCommandListBuilder builder) { - Check.NotEmpty(name, nameof(name)); - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder .Append(" INCREMENT BY ") .Append(IntegerConstant(operation.IncrementBy)); @@ -1564,10 +1507,6 @@ protected override void ColumnDefinition( IModel? model, MigrationCommandListBuilder builder) { - Check.NotEmpty(name, nameof(name)); - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - if (operation.ComputedColumnSql != null) { ComputedColumnDefinition(schema, table, name, operation, model, builder); @@ -1657,10 +1596,6 @@ protected override void ComputedColumnDefinition( IModel? model, MigrationCommandListBuilder builder) { - Check.NotEmpty(name, nameof(name)); - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - builder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(name)); builder @@ -1705,10 +1640,6 @@ protected virtual void Rename( string? type, MigrationCommandListBuilder builder) { - Check.NotEmpty(name, nameof(name)); - Check.NotEmpty(newName, nameof(newName)); - Check.NotNull(builder, nameof(builder)); - var stringTypeMapping = Dependencies.TypeMappingSource.GetMapping(typeof(string)); builder @@ -1740,9 +1671,6 @@ protected virtual void Transfer( string name, MigrationCommandListBuilder builder) { - Check.NotEmpty(name, nameof(name)); - Check.NotNull(builder, nameof(builder)); - if (newSchema == null) { var stringTypeMapping = Dependencies.TypeMappingSource.GetMapping(typeof(string)); @@ -1776,9 +1704,6 @@ protected virtual void Transfer( /// The command builder to use to add the SQL fragment. protected override void IndexTraits(MigrationOperation operation, IModel? model, MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - var clustered = operation[SqlServerAnnotationNames.Clustered] as bool?; if (clustered.HasValue) { @@ -1871,8 +1796,6 @@ private void IndexWithOptions(CreateIndexOperation operation, MigrationCommandLi /// The command builder to use to add the SQL fragment. protected override void ForeignKeyAction(ReferentialAction referentialAction, MigrationCommandListBuilder builder) { - Check.NotNull(builder, nameof(builder)); - if (referentialAction == ReferentialAction.Restrict) { builder.Append("NO ACTION"); @@ -1896,10 +1819,6 @@ protected virtual void DropDefaultConstraint( string columnName, MigrationCommandListBuilder builder) { - Check.NotEmpty(tableName, nameof(tableName)); - Check.NotEmpty(columnName, nameof(columnName)); - Check.NotNull(builder, nameof(builder)); - var stringTypeMapping = Dependencies.TypeMappingSource.GetMapping(typeof(string)); var variable = "@var" + _variableCounter++; @@ -1945,8 +1864,6 @@ protected virtual IEnumerable GetIndexesToRebuild( IColumn? column, MigrationOperation currentOperation) { - Check.NotNull(currentOperation, nameof(currentOperation)); - if (column == null) { yield break; @@ -1984,9 +1901,6 @@ protected virtual void DropIndexes( IEnumerable indexes, MigrationCommandListBuilder builder) { - Check.NotNull(indexes, nameof(indexes)); - Check.NotNull(builder, nameof(builder)); - foreach (var index in indexes) { var table = index.Table; @@ -2012,9 +1926,6 @@ protected virtual void CreateIndexes( IEnumerable indexes, MigrationCommandListBuilder builder) { - Check.NotNull(indexes, nameof(indexes)); - Check.NotNull(builder, nameof(builder)); - foreach (var index in indexes) { Generate(CreateIndexOperation.CreateFrom(index), index.Table.Model.Model, builder, terminate: false); diff --git a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs index ed60bb03b9a..3ceb654b9e0 100644 --- a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -120,8 +119,6 @@ private SqlExpression SimplifyNegatedBinary(SqlExpression sqlExpression) /// protected override Expression VisitCase(CaseExpression caseExpression) { - Check.NotNull(caseExpression, nameof(caseExpression)); - var parentSearchCondition = _isSearchCondition; var testIsCondition = caseExpression.Operand == null; @@ -153,8 +150,6 @@ protected override Expression VisitCase(CaseExpression caseExpression) /// protected override Expression VisitCollate(CollateExpression collateExpression) { - Check.NotNull(collateExpression, nameof(collateExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var operand = (SqlExpression)Visit(collateExpression.Operand); @@ -170,11 +165,7 @@ protected override Expression VisitCollate(CollateExpression collateExpression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitColumn(ColumnExpression columnExpression) - { - Check.NotNull(columnExpression, nameof(columnExpression)); - - return ApplyConversion(columnExpression, condition: false); - } + => ApplyConversion(columnExpression, condition: false); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -184,8 +175,6 @@ protected override Expression VisitColumn(ColumnExpression columnExpression) /// protected override Expression VisitDistinct(DistinctExpression distinctExpression) { - Check.NotNull(distinctExpression, nameof(distinctExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var operand = (SqlExpression)Visit(distinctExpression.Operand); @@ -202,8 +191,6 @@ protected override Expression VisitDistinct(DistinctExpression distinctExpressio /// protected override Expression VisitExists(ExistsExpression existsExpression) { - Check.NotNull(existsExpression, nameof(existsExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var subquery = (SelectExpression)Visit(existsExpression.Subquery); @@ -219,11 +206,7 @@ protected override Expression VisitExists(ExistsExpression existsExpression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitFromSql(FromSqlExpression fromSqlExpression) - { - Check.NotNull(fromSqlExpression, nameof(fromSqlExpression)); - - return fromSqlExpression; - } + => fromSqlExpression; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -233,8 +216,6 @@ protected override Expression VisitFromSql(FromSqlExpression fromSqlExpression) /// protected override Expression VisitIn(InExpression inExpression) { - Check.NotNull(inExpression, nameof(inExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; @@ -254,8 +235,6 @@ protected override Expression VisitIn(InExpression inExpression) /// protected override Expression VisitLike(LikeExpression likeExpression) { - Check.NotNull(likeExpression, nameof(likeExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var match = (SqlExpression)Visit(likeExpression.Match); @@ -274,8 +253,6 @@ protected override Expression VisitLike(LikeExpression likeExpression) /// protected override Expression VisitSelect(SelectExpression selectExpression) { - Check.NotNull(selectExpression, nameof(selectExpression)); - var changed = false; var parentSearchCondition = _isSearchCondition; @@ -344,8 +321,6 @@ protected override Expression VisitSelect(SelectExpression selectExpression) /// protected override Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpression) { - Check.NotNull(sqlBinaryExpression, nameof(sqlBinaryExpression)); - var parentIsSearchCondition = _isSearchCondition; switch (sqlBinaryExpression.OperatorType) @@ -386,8 +361,6 @@ protected override Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpres /// protected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpression) { - Check.NotNull(sqlUnaryExpression, nameof(sqlUnaryExpression)); - var parentSearchCondition = _isSearchCondition; bool resultCondition; switch (sqlUnaryExpression.OperatorType) @@ -440,11 +413,7 @@ protected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpressio /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitSqlConstant(SqlConstantExpression sqlConstantExpression) - { - Check.NotNull(sqlConstantExpression, nameof(sqlConstantExpression)); - - return ApplyConversion(sqlConstantExpression, condition: false); - } + => ApplyConversion(sqlConstantExpression, condition: false); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -453,11 +422,7 @@ protected override Expression VisitSqlConstant(SqlConstantExpression sqlConstant /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitSqlFragment(SqlFragmentExpression sqlFragmentExpression) - { - Check.NotNull(sqlFragmentExpression, nameof(sqlFragmentExpression)); - - return sqlFragmentExpression; - } + => sqlFragmentExpression; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -467,8 +432,6 @@ protected override Expression VisitSqlFragment(SqlFragmentExpression sqlFragment /// protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunctionExpression) { - Check.NotNull(sqlFunctionExpression, nameof(sqlFunctionExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var instance = (SqlExpression?)Visit(sqlFunctionExpression.Instance); @@ -498,8 +461,6 @@ protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunction /// protected override Expression VisitTableValuedFunction(TableValuedFunctionExpression tableValuedFunctionExpression) { - Check.NotNull(tableValuedFunctionExpression, nameof(tableValuedFunctionExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; @@ -520,11 +481,7 @@ protected override Expression VisitTableValuedFunction(TableValuedFunctionExpres /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitSqlParameter(SqlParameterExpression sqlParameterExpression) - { - Check.NotNull(sqlParameterExpression, nameof(sqlParameterExpression)); - - return ApplyConversion(sqlParameterExpression, condition: false); - } + => ApplyConversion(sqlParameterExpression, condition: false); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -533,11 +490,7 @@ protected override Expression VisitSqlParameter(SqlParameterExpression sqlParame /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitTable(TableExpression tableExpression) - { - Check.NotNull(tableExpression, nameof(tableExpression)); - - return tableExpression; - } + => tableExpression; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -547,8 +500,6 @@ protected override Expression VisitTable(TableExpression tableExpression) /// protected override Expression VisitProjection(ProjectionExpression projectionExpression) { - Check.NotNull(projectionExpression, nameof(projectionExpression)); - var expression = (SqlExpression)Visit(projectionExpression.Expression); return projectionExpression.Update(expression); @@ -562,8 +513,6 @@ protected override Expression VisitProjection(ProjectionExpression projectionExp /// protected override Expression VisitOrdering(OrderingExpression orderingExpression) { - Check.NotNull(orderingExpression, nameof(orderingExpression)); - var expression = (SqlExpression)Visit(orderingExpression.Expression); return orderingExpression.Update(expression); @@ -577,8 +526,6 @@ protected override Expression VisitOrdering(OrderingExpression orderingExpressio /// protected override Expression VisitCrossJoin(CrossJoinExpression crossJoinExpression) { - Check.NotNull(crossJoinExpression, nameof(crossJoinExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var table = (TableExpressionBase)Visit(crossJoinExpression.Table); @@ -595,8 +542,6 @@ protected override Expression VisitCrossJoin(CrossJoinExpression crossJoinExpres /// protected override Expression VisitCrossApply(CrossApplyExpression crossApplyExpression) { - Check.NotNull(crossApplyExpression, nameof(crossApplyExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var table = (TableExpressionBase)Visit(crossApplyExpression.Table); @@ -613,8 +558,6 @@ protected override Expression VisitCrossApply(CrossApplyExpression crossApplyExp /// protected override Expression VisitOuterApply(OuterApplyExpression outerApplyExpression) { - Check.NotNull(outerApplyExpression, nameof(outerApplyExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var table = (TableExpressionBase)Visit(outerApplyExpression.Table); @@ -631,8 +574,6 @@ protected override Expression VisitOuterApply(OuterApplyExpression outerApplyExp /// protected override Expression VisitInnerJoin(InnerJoinExpression innerJoinExpression) { - Check.NotNull(innerJoinExpression, nameof(innerJoinExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var table = (TableExpressionBase)Visit(innerJoinExpression.Table); @@ -651,8 +592,6 @@ protected override Expression VisitInnerJoin(InnerJoinExpression innerJoinExpres /// protected override Expression VisitLeftJoin(LeftJoinExpression leftJoinExpression) { - Check.NotNull(leftJoinExpression, nameof(leftJoinExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var table = (TableExpressionBase)Visit(leftJoinExpression.Table); @@ -671,8 +610,6 @@ protected override Expression VisitLeftJoin(LeftJoinExpression leftJoinExpressio /// protected override Expression VisitScalarSubquery(ScalarSubqueryExpression scalarSubqueryExpression) { - Check.NotNull(scalarSubqueryExpression, nameof(scalarSubqueryExpression)); - var parentSearchCondition = _isSearchCondition; var subquery = (SelectExpression)Visit(scalarSubqueryExpression.Subquery); _isSearchCondition = parentSearchCondition; @@ -688,8 +625,6 @@ protected override Expression VisitScalarSubquery(ScalarSubqueryExpression scala /// protected override Expression VisitRowNumber(RowNumberExpression rowNumberExpression) { - Check.NotNull(rowNumberExpression, nameof(rowNumberExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var changed = false; @@ -722,8 +657,6 @@ protected override Expression VisitRowNumber(RowNumberExpression rowNumberExpres /// protected override Expression VisitExcept(ExceptExpression exceptExpression) { - Check.NotNull(exceptExpression, nameof(exceptExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var source1 = (SelectExpression)Visit(exceptExpression.Source1); @@ -741,8 +674,6 @@ protected override Expression VisitExcept(ExceptExpression exceptExpression) /// protected override Expression VisitIntersect(IntersectExpression intersectExpression) { - Check.NotNull(intersectExpression, nameof(intersectExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var source1 = (SelectExpression)Visit(intersectExpression.Source1); @@ -760,8 +691,6 @@ protected override Expression VisitIntersect(IntersectExpression intersectExpres /// protected override Expression VisitUnion(UnionExpression unionExpression) { - Check.NotNull(unionExpression, nameof(unionExpression)); - var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; var source1 = (SelectExpression)Visit(unionExpression.Source1); diff --git a/src/EFCore.SqlServer/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs index 1c8e43cfdae..2aa01b38cef 100644 --- a/src/EFCore.SqlServer/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -30,8 +29,6 @@ public class SkipTakeCollapsingExpressionVisitor : ExpressionVisitor /// public SkipTakeCollapsingExpressionVisitor(ISqlExpressionFactory sqlExpressionFactory) { - Check.NotNull(sqlExpressionFactory, nameof(sqlExpressionFactory)); - _sqlExpressionFactory = sqlExpressionFactory; _parameterValues = null!; } @@ -47,9 +44,6 @@ public virtual SelectExpression Process( IReadOnlyDictionary parametersValues, out bool canCache) { - Check.NotNull(selectExpression, nameof(selectExpression)); - Check.NotNull(parametersValues, nameof(parametersValues)); - _parameterValues = parametersValues; _canCache = true; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs index c4058fa75d6..14055000e68 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -43,10 +42,6 @@ public SqlServerByteArrayMethodTranslator(ISqlExpressionFactory sqlExpressionFac IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (method.IsGenericMethod && method.GetGenericMethodDefinition().Equals(EnumerableMethods.Contains) && arguments[0].Type == typeof(byte[])) diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs index a745925ccf9..4c9662297f4 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -31,8 +30,6 @@ public SqlServerCompiledQueryCacheKeyGenerator( ISqlServerConnection sqlServerConnection) : base(dependencies, relationalDependencies) { - Check.NotNull(sqlServerConnection, nameof(sqlServerConnection)); - _sqlServerConnection = sqlServerConnection; } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs index b0273fa2d32..86534936730 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -78,12 +77,7 @@ public SqlServerConvertTranslator(ISqlExpressionFactory sqlExpressionFactory) MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) - { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - - return _supportedMethods.Contains(method) + => _supportedMethods.Contains(method) ? _sqlExpressionFactory.Function( "CONVERT", new[] { _sqlExpressionFactory.Fragment(_typeMapping[method.Name]), arguments[0] }, @@ -91,6 +85,5 @@ public SqlServerConvertTranslator(ISqlExpressionFactory sqlExpressionFactory) argumentsPropagateNullability: new[] { false, true }, method.ReturnType) : null; - } } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs index 54f38e625c5..10d23ca91bb 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -75,10 +74,6 @@ public SqlServerDataLengthFunctionTranslator(ISqlExpressionFactory sqlExpression IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (_methodInfoDataLengthMapping.Contains(method)) { var argument = arguments[1]; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs index d3de80fa79c..5d1414a8290 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -340,10 +339,6 @@ public SqlServerDateDiffFunctionsTranslator( IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (_methodInfoDateDiffMapping.TryGetValue(method, out var datePart)) { var startDate = arguments[1]; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs index e13099ebaf3..9b5d676fe3d 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -46,9 +45,6 @@ public SqlServerDateTimeMemberTranslator( ISqlExpressionFactory sqlExpressionFactory, IRelationalTypeMappingSource typeMappingSource) { - Check.NotNull(sqlExpressionFactory, nameof(sqlExpressionFactory)); - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - _sqlExpressionFactory = sqlExpressionFactory; _typeMappingSource = typeMappingSource; } @@ -65,10 +61,6 @@ public SqlServerDateTimeMemberTranslator( Type returnType, IDiagnosticsLogger logger) { - Check.NotNull(member, nameof(member)); - Check.NotNull(returnType, nameof(returnType)); - Check.NotNull(logger, nameof(logger)); - var declaringType = member.DeclaringType; if (declaringType == typeof(DateTime) diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs index da8b5899462..59d61f369d3 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -67,10 +66,6 @@ public SqlServerDateTimeMethodTranslator( IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (_methodInfoDatePartMapping.TryGetValue(method, out var datePart) && instance != null) { diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs index 6ccefb6f693..6d1d303c52d 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -90,10 +89,6 @@ public SqlServerFromPartsFunctionTranslator( IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (_methodFunctionMapping.TryGetValue(method, out var value)) { return _sqlExpressionFactory.Function( diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs index 19627fd6285..4d93503b9b0 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.SqlServer.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -74,10 +73,6 @@ public SqlServerFullTextSearchFunctionsTranslator(ISqlExpressionFactory sqlExpre IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (_functionMapping.TryGetValue(method, out var functionName)) { var propertyReference = arguments[1]; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs index 5741dc0d2d5..39bcc870e58 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -44,12 +43,7 @@ public SqlServerIsDateFunctionTranslator(ISqlExpressionFactory sqlExpressionFact MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) - { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - - return _methodInfo.Equals(method) + => _methodInfo.Equals(method) ? _sqlExpressionFactory.Convert( _sqlExpressionFactory.Function( "ISDATE", @@ -59,6 +53,5 @@ public SqlServerIsDateFunctionTranslator(ISqlExpressionFactory sqlExpressionFact _methodInfo.ReturnType), _methodInfo.ReturnType) : null; - } } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerIsNumericFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerIsNumericFunctionTranslator.cs index ae3d9d665fb..1b8e2ce41e3 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerIsNumericFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerIsNumericFunctionTranslator.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -44,12 +43,7 @@ public SqlServerIsNumericFunctionTranslator(ISqlExpressionFactory sqlExpressionF MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) - { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - - return _methodInfo.Equals(method) + => _methodInfo.Equals(method) ? _sqlExpressionFactory.Equal( _sqlExpressionFactory.Function( "ISNUMERIC", @@ -59,6 +53,5 @@ public SqlServerIsNumericFunctionTranslator(ISqlExpressionFactory sqlExpressionF typeof(int)), _sqlExpressionFactory.Constant(1)) : null; - } } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs index 9d6092aa33e..e71505bdbd6 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -114,10 +113,6 @@ public SqlServerMathTranslator(ISqlExpressionFactory sqlExpressionFactory) IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (_supportedMethodTranslations.TryGetValue(method, out var sqlFunctionName)) { var typeMapping = arguments.Count == 1 diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMemberTranslatorProvider.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMemberTranslatorProvider.cs index 945e85652e1..01c87f3ba85 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerMemberTranslatorProvider.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMemberTranslatorProvider.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -26,8 +25,6 @@ public SqlServerMemberTranslatorProvider( IRelationalTypeMappingSource typeMappingSource) : base(dependencies) { - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - var sqlExpressionFactory = dependencies.SqlExpressionFactory; AddTranslators( diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs index f5b4dbbcbb4..4b5fd6571f9 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -44,12 +43,7 @@ public SqlServerNewGuidTranslator(ISqlExpressionFactory sqlExpressionFactory) MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) - { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - - return _methodInfo.Equals(method) + => _methodInfo.Equals(method) ? _sqlExpressionFactory.Function( "NEWID", Array.Empty(), @@ -57,6 +51,5 @@ public SqlServerNewGuidTranslator(ISqlExpressionFactory sqlExpressionFactory) argumentsPropagateNullability: Array.Empty(), method.ReturnType) : null; - } } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs index 188a3ffd8dd..38eedefa392 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -68,10 +67,6 @@ public SqlServerObjectToStringTranslator(ISqlExpressionFactory sqlExpressionFact IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (instance == null || method.Name != nameof(ToString) || arguments.Count != 0) { return null; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerParameterBasedSqlProcessor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerParameterBasedSqlProcessor.cs index 21349fa3e7b..cf710550dd0 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerParameterBasedSqlProcessor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerParameterBasedSqlProcessor.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -40,9 +39,6 @@ public override SelectExpression Optimize( IReadOnlyDictionary parametersValues, out bool canCache) { - Check.NotNull(selectExpression, nameof(selectExpression)); - Check.NotNull(parametersValues, nameof(parametersValues)); - var optimizedSelectExpression = base.Optimize(selectExpression, parametersValues, out canCache); optimizedSelectExpression = new SkipTakeCollapsingExpressionVisitor(Dependencies.SqlExpressionFactory) @@ -64,12 +60,7 @@ protected override SelectExpression ProcessSqlNullability( SelectExpression selectExpression, IReadOnlyDictionary parametersValues, out bool canCache) - { - Check.NotNull(selectExpression, nameof(selectExpression)); - Check.NotNull(parametersValues, nameof(parametersValues)); - - return new SqlServerSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process( + => new SqlServerSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process( selectExpression, parametersValues, out canCache); - } } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContextFactory.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContextFactory.cs index 4b381f21516..d817a7de0f0 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContextFactory.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContextFactory.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -28,9 +27,6 @@ public SqlServerQueryCompilationContextFactory( RelationalQueryCompilationContextDependencies relationalDependencies, ISqlServerConnection sqlServerConnection) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(relationalDependencies, nameof(relationalDependencies)); - Dependencies = dependencies; RelationalDependencies = relationalDependencies; _sqlServerConnection = sqlServerConnection; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs index d1de769da81..262ab6a8a8c 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs @@ -39,8 +39,6 @@ public SqlServerQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies) /// protected override void GenerateTop(SelectExpression selectExpression) { - Check.NotNull(selectExpression, nameof(selectExpression)); - if (selectExpression.Limit != null && selectExpression.Offset == null) { @@ -60,8 +58,6 @@ protected override void GenerateTop(SelectExpression selectExpression) /// protected override void GenerateOrderings(SelectExpression selectExpression) { - Check.NotNull(selectExpression, nameof(selectExpression)); - base.GenerateOrderings(selectExpression); // In SQL Server, if an offset is specified, then an ORDER BY clause must also exist. @@ -80,8 +76,6 @@ protected override void GenerateOrderings(SelectExpression selectExpression) /// protected override void GenerateLimitOffset(SelectExpression selectExpression) { - Check.NotNull(selectExpression, nameof(selectExpression)); - // Note: For Limit without Offset, SqlServer generates TOP() if (selectExpression.Offset != null) { diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs index bf087885a43..6cde8396883 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQueryableMethodTranslatingExpressionVisitorFactory.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -24,9 +23,6 @@ public SqlServerQueryableMethodTranslatingExpressionVisitorFactory( QueryableMethodTranslatingExpressionVisitorDependencies dependencies, RelationalQueryableMethodTranslatingExpressionVisitorDependencies relationalDependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(relationalDependencies, nameof(relationalDependencies)); - Dependencies = dependencies; RelationalDependencies = relationalDependencies; } @@ -48,10 +44,6 @@ public SqlServerQueryableMethodTranslatingExpressionVisitorFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QueryableMethodTranslatingExpressionVisitor Create(QueryCompilationContext queryCompilationContext) - { - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - - return new SqlServerQueryableMethodTranslatingExpressionVisitor(Dependencies, RelationalDependencies, queryCompilationContext); - } + => new SqlServerQueryableMethodTranslatingExpressionVisitor(Dependencies, RelationalDependencies, queryCompilationContext); } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs index 439c4b92aff..8c6c9aa602a 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -59,8 +58,6 @@ public SqlServerSqlTranslatingExpressionVisitor( /// protected override Expression VisitBinary(BinaryExpression binaryExpression) { - Check.NotNull(binaryExpression, nameof(binaryExpression)); - if (binaryExpression.NodeType == ExpressionType.ArrayIndex && binaryExpression.Left.Type == typeof(byte[])) { @@ -137,17 +134,13 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override SqlExpression? TranslateLongCount(SqlExpression sqlExpression) - { - Check.NotNull(sqlExpression, nameof(sqlExpression)); - - return Dependencies.SqlExpressionFactory.ApplyDefaultTypeMapping( + => Dependencies.SqlExpressionFactory.ApplyDefaultTypeMapping( Dependencies.SqlExpressionFactory.Function( "COUNT_BIG", new[] { sqlExpression }, nullable: false, argumentsPropagateNullability: new[] { false }, typeof(long))); - } private static string? GetProviderType(SqlExpression expression) => expression.TypeMapping?.StoreType; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs index fd5a9a74884..cd4694a7e5d 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -43,10 +42,6 @@ public SqlServerStringMemberTranslator(ISqlExpressionFactory sqlExpressionFactor Type returnType, IDiagnosticsLogger logger) { - Check.NotNull(member, nameof(member)); - Check.NotNull(returnType, nameof(returnType)); - Check.NotNull(logger, nameof(logger)); - if (member.Name == nameof(string.Length) && instance?.Type == typeof(string)) { diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs index 78faf9f358a..ef3a986f2e5 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -112,10 +111,6 @@ public SqlServerStringMethodTranslator(ISqlExpressionFactory sqlExpressionFactor IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - if (instance != null) { if (_indexOfMethodInfo.Equals(method)) diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs index c415fa8cee7..37ada467e13 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -52,10 +51,6 @@ public SqlServerTimeSpanMemberTranslator(ISqlExpressionFactory sqlExpressionFact Type returnType, IDiagnosticsLogger logger) { - Check.NotNull(member, nameof(member)); - Check.NotNull(returnType, nameof(returnType)); - Check.NotNull(logger, nameof(logger)); - if (member.DeclaringType == typeof(TimeSpan) && _datePartMappings.TryGetValue(member.Name, out var value)) { return _sqlExpressionFactory.Function( diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs index 6d2ee898b8c..5507d600026 100644 --- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs +++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs @@ -86,8 +86,6 @@ private static readonly Regex _partExtractor /// public SqlServerDatabaseModelFactory(IDiagnosticsLogger logger) { - Check.NotNull(logger, nameof(logger)); - _logger = logger; } @@ -99,9 +97,6 @@ public SqlServerDatabaseModelFactory(IDiagnosticsLogger public override DatabaseModel Create(string connectionString, DatabaseModelFactoryOptions options) { - Check.NotEmpty(connectionString, nameof(connectionString)); - Check.NotNull(options, nameof(options)); - using var connection = new SqlConnection(connectionString); return Create(connection, options); } @@ -114,9 +109,6 @@ public override DatabaseModel Create(string connectionString, DatabaseModelFacto /// public override DatabaseModel Create(DbConnection connection, DatabaseModelFactoryOptions options) { - Check.NotNull(connection, nameof(connection)); - Check.NotNull(options, nameof(options)); - var databaseModel = new DatabaseModel(); var connectionStartedOpen = connection.State == ConnectionState.Open; diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs index 850d1bab999..272c2e1c4ef 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs @@ -5,7 +5,6 @@ using System.Text; using Microsoft.EntityFrameworkCore.SqlServer.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal { @@ -53,7 +52,7 @@ public override string StartTransactionStatement /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override string EscapeIdentifier(string identifier) - => Check.NotEmpty(identifier, nameof(identifier)).Replace("]", "]]"); + => identifier.Replace("]", "]]"); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -63,8 +62,6 @@ public override string EscapeIdentifier(string identifier) /// public override void EscapeIdentifier(StringBuilder builder, string identifier) { - Check.NotEmpty(identifier, nameof(identifier)); - var initialLength = builder.Length; builder.Append(identifier); builder.Replace("]", "]]", initialLength, identifier.Length); @@ -77,7 +74,7 @@ public override void EscapeIdentifier(StringBuilder builder, string identifier) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override string DelimitIdentifier(string identifier) - => $"[{EscapeIdentifier(Check.NotEmpty(identifier, nameof(identifier)))}]"; // Interpolation okay; strings + => $"[{EscapeIdentifier(identifier)}]"; // Interpolation okay; strings /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -87,8 +84,6 @@ public override string DelimitIdentifier(string identifier) /// public override void DelimitIdentifier(StringBuilder builder, string identifier) { - Check.NotEmpty(identifier, nameof(identifier)); - builder.Append('['); EscapeIdentifier(builder, identifier); builder.Append(']'); diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs index 131df533e13..b9d9ab25f72 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs @@ -5,7 +5,6 @@ using System.Data.Common; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal { @@ -23,8 +22,6 @@ public class SqlServerTransactionFactory : IRelationalTransactionFactory /// Parameter object containing dependencies for this service. public SqlServerTransactionFactory(RelationalTransactionFactoryDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatchFactory.cs b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatchFactory.cs index acde5499e31..c048a55efbc 100644 --- a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatchFactory.cs +++ b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatchFactory.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal; using Microsoft.EntityFrameworkCore.Update; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.SqlServer.Update.Internal { @@ -29,9 +28,6 @@ public SqlServerModificationCommandBatchFactory( ModificationCommandBatchFactoryDependencies dependencies, IDbContextOptions options) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(options, nameof(options)); - Dependencies = dependencies; _options = options; } diff --git a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceValueGeneratorState.cs b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceValueGeneratorState.cs index 6a81a37bee1..a82105d7954 100644 --- a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceValueGeneratorState.cs +++ b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceValueGeneratorState.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.EntityFrameworkCore.ValueGeneration; namespace Microsoft.EntityFrameworkCore.SqlServer.ValueGeneration.Internal @@ -22,7 +21,7 @@ public class SqlServerSequenceValueGeneratorState : HiLoValueGeneratorState /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public SqlServerSequenceValueGeneratorState(ISequence sequence) - : base(Check.NotNull(sequence, nameof(sequence)).IncrementBy) + : base(sequence.IncrementBy) { Sequence = sequence; } diff --git a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs index a690abe45ef..d411090d1d8 100644 --- a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs +++ b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.EntityFrameworkCore.ValueGeneration; namespace Microsoft.EntityFrameworkCore.SqlServer.ValueGeneration.Internal @@ -60,11 +59,7 @@ public SqlServerValueGeneratorSelector( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override ValueGenerator Select(IProperty property, IEntityType entityType) - { - Check.NotNull(property, nameof(property)); - Check.NotNull(entityType, nameof(entityType)); - - return property.GetValueGeneratorFactory() == null + => property.GetValueGeneratorFactory() == null && property.GetValueGenerationStrategy() == SqlServerValueGenerationStrategy.SequenceHiLo ? _sequenceFactory.Create( property, @@ -73,7 +68,6 @@ public override ValueGenerator Select(IProperty property, IEntityType entityType _rawSqlCommandBuilder, _commandLogger) : base.Select(property, entityType); - } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -82,15 +76,10 @@ public override ValueGenerator Select(IProperty property, IEntityType entityType /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override ValueGenerator Create(IProperty property, IEntityType entityType) - { - Check.NotNull(property, nameof(property)); - Check.NotNull(entityType, nameof(entityType)); - - return property.ClrType.UnwrapNullableType() == typeof(Guid) + => property.ClrType.UnwrapNullableType() == typeof(Guid) ? property.ValueGenerated == ValueGenerated.Never || property.GetDefaultValueSql() != null ? new TemporaryGuidValueGenerator() : new SequentialGuidValueGenerator() : base.Create(property, entityType); - } } }