From 3377d77db203aab08b184e61d6a7f861ffd8c449 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Mon, 25 Oct 2021 18:33:30 +0100 Subject: [PATCH] Evolve null-checking approach Part of #19233 Removes a lot of null checks from code that is not intended to be called directly by application code. --- .../ObservableCollectionExtensions.cs | 7 +- .../CosmosDatabaseFacadeExtensions.cs | 3 - .../CosmosEntityTypeBuilderExtensions.cs | 53 +---- .../Extensions/CosmosEntityTypeExtensions.cs | 2 +- .../CosmosModelBuilderExtensions.cs | 1 - .../CosmosPropertyBuilderExtensions.cs | 3 +- .../Extensions/CosmosQueryableExtensions.cs | 2 - .../CosmosServiceCollectionExtensions.cs | 10 +- .../CosmosDbContextOptionsBuilder.cs | 2 - .../Internal/CosmosDbOptionExtension.cs | 3 - .../Conventions/ContextContainerConvention.cs | 8 +- .../CosmosKeyDiscoveryConvention.cs | 5 - ...osmosManyToManyJoinEntityTypeConvention.cs | 5 - .../CosmosDateTimeMemberTranslator.cs | 5 - .../CosmosMemberTranslatorProvider.cs | 9 +- .../CosmosMethodCallTranslatorProvider.cs | 9 +- ...osmosProjectionBindingExpressionVisitor.cs | 10 - .../CosmosQueryCompilationContextFactory.cs | 3 - .../Query/Internal/CosmosQueryContext.cs | 3 - .../Internal/CosmosQueryContextFactory.cs | 4 - ...ueryMetadataExtractingExpressionVisitor.cs | 2 - .../CosmosQueryTranslationPostprocessor.cs | 3 - ...mosQueryTranslationPostprocessorFactory.cs | 7 +- ...smosQueryTranslationPreprocessorFactory.cs | 2 - ...yableMethodTranslatingExpressionVisitor.cs | 196 ++---------------- ...thodTranslatingExpressionVisitorFactory.cs | 7 +- ...ionBindingRemovingExpressionVisitorBase.cs | 6 - ...sitor.JObjectInjectingExpressionVisitor.cs | 3 - ...osShapedQueryCompilingExpressionVisitor.cs | 3 - ...dQueryCompilingExpressionVisitorFactory.cs | 11 +- .../CosmosSqlTranslatingExpressionVisitor.cs | 28 +-- .../Internal/CosmosStringMemberTranslator.cs | 5 - ...eConverterCompensatingExpressionVisitor.cs | 5 - .../Internal/EntityProjectionExpression.cs | 11 +- .../Query/Internal/EqualsTranslator.cs | 5 - .../Query/Internal/FromSqlExpression.cs | 18 +- .../Internal/FromSqlQueryRootExpression.cs | 9 - .../Query/Internal/InExpression.cs | 3 - .../Query/Internal/KeyAccessExpression.cs | 12 +- .../Query/Internal/MathTranslator.cs | 5 - .../Query/Internal/ObjectAccessExpression.cs | 13 +- .../ObjectArrayProjectionExpression.cs | 9 +- .../Query/Internal/OrderingExpression.cs | 10 +- .../Query/Internal/ProjectionExpression.cs | 9 +- .../Query/Internal/QuerySqlGenerator.cs | 33 --- .../Internal/QuerySqlGeneratorFactory.cs | 3 - .../Query/Internal/RandomTranslator.cs | 9 +- .../Query/Internal/ReadItemExpression.cs | 4 - .../Query/Internal/RootReferenceExpression.cs | 7 +- .../Query/Internal/SelectExpression.cs | 6 - .../Query/Internal/SqlBinaryExpression.cs | 8 - .../Internal/SqlConditionalExpression.cs | 5 - .../Query/Internal/SqlConstantExpression.cs | 13 +- .../Query/Internal/SqlExpressionVisitor.cs | 2 - .../Query/Internal/SqlFunctionExpression.cs | 5 - .../Query/Internal/SqlParameterExpression.cs | 12 +- .../Query/Internal/SqlUnaryExpression.cs | 10 +- .../Query/Internal/StringMethodTranslator.cs | 5 - .../CosmosExecutionStrategyFactory.cs | 3 - 59 files changed, 60 insertions(+), 594 deletions(-) diff --git a/src/EFCore.Abstractions/ObservableCollectionExtensions.cs b/src/EFCore.Abstractions/ObservableCollectionExtensions.cs index 456a8098261..39da8eb21df 100644 --- a/src/EFCore.Abstractions/ObservableCollectionExtensions.cs +++ b/src/EFCore.Abstractions/ObservableCollectionExtensions.cs @@ -4,7 +4,6 @@ using System.Collections.ObjectModel; using System.ComponentModel; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore { @@ -25,10 +24,6 @@ public static class ObservableCollectionExtensions /// The binding list. public static BindingList ToBindingList(this ObservableCollection source) where T : class - { - Check.NotNull(source, nameof(source)); - - return new ObservableBackedBindingList(source); - } + => new ObservableBackedBindingList(source); } } diff --git a/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs index 38eae0d8234..27511dae215 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosDatabaseFacadeExtensions.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; // ReSharper disable once CheckNamespace @@ -32,8 +31,6 @@ public static CosmosClient GetCosmosClient(this DatabaseFacade databaseFacade) private static TService GetService(IInfrastructure databaseFacade) { - Check.NotNull(databaseFacade, nameof(databaseFacade)); - var service = databaseFacade.Instance.GetService(); if (service == null) { diff --git a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs index 3ad335bb301..4611e11784c 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs @@ -37,7 +37,6 @@ public static EntityTypeBuilder ToContainer( this EntityTypeBuilder entityTypeBuilder, string? name) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); entityTypeBuilder.Metadata.SetContainer(name); @@ -108,7 +107,6 @@ public static bool CanSetContainer( string? name, bool fromDataAnnotation = false) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.ContainerName, name, fromDataAnnotation); @@ -200,7 +198,6 @@ public static bool CanSetJsonProperty( string? name, bool fromDataAnnotation = false) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.PropertyName, name, fromDataAnnotation); @@ -239,11 +236,7 @@ public static EntityTypeBuilder HasPartitionKey( this EntityTypeBuilder entityTypeBuilder, string? name) where TEntity : class - { - entityTypeBuilder.Metadata.SetPartitionKeyPropertyName(name); - - return entityTypeBuilder; - } + => (EntityTypeBuilder)HasPartitionKey((EntityTypeBuilder)entityTypeBuilder, name); /// /// Configures the property that is used to store the partition key. @@ -262,9 +255,7 @@ public static EntityTypeBuilder HasPartitionKey( { Check.NotNull(propertyExpression, nameof(propertyExpression)); - entityTypeBuilder.Metadata.SetPartitionKeyPropertyName(propertyExpression.GetMemberAccess().GetSimpleMemberName()); - - return entityTypeBuilder; + return HasPartitionKey(entityTypeBuilder, propertyExpression.GetMemberAccess().GetSimpleMemberName()); } /// @@ -313,7 +304,6 @@ public static bool CanSetPartitionKey( string? name, bool fromDataAnnotation = false) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.PartitionKeyName, name, fromDataAnnotation); @@ -330,11 +320,10 @@ public static bool CanSetPartitionKey( /// The same builder instance so that multiple calls can be chained. public static EntityTypeBuilder UseETagConcurrency(this EntityTypeBuilder entityTypeBuilder) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - entityTypeBuilder.Property("_etag") .ValueGeneratedOnAddOrUpdate() .IsConcurrencyToken(); + return entityTypeBuilder; } @@ -349,11 +338,7 @@ public static EntityTypeBuilder UseETagConcurrency(this EntityTypeBuilder entity /// The same builder instance so that multiple calls can be chained. public static EntityTypeBuilder UseETagConcurrency(this EntityTypeBuilder entityTypeBuilder) where TEntity : class - { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - UseETagConcurrency((EntityTypeBuilder)entityTypeBuilder); - return entityTypeBuilder; - } + => (EntityTypeBuilder)UseETagConcurrency((EntityTypeBuilder)entityTypeBuilder); /// /// Configures the time to live for analytical store in seconds at container scope. @@ -388,11 +373,7 @@ public static EntityTypeBuilder HasAnalyticalStoreTimeToLive( this EntityTypeBuilder entityTypeBuilder, int? seconds) where TEntity : class - { - entityTypeBuilder.Metadata.SetAnalyticalStoreTimeToLive(seconds); - - return entityTypeBuilder; - } + => (EntityTypeBuilder)HasAnalyticalStoreTimeToLive((EntityTypeBuilder)entityTypeBuilder, seconds); /// /// Configures the time to live for analytical store in seconds at container scope. @@ -478,11 +459,7 @@ public static EntityTypeBuilder HasDefaultTimeToLive( this EntityTypeBuilder entityTypeBuilder, int? seconds) where TEntity : class - { - entityTypeBuilder.Metadata.SetDefaultTimeToLive(seconds); - - return entityTypeBuilder; - } + => (EntityTypeBuilder)HasDefaultTimeToLive((EntityTypeBuilder)entityTypeBuilder, seconds); /// /// Configures the default time to live in seconds at container scope. @@ -529,11 +506,7 @@ public static bool CanSetDefaultTimeToLive( this IConventionEntityTypeBuilder entityTypeBuilder, int? seconds, bool fromDataAnnotation = false) - { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - - return entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.DefaultTimeToLive, seconds, fromDataAnnotation); - } + => entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.DefaultTimeToLive, seconds, fromDataAnnotation); /// /// Configures the manual provisioned throughput offering. @@ -564,11 +537,7 @@ public static EntityTypeBuilder HasManualThroughput( this EntityTypeBuilder entityTypeBuilder, int? throughput) where TEntity : class - { - entityTypeBuilder.Metadata.SetThroughput(throughput, autoscale: false); - - return entityTypeBuilder; - } + => (EntityTypeBuilder)HasManualThroughput((EntityTypeBuilder)entityTypeBuilder, throughput); /// /// Configures the autoscale provisioned throughput offering. @@ -599,11 +568,7 @@ public static EntityTypeBuilder HasAutoscaleThroughput( this EntityTypeBuilder entityTypeBuilder, int? throughput) where TEntity : class - { - entityTypeBuilder.Metadata.SetThroughput(throughput, autoscale: true); - - return entityTypeBuilder; - } + => (EntityTypeBuilder)HasAutoscaleThroughput((EntityTypeBuilder)entityTypeBuilder, throughput); /// /// Configures the provisioned throughput. diff --git a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs index 0f8a00e6044..88fc3b1bb60 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs @@ -260,8 +260,8 @@ public static void SetETagPropertyName( /// The property mapped to ETag, or if no property is mapped to ETag. public static IReadOnlyProperty? GetETagProperty(this IReadOnlyEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); var etagPropertyName = entityType.GetETagPropertyName(); + return !string.IsNullOrEmpty(etagPropertyName) ? entityType.FindProperty(etagPropertyName) : null; } diff --git a/src/EFCore.Cosmos/Extensions/CosmosModelBuilderExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosModelBuilderExtensions.cs index c04b303bd51..ccccbba8706 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosModelBuilderExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosModelBuilderExtensions.cs @@ -34,7 +34,6 @@ public static ModelBuilder HasDefaultContainer( this ModelBuilder modelBuilder, string? name) { - Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullButNotEmpty(name, nameof(name)); modelBuilder.Model.SetDefaultContainer(name); diff --git a/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs index 773e275849b..4edb2ddb242 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs @@ -36,7 +36,6 @@ public static PropertyBuilder ToJsonProperty( this PropertyBuilder propertyBuilder, string name) { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); Check.NotNull(name, nameof(name)); propertyBuilder.Metadata.SetJsonPropertyName(name); @@ -118,11 +117,11 @@ public static bool CanSetJsonProperty( /// The same builder instance so that multiple calls can be chained. public static PropertyBuilder IsETagConcurrency(this PropertyBuilder propertyBuilder) { - Check.NotNull(propertyBuilder, nameof(propertyBuilder)); propertyBuilder .IsConcurrencyToken() .ToJsonProperty("_etag") .ValueGeneratedOnAddOrUpdate(); + return propertyBuilder; } diff --git a/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs index 21ceb6d6fc9..bab7af88752 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs @@ -43,7 +43,6 @@ public static IQueryable WithPartitionKey( [NotParameterized] string partitionKey) where TEntity : class { - Check.NotNull(source, nameof(source)); Check.NotNull(partitionKey, nameof(partitionKey)); return @@ -90,7 +89,6 @@ public static IQueryable FromSqlRaw( params object[] parameters) where TEntity : class { - Check.NotNull(source, nameof(source)); Check.NotEmpty(sql, nameof(sql)); Check.NotNull(parameters, nameof(parameters)); diff --git a/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs index b937e3587f5..756fa1b29b5 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosServiceCollectionExtensions.cs @@ -15,7 +15,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.EntityFrameworkCore.ValueGeneration; // ReSharper disable once CheckNamespace @@ -70,17 +69,12 @@ public static IServiceCollection AddCosmos( Action? cosmosOptionsAction = null, Action? optionsAction = null) where TContext : DbContext - { - Check.NotNull(serviceCollection, nameof(serviceCollection)); - Check.NotEmpty(databaseName, nameof(databaseName)); - - return serviceCollection.AddDbContext( + => serviceCollection.AddDbContext( (serviceProvider, options) => { optionsAction?.Invoke(options); options.UseCosmos(connectionString, databaseName, cosmosOptionsAction); }); - } /// /// @@ -106,8 +100,6 @@ public static IServiceCollection AddCosmos( [EditorBrowsable(EditorBrowsableState.Never)] public static IServiceCollection AddEntityFrameworkCosmos(this IServiceCollection serviceCollection) { - Check.NotNull(serviceCollection, nameof(serviceCollection)); - var builder = new EntityFrameworkServicesBuilder(serviceCollection) .TryAdd() .TryAdd>() diff --git a/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs b/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs index e6fdbe83eee..14a3aa5e3e3 100644 --- a/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs +++ b/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs @@ -40,8 +40,6 @@ public class CosmosDbContextOptionsBuilder : ICosmosDbContextOptionsBuilderInfra /// The options builder. public CosmosDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder) { - Check.NotNull(optionsBuilder, nameof(optionsBuilder)); - _optionsBuilder = optionsBuilder; } diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs index e18af087803..16c85a5c20a 100644 --- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs +++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal @@ -614,8 +613,6 @@ public override bool ShouldUseSameServiceProvider(DbContextOptionsExtensionInfo public override void PopulateDebugInfo(IDictionary debugInfo) { - Check.NotNull(debugInfo, nameof(debugInfo)); - if (!string.IsNullOrEmpty(Extension._connectionString)) { debugInfo["Cosmos:" + nameof(ConnectionString)] = diff --git a/src/EFCore.Cosmos/Metadata/Conventions/ContextContainerConvention.cs b/src/EFCore.Cosmos/Metadata/Conventions/ContextContainerConvention.cs index cb6d4b122bd..2bafe06651e 100644 --- a/src/EFCore.Cosmos/Metadata/Conventions/ContextContainerConvention.cs +++ b/src/EFCore.Cosmos/Metadata/Conventions/ContextContainerConvention.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { @@ -38,11 +37,6 @@ public ContextContainerConvention(ProviderConventionSetBuilderDependencies depen public virtual void ProcessModelInitialized( IConventionModelBuilder modelBuilder, IConventionContext context) - { - Check.NotNull(modelBuilder, nameof(modelBuilder)); - Check.NotNull(context, nameof(context)); - - modelBuilder.HasDefaultContainer(Dependencies.ContextType.Name); - } + => modelBuilder.HasDefaultContainer(Dependencies.ContextType.Name); } } diff --git a/src/EFCore.Cosmos/Metadata/Conventions/CosmosKeyDiscoveryConvention.cs b/src/EFCore.Cosmos/Metadata/Conventions/CosmosKeyDiscoveryConvention.cs index 4e3955a7e16..70bf609f4d2 100644 --- a/src/EFCore.Cosmos/Metadata/Conventions/CosmosKeyDiscoveryConvention.cs +++ b/src/EFCore.Cosmos/Metadata/Conventions/CosmosKeyDiscoveryConvention.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { @@ -45,10 +44,6 @@ public virtual void ProcessEntityTypeAnnotationChanged( IConventionAnnotation? oldAnnotation, IConventionContext context) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - Check.NotEmpty(name, nameof(name)); - Check.NotNull(context, nameof(context)); - if (name == CosmosAnnotationNames.PartitionKeyName) { TryConfigurePrimaryKey(entityTypeBuilder); diff --git a/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs b/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs index 8157d3a77e0..2749fdbd1f1 100644 --- a/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs +++ b/src/EFCore.Cosmos/Metadata/Conventions/CosmosManyToManyJoinEntityTypeConvention.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { @@ -46,10 +45,6 @@ public virtual void ProcessEntityTypeAnnotationChanged( IConventionAnnotation? oldAnnotation, IConventionContext context) { - Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - Check.NotEmpty(name, nameof(name)); - Check.NotNull(context, nameof(context)); - if (name == CosmosAnnotationNames.PartitionKeyName || name == CosmosAnnotationNames.ContainerName) { diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosDateTimeMemberTranslator.cs b/src/EFCore.Cosmos/Query/Internal/CosmosDateTimeMemberTranslator.cs index b4c6f296027..c7e272b1a16 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosDateTimeMemberTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosDateTimeMemberTranslator.cs @@ -4,7 +4,6 @@ using System; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -41,10 +40,6 @@ public CosmosDateTimeMemberTranslator(ISqlExpressionFactory sqlExpressionFactory 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) || declaringType == typeof(DateTimeOffset)) diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs index b2f4861093a..5dca76ba59c 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -52,14 +51,8 @@ public CosmosMemberTranslatorProvider( MemberInfo member, Type returnType, IDiagnosticsLogger logger) - { - Check.NotNull(member, nameof(member)); - Check.NotNull(returnType, nameof(returnType)); - Check.NotNull(logger, nameof(logger)); - - return _plugins.Concat(_translators) + => _plugins.Concat(_translators) .Select(t => t.Translate(instance, member, returnType, logger)).FirstOrDefault(t => t != null); - } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs index e90044370c0..c86d1a0b181 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs @@ -60,16 +60,9 @@ public CosmosMethodCallTranslatorProvider( MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) - { - Check.NotNull(model, nameof(model)); - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - - return _plugins.Concat(_translators) + => _plugins.Concat(_translators) .Select(t => t.Translate(instance, method, arguments, logger)) .FirstOrDefault(t => t != null); - } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs index ba5333cb157..5e42398da9e 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs @@ -221,8 +221,6 @@ protected override Expression VisitConditional(ConditionalExpression conditional /// protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - switch (extensionExpression) { case EntityShaperExpression entityShaperExpression: @@ -296,8 +294,6 @@ protected override ElementInit VisitElementInit(ElementInit elementInit) /// protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - if (!_clientEval) { return null; @@ -445,8 +441,6 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment membe /// protected override Expression VisitMemberInit(MemberInitExpression memberInitExpression) { - Check.NotNull(memberInitExpression, nameof(memberInitExpression)); - var newExpression = Visit(memberInitExpression.NewExpression); if (newExpression == null) { @@ -480,8 +474,6 @@ protected override Expression VisitMemberInit(MemberInitExpression memberInitExp /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (methodCallExpression.TryGetEFPropertyArguments(out var source, out var memberName) || methodCallExpression.TryGetIndexerArguments(_model, out source, out memberName)) { @@ -663,8 +655,6 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp /// protected override Expression VisitNew(NewExpression newExpression) { - Check.NotNull(newExpression, nameof(newExpression)); - if (newExpression.Arguments.Count == 0) { return newExpression; diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContextFactory.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContextFactory.cs index 638b318066c..13da1ec193d 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContextFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContextFactory.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; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal @@ -29,8 +28,6 @@ public class CosmosQueryCompilationContextFactory : IQueryCompilationContextFact /// public CosmosQueryCompilationContextFactory(QueryCompilationContextDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryContext.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryContext.cs index 6f8c7c7c951..310797f0445 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryContext.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryContext.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -26,8 +25,6 @@ public CosmosQueryContext( ICosmosClientWrapper cosmosClient) : base(dependencies) { - Check.NotNull(cosmosClient, nameof(cosmosClient)); - CosmosClient = cosmosClient; } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryContextFactory.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryContextFactory.cs index aa6f95cb306..e4d2bd03e36 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryContextFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryContextFactory.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -27,9 +26,6 @@ public CosmosQueryContextFactory( QueryContextDependencies dependencies, ICosmosClientWrapper cosmosClient) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(cosmosClient, nameof(cosmosClient)); - Dependencies = dependencies; _cosmosClient = cosmosClient; } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs index 5ec21483f2e..473491e58cd 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Linq.Expressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -24,7 +23,6 @@ public class CosmosQueryMetadataExtractingExpressionVisitor : ExpressionVisitor /// public CosmosQueryMetadataExtractingExpressionVisitor(CosmosQueryCompilationContext cosmosQueryCompilationContext) { - Check.NotNull(cosmosQueryCompilationContext, nameof(cosmosQueryCompilationContext)); _cosmosQueryCompilationContext = cosmosQueryCompilationContext; } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessor.cs index 6c61757941d..ad7e54c172a 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessor.cs @@ -3,7 +3,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -29,8 +28,6 @@ public CosmosQueryTranslationPostprocessor( QueryCompilationContext queryCompilationContext) : base(dependencies, queryCompilationContext) { - Check.NotNull(sqlExpressionFactory, nameof(sqlExpressionFactory)); - _sqlExpressionFactory = sqlExpressionFactory; } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessorFactory.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessorFactory.cs index ff41b3c04b2..af9fbec3ca2 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPostprocessorFactory.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.Cosmos.Query.Internal { @@ -42,13 +41,9 @@ public CosmosQueryTranslationPostprocessorFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QueryTranslationPostprocessor Create(QueryCompilationContext queryCompilationContext) - { - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - - return new CosmosQueryTranslationPostprocessor( + => new CosmosQueryTranslationPostprocessor( Dependencies, _sqlExpressionFactory, queryCompilationContext); - } } } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.cs index 2c262076f50..8d9616bee31 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.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.Cosmos.Query.Internal { @@ -23,7 +22,6 @@ public class CosmosQueryTranslationPreprocessorFactory : IQueryTranslationPrepro public CosmosQueryTranslationPreprocessorFactory( QueryTranslationPreprocessorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); Dependencies = dependencies; } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs index c1b9cbe0c81..63cfc272225 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs @@ -221,11 +221,7 @@ protected override QueryableMethodTranslatingExpressionVisitor CreateSubqueryVis /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override ShapedQueryExpression TranslateSubquery(Expression expression) - { - Check.NotNull(expression, nameof(expression)); - - throw new InvalidOperationException(CoreStrings.TranslationFailed(expression.Print())); - } + => throw new InvalidOperationException(CoreStrings.TranslationFailed(expression.Print())); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -236,8 +232,6 @@ public override ShapedQueryExpression TranslateSubquery(Expression expression) [Obsolete("Use overload which takes IEntityType.")] protected override ShapedQueryExpression CreateShapedQueryExpression(Type elementType) { - Check.NotNull(elementType, nameof(elementType)); - var entityType = _queryCompilationContext.Model.FindEntityType(elementType); var selectExpression = _sqlExpressionFactory.Select(entityType); @@ -260,8 +254,6 @@ protected override ShapedQueryExpression CreateShapedQueryExpression(Type elemen /// protected override ShapedQueryExpression CreateShapedQueryExpression(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - var selectExpression = _sqlExpressionFactory.Select(entityType); return CreateShapedQueryExpression(entityType, selectExpression); @@ -282,12 +274,7 @@ private ShapedQueryExpression CreateShapedQueryExpression(IEntityType entityType /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateAll(ShapedQueryExpression source, LambdaExpression predicate) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -296,11 +283,7 @@ protected override ShapedQueryExpression TranslateAll(ShapedQueryExpression sour /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateAny(ShapedQueryExpression source, LambdaExpression predicate) - { - Check.NotNull(source, nameof(source)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -310,9 +293,6 @@ protected override ShapedQueryExpression TranslateAny(ShapedQueryExpression sour /// protected override ShapedQueryExpression TranslateAverage(ShapedQueryExpression source, LambdaExpression selector, Type resultType) { - Check.NotNull(source, nameof(source)); - Check.NotNull(resultType, nameof(resultType)); - var selectExpression = (SelectExpression)source.QueryExpression; if (selectExpression.IsDistinct || selectExpression.Limit != null @@ -340,14 +320,9 @@ protected override ShapedQueryExpression TranslateAverage(ShapedQueryExpression /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateCast(ShapedQueryExpression source, Type resultType) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(resultType, nameof(resultType)); - - return source.ShaperExpression.Type != resultType + => source.ShaperExpression.Type != resultType ? source.UpdateShaperExpression(Expression.Convert(source.ShaperExpression, resultType)) : source; - } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -356,12 +331,7 @@ protected override ShapedQueryExpression TranslateCast(ShapedQueryExpression sou /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateConcat(ShapedQueryExpression source1, ShapedQueryExpression source2) - { - Check.NotNull(source1, nameof(source1)); - Check.NotNull(source2, nameof(source2)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -370,12 +340,7 @@ protected override ShapedQueryExpression TranslateConcat(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateContains(ShapedQueryExpression source, Expression item) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(item, nameof(item)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -385,8 +350,6 @@ protected override ShapedQueryExpression TranslateContains(ShapedQueryExpression /// protected override ShapedQueryExpression TranslateCount(ShapedQueryExpression source, LambdaExpression predicate) { - Check.NotNull(source, nameof(source)); - var selectExpression = (SelectExpression)source.QueryExpression; if (selectExpression.IsDistinct || selectExpression.Limit != null @@ -424,11 +387,7 @@ protected override ShapedQueryExpression TranslateCount(ShapedQueryExpression so /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateDefaultIfEmpty(ShapedQueryExpression source, Expression defaultValue) - { - Check.NotNull(source, nameof(source)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -438,8 +397,6 @@ protected override ShapedQueryExpression TranslateDefaultIfEmpty(ShapedQueryExpr /// protected override ShapedQueryExpression TranslateDistinct(ShapedQueryExpression source) { - Check.NotNull(source, nameof(source)); - ((SelectExpression)source.QueryExpression).ApplyDistinct(); return source; @@ -455,12 +412,7 @@ protected override ShapedQueryExpression TranslateElementAtOrDefault( ShapedQueryExpression source, Expression index, bool returnDefault) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(index, nameof(index)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -469,12 +421,7 @@ protected override ShapedQueryExpression TranslateElementAtOrDefault( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateExcept(ShapedQueryExpression source1, ShapedQueryExpression source2) - { - Check.NotNull(source1, nameof(source1)); - Check.NotNull(source2, nameof(source2)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -488,9 +435,6 @@ protected override ShapedQueryExpression TranslateFirstOrDefault( Type returnType, bool returnDefault) { - Check.NotNull(source, nameof(source)); - Check.NotNull(returnType, nameof(returnType)); - if (predicate != null) { source = TranslateWhere(source, predicate); @@ -525,12 +469,7 @@ protected override ShapedQueryExpression TranslateGroupBy( LambdaExpression keySelector, LambdaExpression elementSelector, LambdaExpression resultSelector) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(keySelector, nameof(keySelector)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -544,15 +483,7 @@ protected override ShapedQueryExpression TranslateGroupJoin( LambdaExpression outerKeySelector, LambdaExpression innerKeySelector, LambdaExpression resultSelector) - { - Check.NotNull(outer, nameof(outer)); - Check.NotNull(inner, nameof(inner)); - Check.NotNull(outerKeySelector, nameof(outerKeySelector)); - Check.NotNull(innerKeySelector, nameof(innerKeySelector)); - Check.NotNull(resultSelector, nameof(resultSelector)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -561,12 +492,7 @@ protected override ShapedQueryExpression TranslateGroupJoin( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateIntersect(ShapedQueryExpression source1, ShapedQueryExpression source2) - { - Check.NotNull(source1, nameof(source1)); - Check.NotNull(source2, nameof(source2)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -580,15 +506,7 @@ protected override ShapedQueryExpression TranslateJoin( LambdaExpression outerKeySelector, LambdaExpression innerKeySelector, LambdaExpression resultSelector) - { - Check.NotNull(outer, nameof(outer)); - Check.NotNull(inner, nameof(inner)); - Check.NotNull(outerKeySelector, nameof(outerKeySelector)); - Check.NotNull(innerKeySelector, nameof(innerKeySelector)); - Check.NotNull(resultSelector, nameof(resultSelector)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -602,9 +520,6 @@ protected override ShapedQueryExpression TranslateLastOrDefault( Type returnType, bool returnDefault) { - Check.NotNull(source, nameof(source)); - Check.NotNull(returnType, nameof(returnType)); - if (predicate != null) { source = TranslateWhere(source, predicate); @@ -635,15 +550,7 @@ protected override ShapedQueryExpression TranslateLeftJoin( LambdaExpression outerKeySelector, LambdaExpression innerKeySelector, LambdaExpression resultSelector) - { - Check.NotNull(outer, nameof(outer)); - Check.NotNull(inner, nameof(inner)); - Check.NotNull(outerKeySelector, nameof(outerKeySelector)); - Check.NotNull(innerKeySelector, nameof(innerKeySelector)); - Check.NotNull(resultSelector, nameof(resultSelector)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -653,8 +560,6 @@ protected override ShapedQueryExpression TranslateLeftJoin( /// protected override ShapedQueryExpression TranslateLongCount(ShapedQueryExpression source, LambdaExpression predicate) { - Check.NotNull(source, nameof(source)); - var selectExpression = (SelectExpression)source.QueryExpression; if (selectExpression.IsDistinct || selectExpression.Limit != null @@ -692,8 +597,6 @@ protected override ShapedQueryExpression TranslateLongCount(ShapedQueryExpressio /// protected override ShapedQueryExpression TranslateMax(ShapedQueryExpression source, LambdaExpression selector, Type resultType) { - Check.NotNull(source, nameof(source)); - var selectExpression = (SelectExpression)source.QueryExpression; if (selectExpression.IsDistinct || selectExpression.Limit != null @@ -722,8 +625,6 @@ protected override ShapedQueryExpression TranslateMax(ShapedQueryExpression sour /// protected override ShapedQueryExpression TranslateMin(ShapedQueryExpression source, LambdaExpression selector, Type resultType) { - Check.NotNull(source, nameof(source)); - var selectExpression = (SelectExpression)source.QueryExpression; if (selectExpression.IsDistinct || selectExpression.Limit != null @@ -752,9 +653,6 @@ protected override ShapedQueryExpression TranslateMin(ShapedQueryExpression sour /// protected override ShapedQueryExpression TranslateOfType(ShapedQueryExpression source, Type resultType) { - Check.NotNull(source, nameof(source)); - Check.NotNull(resultType, nameof(resultType)); - if (source.ShaperExpression is EntityShaperExpression entityShaperExpression) { var entityType = entityShaperExpression.EntityType; @@ -816,9 +714,6 @@ protected override ShapedQueryExpression TranslateOrderBy( LambdaExpression keySelector, bool ascending) { - Check.NotNull(source, nameof(source)); - Check.NotNull(keySelector, nameof(keySelector)); - var translation = TranslateLambdaExpression(source, keySelector); if (translation != null) { @@ -838,8 +733,6 @@ protected override ShapedQueryExpression TranslateOrderBy( /// protected override ShapedQueryExpression TranslateReverse(ShapedQueryExpression source) { - Check.NotNull(source, nameof(source)); - var selectExpression = (SelectExpression)source.QueryExpression; if (selectExpression.Orderings.Count == 0) { @@ -860,9 +753,6 @@ protected override ShapedQueryExpression TranslateReverse(ShapedQueryExpression /// protected override ShapedQueryExpression TranslateSelect(ShapedQueryExpression source, LambdaExpression selector) { - Check.NotNull(source, nameof(source)); - Check.NotNull(selector, nameof(selector)); - if (selector.Body == selector.Parameters[0]) { return source; @@ -889,13 +779,7 @@ protected override ShapedQueryExpression TranslateSelectMany( ShapedQueryExpression source, LambdaExpression collectionSelector, LambdaExpression resultSelector) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(collectionSelector, nameof(collectionSelector)); - Check.NotNull(resultSelector, nameof(resultSelector)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -904,12 +788,7 @@ protected override ShapedQueryExpression TranslateSelectMany( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateSelectMany(ShapedQueryExpression source, LambdaExpression selector) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(selector, nameof(selector)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -923,9 +802,6 @@ protected override ShapedQueryExpression TranslateSingleOrDefault( Type returnType, bool returnDefault) { - Check.NotNull(source, nameof(source)); - Check.NotNull(returnType, nameof(returnType)); - if (predicate != null) { source = TranslateWhere(source, predicate); @@ -951,9 +827,6 @@ protected override ShapedQueryExpression TranslateSingleOrDefault( /// protected override ShapedQueryExpression TranslateSkip(ShapedQueryExpression source, Expression count) { - Check.NotNull(source, nameof(source)); - Check.NotNull(count, nameof(count)); - var selectExpression = (SelectExpression)source.QueryExpression; var translation = TranslateExpression(count); @@ -979,12 +852,7 @@ protected override ShapedQueryExpression TranslateSkip(ShapedQueryExpression sou /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateSkipWhile(ShapedQueryExpression source, LambdaExpression predicate) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -994,9 +862,6 @@ protected override ShapedQueryExpression TranslateSkipWhile(ShapedQueryExpressio /// protected override ShapedQueryExpression TranslateSum(ShapedQueryExpression source, LambdaExpression selector, Type resultType) { - Check.NotNull(source, nameof(source)); - Check.NotNull(resultType, nameof(resultType)); - var selectExpression = (SelectExpression)source.QueryExpression; if (selectExpression.IsDistinct || selectExpression.Limit != null @@ -1027,9 +892,6 @@ protected override ShapedQueryExpression TranslateSum(ShapedQueryExpression sour /// protected override ShapedQueryExpression TranslateTake(ShapedQueryExpression source, Expression count) { - Check.NotNull(source, nameof(source)); - Check.NotNull(count, nameof(count)); - var selectExpression = (SelectExpression)source.QueryExpression; var translation = TranslateExpression(count); @@ -1055,12 +917,7 @@ protected override ShapedQueryExpression TranslateTake(ShapedQueryExpression sou /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateTakeWhile(ShapedQueryExpression source, LambdaExpression predicate) - { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1070,9 +927,6 @@ protected override ShapedQueryExpression TranslateTakeWhile(ShapedQueryExpressio /// protected override ShapedQueryExpression TranslateThenBy(ShapedQueryExpression source, LambdaExpression keySelector, bool ascending) { - Check.NotNull(source, nameof(source)); - Check.NotNull(keySelector, nameof(keySelector)); - var translation = TranslateLambdaExpression(source, keySelector); if (translation != null) { @@ -1091,12 +945,7 @@ protected override ShapedQueryExpression TranslateThenBy(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateUnion(ShapedQueryExpression source1, ShapedQueryExpression source2) - { - Check.NotNull(source1, nameof(source1)); - Check.NotNull(source2, nameof(source2)); - - return null; - } + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1106,9 +955,6 @@ protected override ShapedQueryExpression TranslateUnion(ShapedQueryExpression so /// protected override ShapedQueryExpression TranslateWhere(ShapedQueryExpression source, LambdaExpression predicate) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - if (source.ShaperExpression is EntityShaperExpression entityShaperExpression && entityShaperExpression.EntityType.GetPartitionKeyPropertyName() != null && TryExtractPartitionKey(predicate.Body, entityShaperExpression.EntityType, out var newPredicate) is Expression @@ -1237,9 +1083,7 @@ private SqlExpression TranslateLambdaExpression( } private static Expression RemapLambdaBody(Expression shaperBody, LambdaExpression lambdaExpression) - { - return ReplacingExpressionVisitor.Replace(lambdaExpression.Parameters.Single(), shaperBody, lambdaExpression.Body); - } + => ReplacingExpressionVisitor.Replace(lambdaExpression.Parameters.Single(), shaperBody, lambdaExpression.Body); private ShapedQueryExpression AggregateResultShaper( ShapedQueryExpression source, diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitorFactory.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitorFactory.cs index 30a28753441..44828aa71d0 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitorFactory.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.Cosmos.Query.Internal { @@ -48,15 +47,11 @@ public CosmosQueryableMethodTranslatingExpressionVisitorFactory( /// 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 CosmosQueryableMethodTranslatingExpressionVisitor( + => new CosmosQueryableMethodTranslatingExpressionVisitor( Dependencies, queryCompilationContext, _sqlExpressionFactory, _memberTranslatorProvider, _methodCallTranslatorProvider); - } } } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs index 96c869ce780..227787cd883 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs @@ -79,8 +79,6 @@ public CosmosProjectionBindingRemovingExpressionVisitorBase( protected override Expression VisitBinary(BinaryExpression binaryExpression) { - Check.NotNull(binaryExpression, nameof(binaryExpression)); - if (binaryExpression.NodeType == ExpressionType.Assign) { if (binaryExpression.Left is ParameterExpression parameterExpression) @@ -180,8 +178,6 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - var method = methodCallExpression.Method; var genericMethod = method.IsGenericMethod ? method.GetGenericMethodDefinition() : null; if (genericMethod == EntityFrameworkCore.Infrastructure.ExpressionExtensions.ValueBufferTryReadValueMethod) @@ -234,8 +230,6 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - switch (extensionExpression) { case ProjectionBindingExpression projectionBindingExpression: diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.JObjectInjectingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.JObjectInjectingExpressionVisitor.cs index e1b5bfc0f79..0ed4585e96b 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.JObjectInjectingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.JObjectInjectingExpressionVisitor.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; using Newtonsoft.Json.Linq; #nullable disable @@ -19,8 +18,6 @@ private sealed class JObjectInjectingExpressionVisitor : ExpressionVisitor protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - switch (extensionExpression) { case EntityShaperExpression shaperExpression: diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs index 5045fc389f5..2c89bd33745 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; using Newtonsoft.Json.Linq; #nullable disable @@ -54,8 +53,6 @@ public CosmosShapedQueryCompilingExpressionVisitor( /// protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQueryExpression) { - Check.NotNull(shapedQueryExpression, nameof(shapedQueryExpression)); - var jObjectParameter = Expression.Parameter(typeof(JObject), "jObject"); var shaperBody = shapedQueryExpression.ShaperExpression; diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitorFactory.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitorFactory.cs index 70f4ba359a1..9fc859f8dca 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitorFactory.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; #nullable disable @@ -30,10 +29,6 @@ public CosmosShapedQueryCompilingExpressionVisitorFactory( ISqlExpressionFactory sqlExpressionFactory, IQuerySqlGeneratorFactory querySqlGeneratorFactory) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(sqlExpressionFactory, nameof(sqlExpressionFactory)); - Check.NotNull(querySqlGeneratorFactory, nameof(querySqlGeneratorFactory)); - Dependencies = dependencies; _sqlExpressionFactory = sqlExpressionFactory; _querySqlGeneratorFactory = querySqlGeneratorFactory; @@ -51,14 +46,10 @@ public CosmosShapedQueryCompilingExpressionVisitorFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext queryCompilationContext) - { - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - - return new CosmosShapedQueryCompilingExpressionVisitor( + => new CosmosShapedQueryCompilingExpressionVisitor( Dependencies, (CosmosQueryCompilationContext)queryCompilationContext, _sqlExpressionFactory, _querySqlGeneratorFactory); - } } } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs index e40f87be44c..62738da0451 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs @@ -88,8 +88,6 @@ public CosmosSqlTranslatingExpressionVisitor( /// protected virtual void AddTranslationErrorDetails(string details) { - Check.NotNull(details, nameof(details)); - if (TranslationErrorDetails == null) { TranslationErrorDetails = details; @@ -108,8 +106,6 @@ protected virtual void AddTranslationErrorDetails(string details) /// public virtual SqlExpression Translate(Expression expression) { - Check.NotNull(expression, nameof(expression)); - TranslationErrorDetails = null; return TranslateInternal(expression); @@ -145,8 +141,6 @@ private SqlExpression TranslateInternal(Expression expression) /// protected override Expression VisitBinary(BinaryExpression binaryExpression) { - Check.NotNull(binaryExpression, nameof(binaryExpression)); - if (binaryExpression.NodeType == ExpressionType.Coalesce) { var ifTrue = binaryExpression.Left; @@ -241,8 +235,6 @@ static bool TryUnwrapConvertToObject(Expression expression, out Expression opera /// protected override Expression VisitConditional(ConditionalExpression conditionalExpression) { - Check.NotNull(conditionalExpression, nameof(conditionalExpression)); - var test = Visit(conditionalExpression.Test); var ifTrue = Visit(conditionalExpression.IfTrue); var ifFalse = Visit(conditionalExpression.IfFalse); @@ -261,7 +253,7 @@ protected override Expression VisitConditional(ConditionalExpression conditional /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitConstant(ConstantExpression constantExpression) - => new SqlConstantExpression(Check.NotNull(constantExpression, nameof(constantExpression)), null); + => new SqlConstantExpression(constantExpression, null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -271,8 +263,6 @@ protected override Expression VisitConstant(ConstantExpression constantExpressio /// protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - switch (extensionExpression) { case EntityProjectionExpression _: @@ -345,8 +335,6 @@ protected override Expression VisitListInit(ListInitExpression listInitExpressio /// protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - var innerExpression = Visit(memberExpression.Expression); return TryBindMember(innerExpression, MemberIdentity.Create(memberExpression.Member)) @@ -363,7 +351,7 @@ protected override Expression VisitMember(MemberExpression memberExpression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitMemberInit(MemberInitExpression memberInitExpression) - => GetConstantOrNull(Check.NotNull(memberInitExpression, nameof(memberInitExpression))); + => GetConstantOrNull(memberInitExpression); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -373,8 +361,6 @@ protected override Expression VisitMemberInit(MemberInitExpression memberInitExp /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (methodCallExpression.TryGetEFPropertyArguments(out var source, out var propertyName) || methodCallExpression.TryGetIndexerArguments(_model, out source, out propertyName)) { @@ -539,7 +525,7 @@ static Expression RemoveObjectConvert(Expression expression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitNew(NewExpression newExpression) - => GetConstantOrNull(Check.NotNull(newExpression, nameof(newExpression))); + => GetConstantOrNull(newExpression); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -558,7 +544,7 @@ protected override Expression VisitNewArray(NewArrayExpression newArrayExpressio /// protected override Expression VisitParameter(ParameterExpression parameterExpression) => parameterExpression.Name?.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal) == true - ? new SqlParameterExpression(Check.NotNull(parameterExpression, nameof(parameterExpression)), null) + ? new SqlParameterExpression(parameterExpression, null) : null; /// @@ -569,8 +555,6 @@ protected override Expression VisitParameter(ParameterExpression parameterExpres /// protected override Expression VisitUnary(UnaryExpression unaryExpression) { - Check.NotNull(unaryExpression, nameof(unaryExpression)); - var operand = Visit(unaryExpression.Operand); if (operand is EntityReferenceExpression entityReferenceExpression @@ -617,8 +601,6 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) /// protected override Expression VisitTypeBinary(TypeBinaryExpression typeBinaryExpression) { - Check.NotNull(typeBinaryExpression, nameof(typeBinaryExpression)); - var innerExpression = Visit(typeBinaryExpression.Expression); if (typeBinaryExpression.NodeType == ExpressionType.TypeIs @@ -1013,8 +995,6 @@ private sealed class SqlTypeMappingVerifyingExpressionVisitor : ExpressionVisito { protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - if (extensionExpression is SqlExpression sqlExpression && sqlExpression.TypeMapping == null) { diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosStringMemberTranslator.cs b/src/EFCore.Cosmos/Query/Internal/CosmosStringMemberTranslator.cs index 880b8bb176a..b993cbf3606 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosStringMemberTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosStringMemberTranslator.cs @@ -4,7 +4,6 @@ using System; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -41,10 +40,6 @@ public CosmosStringMemberTranslator(ISqlExpressionFactory sqlExpressionFactory) 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.Cosmos/Query/Internal/CosmosValueConverterCompensatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosValueConverterCompensatingExpressionVisitor.cs index 8323ed9043b..fd70984f118 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosValueConverterCompensatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosValueConverterCompensatingExpressionVisitor.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -56,8 +55,6 @@ private Expression VisitShapedQueryExpression(ShapedQueryExpression shapedQueryE private Expression VisitSelect(SelectExpression selectExpression) { - Check.NotNull(selectExpression, nameof(selectExpression)); - var changed = false; var projections = new List(); @@ -92,8 +89,6 @@ private Expression VisitSelect(SelectExpression selectExpression) private Expression VisitSqlConditional(SqlConditionalExpression sqlConditionalExpression) { - Check.NotNull(sqlConditionalExpression, nameof(sqlConditionalExpression)); - var test = TryCompensateForBoolWithValueConverter((SqlExpression)Visit(sqlConditionalExpression.Test)); var ifTrue = (SqlExpression)Visit(sqlConditionalExpression.IfTrue); var ifFalse = (SqlExpression)Visit(sqlConditionalExpression.IfFalse); diff --git a/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs index 9ceb138b18b..2c837162b23 100644 --- a/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable @@ -89,11 +88,7 @@ public override Type Type /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return Update(visitor.Visit(AccessExpression)); - } + => Update(visitor.Visit(AccessExpression)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -242,8 +237,6 @@ private Expression BindMember(MemberIdentity member, Type entityClrType, bool cl /// public virtual EntityProjectionExpression UpdateEntityType(IEntityType derivedType) { - Check.NotNull(derivedType, nameof(derivedType)); - if (!derivedType.GetAllBaseTypes().Contains(EntityType)) { throw new InvalidOperationException( @@ -262,8 +255,6 @@ public virtual EntityProjectionExpression UpdateEntityType(IEntityType derivedTy /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Visit(AccessExpression); } diff --git a/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs b/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs index bbcb69623d1..e943801e3d5 100644 --- a/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -42,10 +41,6 @@ public EqualsTranslator(ISqlExpressionFactory sqlExpressionFactory) IReadOnlyList arguments, IDiagnosticsLogger logger) { - Check.NotNull(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - Check.NotNull(logger, nameof(logger)); - SqlExpression? left = null; SqlExpression? right = null; diff --git a/src/EFCore.Cosmos/Query/Internal/FromSqlExpression.cs b/src/EFCore.Cosmos/Query/Internal/FromSqlExpression.cs index 6b27dba153a..18a40c8071a 100644 --- a/src/EFCore.Cosmos/Query/Internal/FromSqlExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/FromSqlExpression.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable @@ -28,9 +27,6 @@ public class FromSqlExpression : RootReferenceExpression, IPrintableExpression public FromSqlExpression(IEntityType entityType, string alias, string sql, Expression arguments) : base(entityType, alias) { - Check.NotEmpty(sql, nameof(sql)); - Check.NotNull(arguments, nameof(arguments)); - Sql = sql; Arguments = arguments; } @@ -62,21 +58,13 @@ public override string Alias /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual FromSqlExpression Update(Expression arguments) - { - Check.NotNull(arguments, nameof(arguments)); - - return arguments != Arguments + => arguments != Arguments ? new FromSqlExpression(EntityType, Alias, Sql, arguments) : this; - } /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; /// public override Type Type @@ -85,8 +73,6 @@ public override Type Type /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Append(Sql); } diff --git a/src/EFCore.Cosmos/Query/Internal/FromSqlQueryRootExpression.cs b/src/EFCore.Cosmos/Query/Internal/FromSqlQueryRootExpression.cs index 046470a56a2..961e063c101 100644 --- a/src/EFCore.Cosmos/Query/Internal/FromSqlQueryRootExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/FromSqlQueryRootExpression.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -31,9 +30,6 @@ public FromSqlQueryRootExpression( Expression argument) : base(queryProvider, entityType) { - Check.NotEmpty(sql, nameof(sql)); - Check.NotNull(argument, nameof(argument)); - Sql = sql; Argument = argument; } @@ -50,9 +46,6 @@ public FromSqlQueryRootExpression( Expression argument) : base(entityType) { - Check.NotEmpty(sql, nameof(sql)); - Check.NotNull(argument, nameof(argument)); - Sql = sql; Argument = argument; } @@ -117,8 +110,6 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// protected override void Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - base.Print(expressionPrinter); expressionPrinter.Append($".FromSql({Sql}, "); expressionPrinter.Visit(Argument); diff --git a/src/EFCore.Cosmos/Query/Internal/InExpression.cs b/src/EFCore.Cosmos/Query/Internal/InExpression.cs index 5cf2a6d1e7e..aacaeb2bafb 100644 --- a/src/EFCore.Cosmos/Query/Internal/InExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/InExpression.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -101,8 +100,6 @@ public virtual InExpression Update(SqlExpression item, SqlExpression values) /// protected override void Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Visit(Item); expressionPrinter.Append(IsNegated ? " NOT IN " : " IN "); expressionPrinter.Append("("); diff --git a/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs b/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs index eed96287de9..a36376fcde9 100644 --- a/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs @@ -66,11 +66,7 @@ public KeyAccessExpression(IProperty property, Expression accessExpression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return Update(visitor.Visit(AccessExpression)); - } + => Update(visitor.Visit(AccessExpression)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -90,11 +86,7 @@ public virtual KeyAccessExpression Update(Expression outerExpression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override void Print(ExpressionPrinter expressionPrinter) - { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - - expressionPrinter.Append(ToString()); - } + => expressionPrinter.Append(ToString()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/MathTranslator.cs b/src/EFCore.Cosmos/Query/Internal/MathTranslator.cs index 465a1571a70..56b2537633d 100644 --- a/src/EFCore.Cosmos/Query/Internal/MathTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/MathTranslator.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -101,10 +100,6 @@ public MathTranslator(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.Cosmos/Query/Internal/ObjectAccessExpression.cs b/src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs index 9bed2194fa1..5eeeb057523 100644 --- a/src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable @@ -89,11 +88,7 @@ public override Type Type /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return Update(visitor.Visit(AccessExpression)); - } + => Update(visitor.Visit(AccessExpression)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -113,11 +108,7 @@ public virtual ObjectAccessExpression Update(Expression outerExpression) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) - { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - - expressionPrinter.Append(ToString()); - } + => expressionPrinter.Append(ToString()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs index a7b2a7d0aa5..3652867f21c 100644 --- a/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable warnings @@ -108,8 +107,6 @@ public sealed override ExpressionType NodeType /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var accessExpression = visitor.Visit(AccessExpression); var innerProjection = visitor.Visit(InnerProjection); @@ -136,11 +133,7 @@ public virtual ObjectArrayProjectionExpression Update( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) - { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - - expressionPrinter.Append(ToString()); - } + => expressionPrinter.Append(ToString()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs b/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs index 35bd00c885f..618e24d5c3d 100644 --- a/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -69,11 +68,7 @@ public override Type Type /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return Update((SqlExpression)visitor.Visit(Expression)); - } + => Update((SqlExpression)visitor.Visit(Expression)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -94,10 +89,7 @@ public virtual OrderingExpression Update(SqlExpression expression) /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Visit(Expression); - expressionPrinter.Append(IsAscending ? " ASC" : " DESC"); } diff --git a/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs index 8a1bdb2d815..15b86ff7278 100644 --- a/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable @@ -80,11 +79,7 @@ public sealed override ExpressionType NodeType /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return Update(visitor.Visit(Expression)); - } + => Update(visitor.Visit(Expression)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -105,8 +100,6 @@ public virtual ProjectionExpression Update(Expression expression) /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Visit(Expression); if (Alias != string.Empty && Alias != Name) { diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs index 986f13cccc6..1f44bd280d1 100644 --- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs +++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -103,8 +102,6 @@ public virtual CosmosSqlQuery GetSqlQuery( /// protected override Expression VisitEntityProjection(EntityProjectionExpression entityProjectionExpression) { - Check.NotNull(entityProjectionExpression, nameof(entityProjectionExpression)); - Visit(entityProjectionExpression.AccessExpression); return entityProjectionExpression; @@ -118,8 +115,6 @@ protected override Expression VisitEntityProjection(EntityProjectionExpression e /// protected override Expression VisitObjectArrayProjection(ObjectArrayProjectionExpression objectArrayProjectionExpression) { - Check.NotNull(objectArrayProjectionExpression, nameof(objectArrayProjectionExpression)); - _sqlBuilder.Append(objectArrayProjectionExpression.ToString()); return objectArrayProjectionExpression; @@ -133,8 +128,6 @@ protected override Expression VisitObjectArrayProjection(ObjectArrayProjectionEx /// protected override Expression VisitKeyAccess(KeyAccessExpression keyAccessExpression) { - Check.NotNull(keyAccessExpression, nameof(keyAccessExpression)); - _sqlBuilder.Append(keyAccessExpression.ToString()); return keyAccessExpression; @@ -148,8 +141,6 @@ protected override Expression VisitKeyAccess(KeyAccessExpression keyAccessExpres /// protected override Expression VisitObjectAccess(ObjectAccessExpression objectAccessExpression) { - Check.NotNull(objectAccessExpression, nameof(objectAccessExpression)); - _sqlBuilder.Append(objectAccessExpression.ToString()); return objectAccessExpression; @@ -163,8 +154,6 @@ protected override Expression VisitObjectAccess(ObjectAccessExpression objectAcc /// protected override Expression VisitProjection(ProjectionExpression projectionExpression) { - Check.NotNull(projectionExpression, nameof(projectionExpression)); - if (_useValueProjection) { _sqlBuilder.Append('"').Append(projectionExpression.Alias).Append("\" : "); @@ -190,8 +179,6 @@ protected override Expression VisitProjection(ProjectionExpression projectionExp /// protected override Expression VisitRootReference(RootReferenceExpression rootReferenceExpression) { - Check.NotNull(rootReferenceExpression, nameof(rootReferenceExpression)); - _sqlBuilder.Append(rootReferenceExpression.ToString()); return rootReferenceExpression; @@ -205,8 +192,6 @@ protected override Expression VisitRootReference(RootReferenceExpression rootRef /// protected override Expression VisitSelect(SelectExpression selectExpression) { - Check.NotNull(selectExpression, nameof(selectExpression)); - _sqlBuilder.Append("SELECT "); if (selectExpression.IsDistinct) @@ -294,8 +279,6 @@ protected override Expression VisitSelect(SelectExpression selectExpression) /// protected override Expression VisitFromSql(FromSqlExpression fromSqlExpression) { - Check.NotNull(fromSqlExpression, nameof(fromSqlExpression)); - var sql = fromSqlExpression.Sql; string[] substitutions; @@ -366,8 +349,6 @@ fromSqlExpression.Arguments is ConstantExpression constantExpression /// protected override Expression VisitOrdering(OrderingExpression orderingExpression) { - Check.NotNull(orderingExpression, nameof(orderingExpression)); - Visit(orderingExpression.Expression); if (!orderingExpression.IsAscending) @@ -386,8 +367,6 @@ protected override Expression VisitOrdering(OrderingExpression orderingExpressio /// protected override Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpression) { - Check.NotNull(sqlBinaryExpression, nameof(sqlBinaryExpression)); - var op = _operatorMap[sqlBinaryExpression.OperatorType]; _sqlBuilder.Append('('); Visit(sqlBinaryExpression.Left); @@ -414,8 +393,6 @@ protected override Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpres /// protected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpression) { - Check.NotNull(sqlUnaryExpression, nameof(sqlUnaryExpression)); - var op = _operatorMap[sqlUnaryExpression.OperatorType]; if (sqlUnaryExpression.OperatorType == ExpressionType.Not @@ -459,8 +436,6 @@ private void GenerateList( /// protected override Expression VisitSqlConstant(SqlConstantExpression sqlConstantExpression) { - Check.NotNull(sqlConstantExpression, nameof(sqlConstantExpression)); - _sqlBuilder.Append(GenerateConstant(sqlConstantExpression.Value, sqlConstantExpression.TypeMapping)); return sqlConstantExpression; @@ -504,8 +479,6 @@ private JToken GenerateJToken(object value, CoreTypeMapping typeMapping) /// protected override Expression VisitSqlConditional(SqlConditionalExpression sqlConditionalExpression) { - Check.NotNull(sqlConditionalExpression, nameof(sqlConditionalExpression)); - _sqlBuilder.Append('('); Visit(sqlConditionalExpression.Test); _sqlBuilder.Append(" ? "); @@ -525,8 +498,6 @@ protected override Expression VisitSqlConditional(SqlConditionalExpression sqlCo /// protected override Expression VisitSqlParameter(SqlParameterExpression sqlParameterExpression) { - Check.NotNull(sqlParameterExpression, nameof(sqlParameterExpression)); - var parameterName = $"@{sqlParameterExpression.Name}"; if (_sqlParameters.All(sp => sp.Name != parameterName)) @@ -548,8 +519,6 @@ protected override Expression VisitSqlParameter(SqlParameterExpression sqlParame /// protected override Expression VisitIn(InExpression inExpression) { - Check.NotNull(inExpression, nameof(inExpression)); - Visit(inExpression.Item); _sqlBuilder.Append(inExpression.IsNegated ? " NOT IN " : " IN "); _sqlBuilder.Append('('); @@ -570,8 +539,6 @@ protected override Expression VisitIn(InExpression inExpression) /// protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunctionExpression) { - Check.NotNull(sqlFunctionExpression, nameof(sqlFunctionExpression)); - _sqlBuilder.Append(sqlFunctionExpression.Name); _sqlBuilder.Append('('); GenerateList(sqlFunctionExpression.Arguments, e => Visit(e)); diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs index c2c1fb107f1..a7e5f7bbd0e 100644 --- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -24,8 +23,6 @@ public class QuerySqlGeneratorFactory : IQuerySqlGeneratorFactory /// public QuerySqlGeneratorFactory(ITypeMappingSource typeMappingSource) { - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - _typeMappingSource = typeMappingSource; } diff --git a/src/EFCore.Cosmos/Query/Internal/RandomTranslator.cs b/src/EFCore.Cosmos/Query/Internal/RandomTranslator.cs index abb6e54ab4b..ca46651261f 100644 --- a/src/EFCore.Cosmos/Query/Internal/RandomTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/RandomTranslator.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable @@ -46,17 +45,11 @@ public virtual SqlExpression Translate( 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( "RAND", Array.Empty(), method.ReturnType) : null; - } } } diff --git a/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs b/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs index a8b4f5e0c17..390625ff157 100644 --- a/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable @@ -81,9 +80,6 @@ public ReadItemExpression( IEntityType entityType, IDictionary propertyParameters) { - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(propertyParameters, nameof(propertyParameters)); - Container = entityType.GetContainer(); ProjectionExpression = new ProjectionExpression( diff --git a/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs b/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs index ef35ef2669e..df92673efaf 100644 --- a/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable @@ -80,11 +79,7 @@ string IAccessExpression.Name /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs index 4186f4040a9..2827045c082 100644 --- a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Microsoft.EntityFrameworkCore.Utilities; #nullable disable warnings @@ -452,8 +451,6 @@ public sealed override ExpressionType NodeType /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var changed = false; var projections = new List(); @@ -532,9 +529,6 @@ public virtual SelectExpression Update( SqlExpression? limit, SqlExpression? offset) { - Check.NotNull(projections, nameof(projections)); - Check.NotNull(fromExpression, nameof(fromExpression)); - var projectionMapping = new Dictionary(); foreach (var kvp in _projectionMapping) { diff --git a/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs index a600d6f769e..2f898a8b18e 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -63,9 +62,6 @@ public SqlBinaryExpression( CoreTypeMapping? typeMapping) : base(type, typeMapping) { - Check.NotNull(left, nameof(left)); - Check.NotNull(right, nameof(right)); - OperatorType = VerifyOperator(operatorType); Left = left; @@ -104,8 +100,6 @@ public SqlBinaryExpression( /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var left = (SqlExpression)visitor.Visit(Left); var right = (SqlExpression)visitor.Visit(Right); @@ -131,8 +125,6 @@ public virtual SqlBinaryExpression Update(SqlExpression left, SqlExpression righ /// protected override void Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - var requiresBrackets = RequiresBrackets(Left); if (requiresBrackets) diff --git a/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs index 11dd95a7895..9ee73559d50 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -65,8 +64,6 @@ public SqlConditionalExpression( /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var test = (SqlExpression)visitor.Visit(Test); var ifTrue = (SqlExpression)visitor.Visit(IfTrue); var ifFalse = (SqlExpression)visitor.Visit(IfFalse); @@ -96,8 +93,6 @@ public virtual SqlConditionalExpression Update( /// protected override void Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Append("("); expressionPrinter.Visit(Test); expressionPrinter.Append(" ? "); diff --git a/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs index b60864e2667..cc0ed9abe25 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -60,11 +59,7 @@ public virtual SqlExpression ApplyTypeMapping(CoreTypeMapping? typeMapping) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -73,11 +68,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override void Print(ExpressionPrinter expressionPrinter) - { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - - Print(Value, expressionPrinter); - } + => Print(Value, expressionPrinter); private void Print( object? value, diff --git a/src/EFCore.Cosmos/Query/Internal/SqlExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/SqlExpressionVisitor.cs index 5bdc0c898fe..68556d19ebb 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlExpressionVisitor.cs @@ -23,8 +23,6 @@ public abstract class SqlExpressionVisitor : ExpressionVisitor /// protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - switch (extensionExpression) { case ShapedQueryExpression shapedQueryExpression: diff --git a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs index 4638485fba8..96df711f9fe 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -60,8 +59,6 @@ public SqlFunctionExpression( /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var changed = false; var arguments = new SqlExpression[Arguments.Count]; for (var i = 0; i < arguments.Length; i++) @@ -107,8 +104,6 @@ public virtual SqlFunctionExpression Update(IReadOnlyList argumen /// protected override void Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Append(Name); expressionPrinter.Append("("); expressionPrinter.VisitCollection(Arguments); diff --git a/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs index ba5c42f913f..7938ae8185e 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs @@ -60,11 +60,7 @@ public SqlExpression ApplyTypeMapping(CoreTypeMapping? typeMapping) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -73,11 +69,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override void Print(ExpressionPrinter expressionPrinter) - { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - - expressionPrinter.Append("@" + _parameterExpression.Name); - } + => expressionPrinter.Append("@" + _parameterExpression.Name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs index 68eacafcb3d..3f4cb6d0834 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -47,7 +46,6 @@ public SqlUnaryExpression( CoreTypeMapping? typeMapping) : base(type, typeMapping) { - Check.NotNull(operand, nameof(operand)); OperatorType = VerifyOperator(operatorType); Operand = operand; } @@ -75,11 +73,7 @@ public SqlUnaryExpression( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return Update((SqlExpression)visitor.Visit(Operand)); - } + => Update((SqlExpression)visitor.Visit(Operand)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -100,8 +94,6 @@ public virtual SqlUnaryExpression Update(SqlExpression operand) /// protected override void Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Append(OperatorType.ToString()); expressionPrinter.Append("("); expressionPrinter.Visit(Operand); diff --git a/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs b/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs index 845fc5e3efb..2a55e57bbbb 100644 --- a/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -116,10 +115,6 @@ public StringMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) 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.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs index f4097c5f309..760b919466c 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs @@ -4,7 +4,6 @@ using System; using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal @@ -33,8 +32,6 @@ public class CosmosExecutionStrategyFactory : IExecutionStrategyFactory /// public CosmosExecutionStrategyFactory(ExecutionStrategyDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; _createExecutionStrategy = dependencies.Options.FindExtension()?.ExecutionStrategyFactory