diff --git a/src/EFCore/ChangeTracking/ChangeTracker.cs b/src/EFCore/ChangeTracking/ChangeTracker.cs index 4109a30b2c2..d6781e95493 100644 --- a/src/EFCore/ChangeTracking/ChangeTracker.cs +++ b/src/EFCore/ChangeTracking/ChangeTracker.cs @@ -43,10 +43,6 @@ public ChangeTracker( IModel model, IEntityEntryGraphIterator graphIterator) { - Check.NotNull(context, nameof(context)); - Check.NotNull(stateManager, nameof(stateManager)); - Check.NotNull(changeDetector, nameof(changeDetector)); - Context = context; _defaultQueryTrackingBehavior diff --git a/src/EFCore/ChangeTracking/EntityEntry.cs b/src/EFCore/ChangeTracking/EntityEntry.cs index 56a3312700f..60403bb8815 100644 --- a/src/EFCore/ChangeTracking/EntityEntry.cs +++ b/src/EFCore/ChangeTracking/EntityEntry.cs @@ -55,8 +55,6 @@ public class EntityEntry : IInfrastructure [EntityFrameworkInternal] public EntityEntry(InternalEntityEntry internalEntry) { - Check.NotNull(internalEntry, nameof(internalEntry)); - InternalEntry = internalEntry; } diff --git a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs index f670622dc9f..62b0adf6e17 100644 --- a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs +++ b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs @@ -39,8 +39,6 @@ public EntityEntryGraphNode( InternalEntityEntry? sourceEntry, INavigationBase? inboundNavigation) { - Check.NotNull(entry, nameof(entry)); - _entry = entry; _sourceEntry = sourceEntry; InboundNavigation = inboundNavigation; diff --git a/src/EFCore/ChangeTracking/MemberEntry.cs b/src/EFCore/ChangeTracking/MemberEntry.cs index dfa61b893d1..feec427371b 100644 --- a/src/EFCore/ChangeTracking/MemberEntry.cs +++ b/src/EFCore/ChangeTracking/MemberEntry.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.ChangeTracking { @@ -38,9 +37,6 @@ public abstract class MemberEntry : IInfrastructure [EntityFrameworkInternal] protected MemberEntry(InternalEntityEntry internalEntry, IPropertyBase metadata) { - Check.NotNull(internalEntry, nameof(internalEntry)); - Check.NotNull(metadata, nameof(metadata)); - InternalEntry = internalEntry; Metadata = metadata; } diff --git a/src/EFCore/DbContextOptions.cs b/src/EFCore/DbContextOptions.cs index 043ebca6df2..21366048991 100644 --- a/src/EFCore/DbContextOptions.cs +++ b/src/EFCore/DbContextOptions.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore { @@ -46,8 +45,6 @@ protected DbContextOptions() protected DbContextOptions( IReadOnlyDictionary extensions) { - Check.NotNull(extensions, nameof(extensions)); - _extensionsMap = ImmutableSortedDictionary.Create(TypeFullNameComparer.Instance) .AddRange(extensions.Select((p, i) => new KeyValuePair(p.Key, (p.Value, i)))); } @@ -62,8 +59,6 @@ protected DbContextOptions( protected DbContextOptions( ImmutableSortedDictionary extensions) { - Check.NotNull(extensions, nameof(extensions)); - _extensionsMap = extensions; } diff --git a/src/EFCore/DbContextOptionsBuilder.cs b/src/EFCore/DbContextOptionsBuilder.cs index 0ccfc158f61..374a3ae271c 100644 --- a/src/EFCore/DbContextOptionsBuilder.cs +++ b/src/EFCore/DbContextOptionsBuilder.cs @@ -638,11 +638,7 @@ public virtual DbContextOptionsBuilder ConfigureLoggingCacheTime(TimeSpan timeSp /// The type of extension to be added. /// The extension to be added. void IDbContextOptionsBuilderInfrastructure.AddOrUpdateExtension(TExtension extension) - { - Check.NotNull(extension, nameof(extension)); - - _options = _options.WithExtension(extension); - } + => _options = _options.WithExtension(extension); private DbContextOptionsBuilder WithOption(Func withFunc) { diff --git a/src/EFCore/DbContextOptions`.cs b/src/EFCore/DbContextOptions`.cs index 2cae60fddae..5d0db36377d 100644 --- a/src/EFCore/DbContextOptions`.cs +++ b/src/EFCore/DbContextOptions`.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore { @@ -51,8 +50,6 @@ private DbContextOptions( /// public override DbContextOptions WithExtension(TExtension extension) { - Check.NotNull(extension, nameof(extension)); - var type = extension.GetType(); var ordinal = ExtensionsMap.Count; if (ExtensionsMap.TryGetValue(type, out var existingValue)) diff --git a/src/EFCore/DbUpdateException.cs b/src/EFCore/DbUpdateException.cs index 63975081a77..967dbc9125e 100644 --- a/src/EFCore/DbUpdateException.cs +++ b/src/EFCore/DbUpdateException.cs @@ -7,7 +7,6 @@ using System.Runtime.Serialization; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Update; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore { @@ -73,8 +72,6 @@ public DbUpdateException( IReadOnlyList entries) : base(message, innerException) { - Check.NotEmpty(entries, nameof(entries)); - _entries = entries .Where(e => e.EntityState != EntityState.Unchanged) .Select(e => e.ToEntityEntry()).ToList(); @@ -104,8 +101,6 @@ public DbUpdateException( IReadOnlyList entries) : base(message, innerException) { - Check.NotEmpty(entries, nameof(entries)); - _entries = entries; } diff --git a/src/EFCore/Design/AttributeCodeFragment.cs b/src/EFCore/Design/AttributeCodeFragment.cs index 5a9b72cab1d..1e69c9d01e4 100644 --- a/src/EFCore/Design/AttributeCodeFragment.cs +++ b/src/EFCore/Design/AttributeCodeFragment.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Design { @@ -25,9 +24,6 @@ public class AttributeCodeFragment /// The attribute's arguments. public AttributeCodeFragment(Type type, params object[] arguments) { - Check.NotNull(type, nameof(type)); - Check.NotNull(arguments, nameof(arguments)); - Type = type; _arguments = new List(arguments); } diff --git a/src/EFCore/Design/DesignTimeProviderServicesAttribute.cs b/src/EFCore/Design/DesignTimeProviderServicesAttribute.cs index c2170e5660b..da69babc179 100644 --- a/src/EFCore/Design/DesignTimeProviderServicesAttribute.cs +++ b/src/EFCore/Design/DesignTimeProviderServicesAttribute.cs @@ -31,8 +31,7 @@ public sealed class DesignTimeProviderServicesAttribute : Attribute /// The name of the type that can be used to add the database providers design time services to a . /// This type should implement . /// - public DesignTimeProviderServicesAttribute( - string typeName) + public DesignTimeProviderServicesAttribute(string typeName) { Check.NotEmpty(typeName, nameof(typeName)); diff --git a/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs b/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs index 77f8c9739c1..a93128bf2c5 100644 --- a/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs +++ b/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGenerator.cs @@ -6,7 +6,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Design.Internal { @@ -21,8 +20,6 @@ public class CSharpRuntimeAnnotationCodeGenerator : ICSharpRuntimeAnnotationCode /// Parameter object containing dependencies for this service. public CSharpRuntimeAnnotationCodeGenerator(CSharpRuntimeAnnotationCodeGeneratorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGeneratorDependencies.cs b/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGeneratorDependencies.cs index 1ee370d4962..bb46a0cab0c 100644 --- a/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGeneratorDependencies.cs +++ b/src/EFCore/Design/Internal/CSharpRuntimeAnnotationCodeGeneratorDependencies.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Design.Internal { @@ -42,8 +41,6 @@ public sealed record CSharpRuntimeAnnotationCodeGeneratorDependencies [EntityFrameworkInternal] public CSharpRuntimeAnnotationCodeGeneratorDependencies(ICSharpHelper cSharpHelper) { - Check.NotNull(cSharpHelper, nameof(cSharpHelper)); - CSharpHelper = cSharpHelper; } diff --git a/src/EFCore/Design/MethodCallCodeFragment.cs b/src/EFCore/Design/MethodCallCodeFragment.cs index 4de04ef7893..6a2664f33ce 100644 --- a/src/EFCore/Design/MethodCallCodeFragment.cs +++ b/src/EFCore/Design/MethodCallCodeFragment.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Design { @@ -32,9 +31,6 @@ public class MethodCallCodeFragment /// The method call's arguments. Can be . public MethodCallCodeFragment(MethodInfo methodInfo, params object?[] arguments) { - Check.NotNull(methodInfo, nameof(methodInfo)); - Check.NotNull(arguments, nameof(arguments)); - var parameterLength = methodInfo.GetParameters().Length; if (methodInfo.IsStatic) { @@ -60,9 +56,6 @@ public MethodCallCodeFragment(MethodInfo methodInfo, params object?[] arguments) [Obsolete("Use the overload accepting a MethodInfo")] public MethodCallCodeFragment(string method, params object?[] arguments) { - Check.NotEmpty(method, nameof(method)); - Check.NotNull(arguments, nameof(arguments)); - _method = method; _arguments = new List(arguments); } @@ -87,8 +80,6 @@ private MethodCallCodeFragment( object?[] arguments) : this(methodInfo, arguments) { - Check.NotNull(chainedCall, nameof(chainedCall)); - ChainedCall = chainedCall; } @@ -105,8 +96,6 @@ public MethodCallCodeFragment( MethodCallCodeFragment chainedCall) : this(method, arguments) { - Check.NotNull(chainedCall, nameof(chainedCall)); - ChainedCall = chainedCall; } diff --git a/src/EFCore/Design/NestedClosureCodeFragment.cs b/src/EFCore/Design/NestedClosureCodeFragment.cs index 86bb6d41b70..ceef5f930a8 100644 --- a/src/EFCore/Design/NestedClosureCodeFragment.cs +++ b/src/EFCore/Design/NestedClosureCodeFragment.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Design { @@ -22,9 +21,6 @@ public class NestedClosureCodeFragment /// The method call used as the body of the nested closure. public NestedClosureCodeFragment(string parameter, MethodCallCodeFragment methodCall) { - Check.NotEmpty(parameter, nameof(parameter)); - Check.NotNull(methodCall, nameof(methodCall)); - Parameter = parameter; MethodCalls = new List { methodCall }; } @@ -36,9 +32,6 @@ public NestedClosureCodeFragment(string parameter, MethodCallCodeFragment method /// The list of method calls used as the body of the nested closure. public NestedClosureCodeFragment(string parameter, IReadOnlyList methodCalls) { - Check.NotEmpty(parameter, nameof(parameter)); - Check.NotEmpty(methodCalls, nameof(methodCalls)); - Parameter = parameter; MethodCalls = methodCalls; } diff --git a/src/EFCore/Diagnostics/CascadeDeleteEventData.cs b/src/EFCore/Diagnostics/CascadeDeleteEventData.cs index 559abf2a4f8..85886292f6e 100644 --- a/src/EFCore/Diagnostics/CascadeDeleteEventData.cs +++ b/src/EFCore/Diagnostics/CascadeDeleteEventData.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -33,8 +32,6 @@ public CascadeDeleteEventData( EntityState state) : base(eventDefinition, messageGenerator, entityEntry) { - Check.NotNull(parentEntry, nameof(parentEntry)); - ParentEntityEntry = parentEntry; State = state; } diff --git a/src/EFCore/Diagnostics/CascadeDeleteOrphanEventData.cs b/src/EFCore/Diagnostics/CascadeDeleteOrphanEventData.cs index f567bc59c96..e6106bc821d 100644 --- a/src/EFCore/Diagnostics/CascadeDeleteOrphanEventData.cs +++ b/src/EFCore/Diagnostics/CascadeDeleteOrphanEventData.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -34,8 +33,6 @@ public CascadeDeleteOrphanEventData( EntityState state) : base(eventDefinition, messageGenerator, entityEntry) { - Check.NotNull(parentEntityTypes, nameof(parentEntityTypes)); - ParentEntityType = parentEntityTypes; State = state; } diff --git a/src/EFCore/Diagnostics/CollectionChangedEventData.cs b/src/EFCore/Diagnostics/CollectionChangedEventData.cs index 370f60530e1..0387e28fd10 100644 --- a/src/EFCore/Diagnostics/CollectionChangedEventData.cs +++ b/src/EFCore/Diagnostics/CollectionChangedEventData.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -37,10 +36,6 @@ public CollectionChangedEventData( IEnumerable removed) : base(eventDefinition, messageGenerator, navigation) { - Check.NotNull(entityEntry, nameof(entityEntry)); - Check.NotNull(added, nameof(added)); - Check.NotNull(removed, nameof(removed)); - EntityEntry = entityEntry; Added = added; Removed = removed; diff --git a/src/EFCore/Diagnostics/EntityEntryEventData.cs b/src/EFCore/Diagnostics/EntityEntryEventData.cs index 36853f22a99..ea6101fbf7f 100644 --- a/src/EFCore/Diagnostics/EntityEntryEventData.cs +++ b/src/EFCore/Diagnostics/EntityEntryEventData.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -29,8 +28,6 @@ public EntityEntryEventData( EntityEntry entityEntry) : base(eventDefinition, messageGenerator) { - Check.NotNull(entityEntry, nameof(entityEntry)); - EntityEntry = entityEntry; } diff --git a/src/EFCore/Diagnostics/EventDefinition.cs b/src/EFCore/Diagnostics/EventDefinition.cs index 697a5472ed9..29f3360a448 100644 --- a/src/EFCore/Diagnostics/EventDefinition.cs +++ b/src/EFCore/Diagnostics/EventDefinition.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -37,8 +36,6 @@ public EventDefinition( Func> logActionFunc) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotNull(logActionFunc, nameof(logActionFunc)); - _logAction = logActionFunc(Level); } diff --git a/src/EFCore/Diagnostics/EventDefinitionBase.cs b/src/EFCore/Diagnostics/EventDefinitionBase.cs index d0e39a140d6..f8e03848158 100644 --- a/src/EFCore/Diagnostics/EventDefinitionBase.cs +++ b/src/EFCore/Diagnostics/EventDefinitionBase.cs @@ -3,7 +3,6 @@ using System; using System.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -32,9 +31,6 @@ protected EventDefinitionBase( LogLevel level, string eventIdCode) { - Check.NotNull(loggingOptions, nameof(loggingOptions)); - Check.NotEmpty(eventIdCode, nameof(eventIdCode)); - EventId = eventId; EventIdCode = eventIdCode; diff --git a/src/EFCore/Diagnostics/EventDefinition`.cs b/src/EFCore/Diagnostics/EventDefinition`.cs index 2b59a61db3c..fa8676a0026 100644 --- a/src/EFCore/Diagnostics/EventDefinition`.cs +++ b/src/EFCore/Diagnostics/EventDefinition`.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -37,8 +36,6 @@ public EventDefinition( Func> logActionFunc) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotNull(logActionFunc, nameof(logActionFunc)); - _logAction = logActionFunc(Level); } diff --git a/src/EFCore/Diagnostics/EventDefinition``.cs b/src/EFCore/Diagnostics/EventDefinition``.cs index 0759ba71421..69fa08d6902 100644 --- a/src/EFCore/Diagnostics/EventDefinition``.cs +++ b/src/EFCore/Diagnostics/EventDefinition``.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -37,8 +36,6 @@ public EventDefinition( Func> logActionFunc) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotNull(logActionFunc, nameof(logActionFunc)); - _logAction = logActionFunc(Level); } diff --git a/src/EFCore/Diagnostics/EventDefinition```.cs b/src/EFCore/Diagnostics/EventDefinition```.cs index 06364951521..d822fda7903 100644 --- a/src/EFCore/Diagnostics/EventDefinition```.cs +++ b/src/EFCore/Diagnostics/EventDefinition```.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -37,8 +36,6 @@ public EventDefinition( Func> logActionFunc) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotNull(logActionFunc, nameof(logActionFunc)); - _logAction = logActionFunc(Level); } diff --git a/src/EFCore/Diagnostics/EventDefinition````.cs b/src/EFCore/Diagnostics/EventDefinition````.cs index 17d2864b415..26f55590c29 100644 --- a/src/EFCore/Diagnostics/EventDefinition````.cs +++ b/src/EFCore/Diagnostics/EventDefinition````.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -37,8 +36,6 @@ public EventDefinition( Func> logActionFunc) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotNull(logActionFunc, nameof(logActionFunc)); - _logAction = logActionFunc(Level); } diff --git a/src/EFCore/Diagnostics/EventDefinition`````.cs b/src/EFCore/Diagnostics/EventDefinition`````.cs index 616ea432f26..ec2f0c01d1c 100644 --- a/src/EFCore/Diagnostics/EventDefinition`````.cs +++ b/src/EFCore/Diagnostics/EventDefinition`````.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -37,8 +36,6 @@ public EventDefinition( Func> logActionFunc) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotNull(logActionFunc, nameof(logActionFunc)); - _logAction = logActionFunc(Level); } diff --git a/src/EFCore/Diagnostics/EventDefinition``````.cs b/src/EFCore/Diagnostics/EventDefinition``````.cs index 65f74e1ef28..a083ed66a34 100644 --- a/src/EFCore/Diagnostics/EventDefinition``````.cs +++ b/src/EFCore/Diagnostics/EventDefinition``````.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -37,8 +36,6 @@ public EventDefinition( Func> logActionFunc) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotNull(logActionFunc, nameof(logActionFunc)); - _logAction = logActionFunc(Level); } diff --git a/src/EFCore/Diagnostics/FallbackEventDefinition.cs b/src/EFCore/Diagnostics/FallbackEventDefinition.cs index b593ff9967a..76c5cad0510 100644 --- a/src/EFCore/Diagnostics/FallbackEventDefinition.cs +++ b/src/EFCore/Diagnostics/FallbackEventDefinition.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -35,8 +34,6 @@ public FallbackEventDefinition( string messageFormat) : base(loggingOptions, eventId, level, eventIdCode) { - Check.NotEmpty(messageFormat, nameof(messageFormat)); - MessageFormat = messageFormat; } @@ -48,8 +45,6 @@ public FallbackEventDefinition( /// The message string. public virtual string GenerateMessage(Action logAction) { - Check.NotNull(logAction, nameof(logAction)); - var extractor = new MessageExtractingLogger(); logAction(extractor); return extractor.Message; diff --git a/src/EFCore/Diagnostics/InterceptorAggregator.cs b/src/EFCore/Diagnostics/InterceptorAggregator.cs index 0bd33fbe9b2..bc88ad19889 100644 --- a/src/EFCore/Diagnostics/InterceptorAggregator.cs +++ b/src/EFCore/Diagnostics/InterceptorAggregator.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Diagnostics @@ -45,8 +44,6 @@ public virtual Type InterceptorType /// The combined interceptor. public virtual IInterceptor? AggregateInterceptors(IReadOnlyList interceptors) { - Check.NotNull(interceptors, nameof(interceptors)); - if (!_resolved) { if (interceptors.Count == 1) diff --git a/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs b/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs index 098117d8b26..c9312f35714 100644 --- a/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs +++ b/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs @@ -3,7 +3,6 @@ using System; using System.Text; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Diagnostics.Internal @@ -44,8 +43,6 @@ public FormattingDbContextLogger( /// public virtual void Log(EventData eventData) { - Check.NotNull(eventData, nameof(eventData)); - var message = eventData.ToString(); var logLevel = eventData.LogLevel; var eventId = eventData.EventId; diff --git a/src/EFCore/Diagnostics/PropertyChangedEventData.cs b/src/EFCore/Diagnostics/PropertyChangedEventData.cs index f850877a879..0c72ac82005 100644 --- a/src/EFCore/Diagnostics/PropertyChangedEventData.cs +++ b/src/EFCore/Diagnostics/PropertyChangedEventData.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -36,8 +35,6 @@ public PropertyChangedEventData( object? newValue) : base(eventDefinition, messageGenerator, property) { - Check.NotNull(entityEntry, nameof(entityEntry)); - EntityEntry = entityEntry; OldValue = oldValue; NewValue = newValue; diff --git a/src/EFCore/Diagnostics/PropertyValueEventData.cs b/src/EFCore/Diagnostics/PropertyValueEventData.cs index 65a7618e001..7b3ce415a8d 100644 --- a/src/EFCore/Diagnostics/PropertyValueEventData.cs +++ b/src/EFCore/Diagnostics/PropertyValueEventData.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -34,8 +33,6 @@ public PropertyValueEventData( object? value) : base(eventDefinition, messageGenerator, property) { - Check.NotNull(entityEntry, nameof(entityEntry)); - EntityEntry = entityEntry; Value = value; } diff --git a/src/EFCore/Diagnostics/ReferenceChangedEventData.cs b/src/EFCore/Diagnostics/ReferenceChangedEventData.cs index 0c1c5140e3d..b8c372b3897 100644 --- a/src/EFCore/Diagnostics/ReferenceChangedEventData.cs +++ b/src/EFCore/Diagnostics/ReferenceChangedEventData.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -36,8 +35,6 @@ public ReferenceChangedEventData( object? newReferencedEntity) : base(eventDefinition, messageGenerator, navigation) { - Check.NotNull(entityEntry, nameof(entityEntry)); - EntityEntry = entityEntry; OldReferencedEntity = oldReferencedEntity; NewReferencedEntity = newReferencedEntity; diff --git a/src/EFCore/Diagnostics/SkipCollectionChangedEventData.cs b/src/EFCore/Diagnostics/SkipCollectionChangedEventData.cs index 82f3b6746b6..88b7e5c2ee9 100644 --- a/src/EFCore/Diagnostics/SkipCollectionChangedEventData.cs +++ b/src/EFCore/Diagnostics/SkipCollectionChangedEventData.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Diagnostics { @@ -37,10 +36,6 @@ public SkipCollectionChangedEventData( IEnumerable removed) : base(eventDefinition, messageGenerator, navigation) { - Check.NotNull(entityEntry, nameof(entityEntry)); - Check.NotNull(added, nameof(added)); - Check.NotNull(removed, nameof(removed)); - EntityEntry = entityEntry; Added = added; Removed = removed; diff --git a/src/EFCore/Diagnostics/WarningsConfigurationBuilder.cs b/src/EFCore/Diagnostics/WarningsConfigurationBuilder.cs index c4f942a6cc1..9f96b8db884 100644 --- a/src/EFCore/Diagnostics/WarningsConfigurationBuilder.cs +++ b/src/EFCore/Diagnostics/WarningsConfigurationBuilder.cs @@ -31,8 +31,6 @@ public class WarningsConfigurationBuilder /// The options builder to which the warnings configuration will be applied. public WarningsConfigurationBuilder(DbContextOptionsBuilder optionsBuilder) { - Check.NotNull(optionsBuilder, nameof(optionsBuilder)); - _optionsBuilder = optionsBuilder; } diff --git a/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs b/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs index 2244be2ba56..744740d1cb8 100644 --- a/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs +++ b/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs @@ -40,13 +40,9 @@ public static class EntityFrameworkQueryableExtensions /// The query string for debugging. /// is . public static string ToQueryString(this IQueryable source) - { - Check.NotNull(source, nameof(source)); - - return source.Provider.Execute(source.Expression) is IQueryingEnumerable queryingEnumerable + => source.Provider.Execute(source.Expression) is IQueryingEnumerable queryingEnumerable ? queryingEnumerable.ToQueryString() : CoreStrings.NotQueryingEnumerable; - } #region Any/All @@ -75,11 +71,7 @@ public static string ToQueryString(this IQueryable source) public static Task AnyAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.AnyWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.AnyWithoutPredicate, source, cancellationToken); /// /// Asynchronously determines whether any element of a sequence satisfies a condition. @@ -112,7 +104,6 @@ public static Task AnyAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.AnyWithPredicate, source, predicate, cancellationToken); @@ -149,7 +140,6 @@ public static Task AllAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.All, source, predicate, cancellationToken); @@ -184,11 +174,7 @@ public static Task AllAsync( public static Task CountAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.CountWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.CountWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns the number of elements in a sequence that satisfy a condition. @@ -221,7 +207,6 @@ public static Task CountAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.CountWithPredicate, source, predicate, cancellationToken); @@ -252,11 +237,7 @@ public static Task CountAsync( public static Task LongCountAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.LongCountWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.LongCountWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns a that represents the number of elements in a sequence @@ -290,7 +271,6 @@ public static Task LongCountAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.LongCountWithPredicate, source, predicate, cancellationToken); @@ -326,11 +306,7 @@ public static Task LongCountAsync( public static Task FirstAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.FirstWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.FirstWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns the first element of a sequence that satisfies a specified condition. @@ -374,7 +350,6 @@ public static Task FirstAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.FirstWithPredicate, source, predicate, cancellationToken); @@ -406,11 +381,7 @@ public static Task FirstAsync( public static Task FirstOrDefaultAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.FirstOrDefaultWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.FirstOrDefaultWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns the first element of a sequence that satisfies a specified condition @@ -445,7 +416,6 @@ public static Task FirstAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>( @@ -482,11 +452,7 @@ public static Task FirstAsync( public static Task LastAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.LastWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.LastWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns the last element of a sequence that satisfies a specified condition. @@ -530,7 +496,6 @@ public static Task LastAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.LastWithPredicate, source, predicate, cancellationToken); @@ -562,11 +527,7 @@ public static Task LastAsync( public static Task LastOrDefaultAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.LastOrDefaultWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.LastOrDefaultWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns the last element of a sequence that satisfies a specified condition @@ -601,7 +562,6 @@ public static Task LastAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.LastOrDefaultWithPredicate, source, predicate, cancellationToken); @@ -648,11 +608,7 @@ public static Task LastAsync( public static Task SingleAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.SingleWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.SingleWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns the only element of a sequence that satisfies a specified condition, @@ -703,7 +659,6 @@ public static Task SingleAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>(QueryableMethods.SingleWithPredicate, source, predicate, cancellationToken); @@ -738,11 +693,7 @@ public static Task SingleAsync( public static Task SingleOrDefaultAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.SingleOrDefaultWithoutPredicate, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.SingleOrDefaultWithoutPredicate, source, cancellationToken); /// /// Asynchronously returns the only element of a sequence that satisfies a specified condition or @@ -780,7 +731,6 @@ public static Task SingleAsync( Expression> predicate, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(predicate, nameof(predicate)); return ExecuteAsync>( @@ -817,11 +767,7 @@ public static Task SingleAsync( public static Task MinAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.MinWithoutSelector, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.MinWithoutSelector, source, cancellationToken); /// /// Asynchronously invokes a projection function on each element of a sequence and returns the minimum resulting value. @@ -857,7 +803,6 @@ public static Task MinAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>(QueryableMethods.MinWithSelector, source, selector, cancellationToken); @@ -893,11 +838,7 @@ public static Task MinAsync( public static Task MaxAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.MaxWithoutSelector, source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.MaxWithoutSelector, source, cancellationToken); /// /// Asynchronously invokes a projection function on each element of a sequence and returns the maximum resulting value. @@ -933,7 +874,6 @@ public static Task MaxAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>(QueryableMethods.MaxWithSelector, source, selector, cancellationToken); @@ -967,11 +907,7 @@ public static Task MaxAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(decimal)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(decimal)), source, cancellationToken); /// /// Asynchronously computes the sum of a sequence of values. @@ -997,12 +933,8 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>( + => ExecuteAsync>( QueryableMethods.GetSumWithoutSelector(typeof(decimal?)), source, cancellationToken); - } /// /// Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on @@ -1034,7 +966,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1071,7 +1002,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1102,11 +1032,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(int)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(int)), source, cancellationToken); /// /// Asynchronously computes the sum of a sequence of values. @@ -1132,11 +1058,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(int?)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(int?)), source, cancellationToken); /// /// Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on @@ -1168,7 +1090,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>(QueryableMethods.GetSumWithSelector(typeof(int)), source, selector, cancellationToken); @@ -1204,7 +1125,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1235,11 +1155,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(long)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(long)), source, cancellationToken); /// /// Asynchronously computes the sum of a sequence of values. @@ -1265,11 +1181,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(long?)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(long?)), source, cancellationToken); /// /// Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on @@ -1301,7 +1213,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1338,7 +1249,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1369,11 +1279,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(double)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(double)), source, cancellationToken); /// /// Asynchronously computes the sum of a sequence of values. @@ -1399,11 +1305,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(double?)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(double?)), source, cancellationToken); /// /// Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on @@ -1435,7 +1337,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1472,7 +1373,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1503,11 +1403,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(float)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(float)), source, cancellationToken); /// /// Asynchronously computes the sum of a sequence of values. @@ -1533,11 +1429,7 @@ public static Task SumAsync( public static Task SumAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(float?)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetSumWithoutSelector(typeof(float?)), source, cancellationToken); /// /// Asynchronously computes the sum of the sequence of values that is obtained by invoking a projection function on @@ -1569,7 +1461,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1606,7 +1497,6 @@ public static Task SumAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1642,12 +1532,8 @@ public static Task SumAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>( + => ExecuteAsync>( QueryableMethods.GetAverageWithoutSelector(typeof(decimal)), source, cancellationToken); - } /// /// Asynchronously computes the average of a sequence of values. @@ -1673,12 +1559,8 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>( + => ExecuteAsync>( QueryableMethods.GetAverageWithoutSelector(typeof(decimal?)), source, cancellationToken); - } /// /// Asynchronously computes the average of a sequence of values that is obtained @@ -1712,7 +1594,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1750,7 +1631,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1782,11 +1662,7 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(int)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(int)), source, cancellationToken); /// /// Asynchronously computes the average of a sequence of values. @@ -1812,11 +1688,7 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(int?)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(int?)), source, cancellationToken); /// /// Asynchronously computes the average of a sequence of values that is obtained @@ -1850,7 +1722,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1888,7 +1759,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -1920,11 +1790,7 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(long)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(long)), source, cancellationToken); /// /// Asynchronously computes the average of a sequence of values. @@ -1950,11 +1816,7 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(long?)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(long?)), source, cancellationToken); /// /// Asynchronously computes the average of a sequence of values that is obtained @@ -1988,7 +1850,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -2026,7 +1887,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -2058,12 +1918,8 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>( + => ExecuteAsync>( QueryableMethods.GetAverageWithoutSelector(typeof(double)), source, cancellationToken); - } /// /// Asynchronously computes the average of a sequence of values. @@ -2089,12 +1945,8 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>( + => ExecuteAsync>( QueryableMethods.GetAverageWithoutSelector(typeof(double?)), source, cancellationToken); - } /// /// Asynchronously computes the average of a sequence of values that is obtained @@ -2128,7 +1980,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -2166,7 +2017,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -2198,11 +2048,7 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(float)), source, cancellationToken); - } + => ExecuteAsync>(QueryableMethods.GetAverageWithoutSelector(typeof(float)), source, cancellationToken); /// /// Asynchronously computes the average of a sequence of values. @@ -2228,12 +2074,8 @@ public static Task AverageAsync( public static Task AverageAsync( this IQueryable source, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>( + => ExecuteAsync>( QueryableMethods.GetAverageWithoutSelector(typeof(float?)), source, cancellationToken); - } /// /// Asynchronously computes the average of a sequence of values that is obtained @@ -2267,7 +2109,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -2305,7 +2146,6 @@ public static Task AverageAsync( Expression> selector, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); Check.NotNull(selector, nameof(selector)); return ExecuteAsync>( @@ -2344,15 +2184,11 @@ public static Task ContainsAsync( this IQueryable source, TSource item, CancellationToken cancellationToken = default) - { - Check.NotNull(source, nameof(source)); - - return ExecuteAsync>( + => ExecuteAsync>( QueryableMethods.Contains, source, Expression.Constant(item, typeof(TSource)), cancellationToken); - } #endregion @@ -2498,7 +2334,6 @@ public static IIncludableQueryable Include> navigationPropertyPath) where TEntity : class { - Check.NotNull(source, nameof(source)); Check.NotNull(navigationPropertyPath, nameof(navigationPropertyPath)); return new IncludableQueryable( @@ -2734,7 +2569,6 @@ public static IQueryable Include( [NotParameterized] string navigationPropertyPath) where TEntity : class { - Check.NotNull(source, nameof(source)); Check.NotEmpty(navigationPropertyPath, nameof(navigationPropertyPath)); return @@ -2768,18 +2602,13 @@ internal static readonly MethodInfo IgnoreAutoIncludesMethodInfo public static IQueryable IgnoreAutoIncludes( this IQueryable source) where TEntity : class - { - Check.NotNull(source, nameof(source)); - - return - source.Provider is EntityQueryProvider - ? source.Provider.CreateQuery( - Expression.Call( - instance: null, - method: IgnoreAutoIncludesMethodInfo.MakeGenericMethod(typeof(TEntity)), - arguments: source.Expression)) - : source; - } + => source.Provider is EntityQueryProvider + ? source.Provider.CreateQuery( + Expression.Call( + instance: null, + method: IgnoreAutoIncludesMethodInfo.MakeGenericMethod(typeof(TEntity)), + arguments: source.Expression)) + : source; #endregion @@ -2802,18 +2631,13 @@ internal static readonly MethodInfo IgnoreQueryFiltersMethodInfo public static IQueryable IgnoreQueryFilters( this IQueryable source) where TEntity : class - { - Check.NotNull(source, nameof(source)); - - return - source.Provider is EntityQueryProvider - ? source.Provider.CreateQuery( - Expression.Call( - instance: null, - method: IgnoreQueryFiltersMethodInfo.MakeGenericMethod(typeof(TEntity)), - arguments: source.Expression)) - : source; - } + => source.Provider is EntityQueryProvider + ? source.Provider.CreateQuery( + Expression.Call( + instance: null, + method: IgnoreQueryFiltersMethodInfo.MakeGenericMethod(typeof(TEntity)), + arguments: source.Expression)) + : source; #endregion @@ -2853,18 +2677,13 @@ internal static readonly MethodInfo AsNoTrackingMethodInfo public static IQueryable AsNoTracking( this IQueryable source) where TEntity : class - { - Check.NotNull(source, nameof(source)); - - return - source.Provider is EntityQueryProvider - ? source.Provider.CreateQuery( - Expression.Call( - instance: null, - method: AsNoTrackingMethodInfo.MakeGenericMethod(typeof(TEntity)), - arguments: source.Expression)) - : source; - } + => source.Provider is EntityQueryProvider + ? source.Provider.CreateQuery( + Expression.Call( + instance: null, + method: AsNoTrackingMethodInfo.MakeGenericMethod(typeof(TEntity)), + arguments: source.Expression)) + : source; internal static readonly MethodInfo AsNoTrackingWithIdentityResolutionMethodInfo = typeof(EntityFrameworkQueryableExtensions) @@ -2900,18 +2719,13 @@ internal static readonly MethodInfo AsNoTrackingWithIdentityResolutionMethodInfo public static IQueryable AsNoTrackingWithIdentityResolution( this IQueryable source) where TEntity : class - { - Check.NotNull(source, nameof(source)); - - return - source.Provider is EntityQueryProvider - ? source.Provider.CreateQuery( - Expression.Call( - instance: null, - method: AsNoTrackingWithIdentityResolutionMethodInfo.MakeGenericMethod(typeof(TEntity)), - arguments: source.Expression)) - : source; - } + => source.Provider is EntityQueryProvider + ? source.Provider.CreateQuery( + Expression.Call( + instance: null, + method: AsNoTrackingWithIdentityResolutionMethodInfo.MakeGenericMethod(typeof(TEntity)), + arguments: source.Expression)) + : source; internal static readonly MethodInfo AsTrackingMethodInfo = typeof(EntityFrameworkQueryableExtensions) @@ -2939,18 +2753,13 @@ internal static readonly MethodInfo AsTrackingMethodInfo public static IQueryable AsTracking( this IQueryable source) where TEntity : class - { - Check.NotNull(source, nameof(source)); - - return - source.Provider is EntityQueryProvider - ? source.Provider.CreateQuery( - Expression.Call( - instance: null, - method: AsTrackingMethodInfo.MakeGenericMethod(typeof(TEntity)), - arguments: source.Expression)) - : source; - } + => source.Provider is EntityQueryProvider + ? source.Provider.CreateQuery( + Expression.Call( + instance: null, + method: AsTrackingMethodInfo.MakeGenericMethod(typeof(TEntity)), + arguments: source.Expression)) + : source; /// /// Returns a new query where the change tracker will either keep track of changes or not for all entities @@ -3029,7 +2838,6 @@ public static IQueryable TagWith( this IQueryable source, [NotParameterized] string tag) { - Check.NotNull(source, nameof(source)); Check.NotEmpty(tag, nameof(tag)); return @@ -3062,20 +2870,15 @@ public static IQueryable TagWithCallSite( this IQueryable source, [NotParameterized] [CallerFilePath] string? filePath = null, [NotParameterized] [CallerLineNumber] int lineNumber = 0) - { - Check.NotNull(source, nameof(source)); - - return - source.Provider is EntityQueryProvider - ? source.Provider.CreateQuery( - Expression.Call( - instance: null, - method: TagWithCallSiteMethodInfo.MakeGenericMethod(typeof(T)), - arg0: source.Expression, - arg1: Expression.Constant(filePath), - arg2: Expression.Constant(lineNumber))) - : source; - } + => source.Provider is EntityQueryProvider + ? source.Provider.CreateQuery( + Expression.Call( + instance: null, + method: TagWithCallSiteMethodInfo.MakeGenericMethod(typeof(T)), + arg0: source.Expression, + arg1: Expression.Constant(filePath), + arg2: Expression.Constant(lineNumber))) + : source; #endregion @@ -3093,8 +2896,6 @@ source.Provider is EntityQueryProvider /// is . public static void Load(this IQueryable source) { - Check.NotNull(source, nameof(source)); - using var enumerator = source.GetEnumerator(); while (enumerator.MoveNext()) { @@ -3125,8 +2926,6 @@ public static async Task LoadAsync( this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - await using (var enumerator = source.AsAsyncEnumerable().GetAsyncEnumerator(cancellationToken)) { while (await enumerator.MoveNextAsync().ConfigureAwait(false)) @@ -3290,7 +3089,6 @@ public static async Task> ToDictionaryAsync( public static IAsyncEnumerable AsAsyncEnumerable( this IQueryable source) { - Check.NotNull(source, nameof(source)); - if (source is IAsyncEnumerable asyncEnumerable) { return asyncEnumerable; diff --git a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs index 3cc8c02ec2c..45fca942f75 100644 --- a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs +++ b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs @@ -327,7 +327,6 @@ public static IServiceCollection AddDbContextPool(serviceCollection, optionsAction, poolSize); @@ -566,8 +565,6 @@ public static IServiceCollection AddDbContext( where TContext : DbContext where TFactory : IDbContextFactory { - Check.NotNull(serviceCollection, nameof(serviceCollection)); - AddCoreServices(serviceCollection, optionsAction, lifetime); serviceCollection.AddSingleton, DbContextFactorySource>(); @@ -1000,7 +995,6 @@ public static IServiceCollection AddPooledDbContextFactory( int poolSize = DbContextPool.DefaultPoolSize) where TContext : DbContext { - Check.NotNull(serviceCollection, nameof(serviceCollection)); Check.NotNull(optionsAction, nameof(optionsAction)); AddPoolingOptions(serviceCollection, optionsAction, poolSize); diff --git a/src/EFCore/Extensions/EntityTypeExtensions.cs b/src/EFCore/Extensions/EntityTypeExtensions.cs index d1de72702b7..fad3934da50 100644 --- a/src/EFCore/Extensions/EntityTypeExtensions.cs +++ b/src/EFCore/Extensions/EntityTypeExtensions.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore @@ -71,11 +70,7 @@ public static IEnumerable GetNavigations(this IEntityType entityTyp /// The LINQ query used as the default source. [Obsolete("Use InMemoryEntityTypeExtensions.GetInMemoryQuery")] public static LambdaExpression? GetDefiningQuery(this IEntityType entityType) - { - Check.NotNull(entityType, nameof(entityType)); - - return (LambdaExpression?)entityType[CoreAnnotationNames.DefiningQuery]; - } + => (LambdaExpression?)entityType[CoreAnnotationNames.DefiningQuery]; /// /// Returns the closest entity type that is a parent of both given entity types. If one of the given entities is diff --git a/src/EFCore/Extensions/Internal/ExpressionExtensions.cs b/src/EFCore/Extensions/Internal/ExpressionExtensions.cs index 1da9bf878a2..ac2ae099d8e 100644 --- a/src/EFCore/Extensions/Internal/ExpressionExtensions.cs +++ b/src/EFCore/Extensions/Internal/ExpressionExtensions.cs @@ -162,12 +162,8 @@ var memberInfos /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static bool IsLogicalOperation(this Expression expression) - { - Check.NotNull(expression, nameof(expression)); - - return expression.NodeType == ExpressionType.AndAlso + => expression.NodeType == ExpressionType.AndAlso || expression.NodeType == ExpressionType.OrElse; - } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Extensions/NavigationExtensions.cs b/src/EFCore/Extensions/NavigationExtensions.cs index 8c0aa5b3f47..404bbc945d4 100644 --- a/src/EFCore/Extensions/NavigationExtensions.cs +++ b/src/EFCore/Extensions/NavigationExtensions.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore @@ -27,7 +26,7 @@ public static class NavigationExtensions [DebuggerStepThrough] [Obsolete("Use IReadOnlyNavigation.IsOnDependent")] public static bool IsDependentToPrincipal(this INavigation navigation) - => Check.NotNull(navigation, nameof(navigation)).IsOnDependent; + => navigation.IsOnDependent; /// /// Gets a value indicating whether the given navigation property is a collection property. @@ -39,7 +38,7 @@ public static bool IsDependentToPrincipal(this INavigation navigation) [DebuggerStepThrough] [Obsolete("Use IReadOnlyNavigation.IsCollection")] public static bool IsCollection(this INavigation navigation) - => Check.NotNull(navigation, nameof(navigation)).IsCollection; + => navigation.IsCollection; /// /// Gets the navigation property on the other end of the relationship. Returns null if @@ -52,7 +51,7 @@ public static bool IsCollection(this INavigation navigation) [DebuggerStepThrough] [Obsolete("Use IReadOnlyNavigation.Inverse")] public static INavigation? FindInverse(this INavigation navigation) - => Check.NotNull(navigation, nameof(navigation)).Inverse; + => navigation.Inverse; /// /// Gets the entity type that a given navigation property will hold an instance of @@ -63,7 +62,7 @@ public static bool IsCollection(this INavigation navigation) [DebuggerStepThrough] [Obsolete("Use IReadOnlyNavigation.TargetEntityType")] public static IEntityType GetTargetType(this INavigation navigation) - => Check.NotNull(navigation, nameof(navigation)).TargetEntityType; + => navigation.TargetEntityType; /// /// Gets a value indicating whether this navigation should be eager loaded by default. @@ -72,6 +71,6 @@ public static IEntityType GetTargetType(this INavigation navigation) /// A value indicating whether this navigation should be eager loaded by default. [Obsolete("Use IReadOnlyNavigation.IsEagerLoaded")] public static bool IsEagerLoaded(this INavigation navigation) - => Check.NotNull(navigation, nameof(navigation)).IsEagerLoaded; + => navigation.IsEagerLoaded; } } diff --git a/src/EFCore/Extensions/TransactionsDatabaseFacadeExtensions.cs b/src/EFCore/Extensions/TransactionsDatabaseFacadeExtensions.cs index 9c2e7a97010..8082ab9f72c 100644 --- a/src/EFCore/Extensions/TransactionsDatabaseFacadeExtensions.cs +++ b/src/EFCore/Extensions/TransactionsDatabaseFacadeExtensions.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; // ReSharper disable once CheckNamespace namespace System.Transactions @@ -26,7 +25,6 @@ public static class TransactionsDatabaseFacadeExtensions /// The transaction to be used. public static void EnlistTransaction(this DatabaseFacade databaseFacade, Transaction? transaction) { - Check.NotNull(databaseFacade, nameof(databaseFacade)); if (((IDatabaseFacadeDependenciesAccessor)databaseFacade).Dependencies.TransactionManager is ITransactionEnlistmentManager transactionManager) { @@ -48,7 +46,6 @@ public static void EnlistTransaction(this DatabaseFacade databaseFacade, Transac /// The currently enlisted transaction. public static Transaction? GetEnlistedTransaction(this DatabaseFacade databaseFacade) { - Check.NotNull(databaseFacade, nameof(databaseFacade)); if (((IDatabaseFacadeDependenciesAccessor)databaseFacade).Dependencies.TransactionManager is ITransactionEnlistmentManager transactionManager) { diff --git a/src/EFCore/Infrastructure/AccessorExtensions.cs b/src/EFCore/Infrastructure/AccessorExtensions.cs index 1895ff74c5f..194883e1d95 100644 --- a/src/EFCore/Infrastructure/AccessorExtensions.cs +++ b/src/EFCore/Infrastructure/AccessorExtensions.cs @@ -4,7 +4,6 @@ using System; using System.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Infrastructure { @@ -42,7 +41,7 @@ public static class AccessorExtensions [DebuggerStepThrough] public static TService GetService(this IInfrastructure accessor) where TService : class - => InfrastructureExtensions.GetService(Check.NotNull(accessor, nameof(accessor))); + => InfrastructureExtensions.GetService(accessor); /// /// @@ -62,6 +61,6 @@ public static TService GetService(this IInfrastructureThe object assigned to the property. [DebuggerStepThrough] public static T GetInfrastructure(this IInfrastructure accessor) - => Check.NotNull(accessor, nameof(accessor)).Instance; + => accessor.Instance; } } diff --git a/src/EFCore/Infrastructure/CoreOptionsExtension.cs b/src/EFCore/Infrastructure/CoreOptionsExtension.cs index b21e5478687..b3f719fbfa3 100644 --- a/src/EFCore/Infrastructure/CoreOptionsExtension.cs +++ b/src/EFCore/Infrastructure/CoreOptionsExtension.cs @@ -8,7 +8,6 @@ using System.Text; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -349,8 +348,6 @@ public virtual CoreOptionsExtension WithServiceProviderCachingEnabled(bool servi /// A new instance with the option changed. public virtual CoreOptionsExtension WithInterceptors(IEnumerable interceptors) { - Check.NotNull(interceptors, nameof(interceptors)); - var clone = Clone(); clone._interceptors = _interceptors == null @@ -581,8 +578,6 @@ public override string LogFragment public override void PopulateDebugInfo(IDictionary debugInfo) { - Check.NotNull(debugInfo, nameof(debugInfo)); - debugInfo["Core:" + nameof(DbContextOptionsBuilder.UseMemoryCache)] = (Extension.GetMemoryCache()?.GetHashCode() ?? 0L).ToString(CultureInfo.InvariantCulture); debugInfo["Core:" + nameof(DbContextOptionsBuilder.EnableSensitiveDataLogging)] = diff --git a/src/EFCore/Infrastructure/DatabaseFacade.cs b/src/EFCore/Infrastructure/DatabaseFacade.cs index 2d94eb2d640..738f21ddaf7 100644 --- a/src/EFCore/Infrastructure/DatabaseFacade.cs +++ b/src/EFCore/Infrastructure/DatabaseFacade.cs @@ -9,7 +9,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Infrastructure { @@ -31,8 +30,6 @@ public class DatabaseFacade : IInfrastructure, IDatabaseFacade /// The context this database API belongs to. public DatabaseFacade(DbContext context) { - Check.NotNull(context, nameof(context)); - _context = context; } diff --git a/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs b/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs index cfcc3d500c0..55fbd8f2aba 100644 --- a/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs +++ b/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Infrastructure { @@ -27,8 +26,6 @@ public abstract class DbContextOptionsExtensionInfo /// The extension. protected DbContextOptionsExtensionInfo(IDbContextOptionsExtension extension) { - Check.NotNull(extension, nameof(extension)); - Extension = extension; } diff --git a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs index cd013e222f8..90261400eca 100644 --- a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs +++ b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs @@ -22,7 +22,6 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Update; using Microsoft.EntityFrameworkCore.Update.Internal; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.EntityFrameworkCore.ValueGeneration; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; @@ -166,8 +165,6 @@ public static readonly IDictionary CoreServices /// The collection to which services will be registered. public EntityFrameworkServicesBuilder(IServiceCollection serviceCollection) { - Check.NotNull(serviceCollection, nameof(serviceCollection)); - ServiceCollectionMap = new ServiceCollectionMap(serviceCollection); } @@ -226,8 +223,6 @@ protected virtual ServiceCharacteristics GetServiceCharacteristics(Type serviceT /// This builder, such that further calls can be chained. public virtual EntityFrameworkServicesBuilder TryAddProviderSpecificServices(Action serviceMap) { - Check.NotNull(serviceMap, nameof(serviceMap)); - ServiceCollectionMap.Validate = serviceType => { if (TryGetServiceCharacteristics(serviceType) != null) @@ -398,9 +393,6 @@ public virtual EntityFrameworkServicesBuilder TryAdd( /// This builder, such that further calls can be chained. public virtual EntityFrameworkServicesBuilder TryAdd(Type serviceType, Type implementationType) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(implementationType, nameof(implementationType)); - var characteristics = GetServiceCharacteristics(serviceType); if (characteristics.MultipleRegistrations) @@ -465,10 +457,6 @@ public virtual EntityFrameworkServicesBuilder TryAdd( Type implementationType, Func factory) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(implementationType, nameof(implementationType)); - Check.NotNull(factory, nameof(factory)); - var characteristics = GetServiceCharacteristics(serviceType); if (characteristics.MultipleRegistrations) @@ -519,9 +507,6 @@ public virtual EntityFrameworkServicesBuilder TryAdd( Type serviceType, object implementation) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(implementation, nameof(implementation)); - var characteristics = GetServiceCharacteristics(serviceType); if (characteristics.Lifetime != ServiceLifetime.Singleton) diff --git a/src/EFCore/Infrastructure/ExpressionExtensions.cs b/src/EFCore/Infrastructure/ExpressionExtensions.cs index cbf728d9e5a..cbfcc149f7b 100644 --- a/src/EFCore/Infrastructure/ExpressionExtensions.cs +++ b/src/EFCore/Infrastructure/ExpressionExtensions.cs @@ -39,7 +39,7 @@ public static class ExpressionExtensions /// An optional limit to the number of characters included. Additional output will be truncated. /// The printable representation. public static string Print(this Expression expression, int? characterLimit = null) - => new ExpressionPrinter().Print(Check.NotNull(expression, nameof(expression)), characterLimit); + => new ExpressionPrinter().Print(expression, characterLimit); /// /// Creates a that represents accessing either a field or a property. @@ -223,8 +223,6 @@ private static TMemberInfo GetInternalMemberAccess(this LambdaExpre /// The list of referenced properties. public static IReadOnlyList GetPropertyAccessList(this LambdaExpression propertyAccessExpression) { - Check.NotNull(propertyAccessExpression, nameof(propertyAccessExpression)); - if (propertyAccessExpression.Parameters.Count != 1) { throw new ArgumentException( @@ -262,8 +260,6 @@ public static IReadOnlyList GetPropertyAccessList(this LambdaExpre /// The list of referenced members. public static IReadOnlyList GetMemberAccessList(this LambdaExpression memberAccessExpression) { - Check.NotNull(memberAccessExpression, nameof(memberAccessExpression)); - var memberPaths = memberAccessExpression .MatchMemberAccessList((p, e) => e.MatchSimpleMemberAccess(p)); diff --git a/src/EFCore/Infrastructure/Internal/LazyLoader.cs b/src/EFCore/Infrastructure/Internal/LazyLoader.cs index 019eb148f97..fedd0afb251 100644 --- a/src/EFCore/Infrastructure/Internal/LazyLoader.cs +++ b/src/EFCore/Infrastructure/Internal/LazyLoader.cs @@ -33,9 +33,6 @@ public LazyLoader( ICurrentDbContext currentContext, IDiagnosticsLogger logger) { - Check.NotNull(currentContext, nameof(currentContext)); - Check.NotNull(logger, nameof(logger)); - Context = currentContext.Context; Logger = logger; } diff --git a/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs b/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs index 51212ac917d..575479e0e25 100644 --- a/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs +++ b/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -29,8 +28,6 @@ public class ModelCacheKeyFactory : IModelCacheKeyFactory /// Parameter object containing dependencies for this service. public ModelCacheKeyFactory(ModelCacheKeyFactoryDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Infrastructure/ModelCreationDependencies.cs b/src/EFCore/Infrastructure/ModelCreationDependencies.cs index cc53088cfed..48a745e4403 100644 --- a/src/EFCore/Infrastructure/ModelCreationDependencies.cs +++ b/src/EFCore/Infrastructure/ModelCreationDependencies.cs @@ -4,7 +4,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore @@ -29,6 +28,7 @@ public sealed record ModelCreationDependencies /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// + [EntityFrameworkInternal] public ModelCreationDependencies( IModelSource modelSource, IConventionSetBuilder conventionSetBuilder, @@ -36,12 +36,6 @@ public ModelCreationDependencies( IModelRuntimeInitializer modelRuntimeInitializer, IDiagnosticsLogger validationLogger) { - Check.NotNull(modelSource, nameof(modelSource)); - Check.NotNull(conventionSetBuilder, nameof(conventionSetBuilder)); - Check.NotNull(modelDependencies, nameof(modelDependencies)); - Check.NotNull(modelRuntimeInitializer, nameof(modelRuntimeInitializer)); - Check.NotNull(validationLogger, nameof(validationLogger)); - ModelSource = modelSource; ConventionSetBuilder = conventionSetBuilder; ModelDependencies = modelDependencies; diff --git a/src/EFCore/Infrastructure/ModelCustomizer.cs b/src/EFCore/Infrastructure/ModelCustomizer.cs index 3c8a34b4b44..b69486e4946 100644 --- a/src/EFCore/Infrastructure/ModelCustomizer.cs +++ b/src/EFCore/Infrastructure/ModelCustomizer.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -35,8 +34,6 @@ public class ModelCustomizer : IModelCustomizer /// Parameter object containing dependencies for this service. public ModelCustomizer(ModelCustomizerDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs b/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs index ec939492f04..3d2921720f7 100644 --- a/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs +++ b/src/EFCore/Infrastructure/ModelCustomizerDependencies.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -51,8 +50,6 @@ public sealed record ModelCustomizerDependencies [EntityFrameworkInternal] public ModelCustomizerDependencies(IDbSetFinder setFinder) { - Check.NotNull(setFinder, nameof(setFinder)); - #pragma warning disable CS0618 // Type or member is obsolete SetFinder = setFinder; #pragma warning restore CS0618 // Type or member is obsolete diff --git a/src/EFCore/Infrastructure/ModelDependencies.cs b/src/EFCore/Infrastructure/ModelDependencies.cs index 675b25b01c0..70fa08f2901 100644 --- a/src/EFCore/Infrastructure/ModelDependencies.cs +++ b/src/EFCore/Infrastructure/ModelDependencies.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -53,8 +52,6 @@ public sealed record ModelDependencies public ModelDependencies( IDiagnosticsLogger logger) { - Check.NotNull(logger, nameof(logger)); - Logger = logger; } diff --git a/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs b/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs index fb827aefe9e..bba11ea8d0d 100644 --- a/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs +++ b/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs @@ -4,7 +4,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -39,8 +38,6 @@ public class ModelRuntimeInitializer : IModelRuntimeInitializer /// The dependencies to use. public ModelRuntimeInitializer(ModelRuntimeInitializerDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs b/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs index d2c8404006f..6d0e2988ac5 100644 --- a/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs +++ b/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -52,9 +51,6 @@ public ModelRuntimeInitializerDependencies( RuntimeModelDependencies runtimeModelDependencies, IModelValidator modelValidator) { - Check.NotNull(runtimeModelDependencies, nameof(runtimeModelDependencies)); - Check.NotNull(modelValidator, nameof(modelValidator)); - ModelDependencies = runtimeModelDependencies; ModelValidator = modelValidator; } diff --git a/src/EFCore/Infrastructure/ModelSource.cs b/src/EFCore/Infrastructure/ModelSource.cs index b35c09cd5a6..5a646ab8c67 100644 --- a/src/EFCore/Infrastructure/ModelSource.cs +++ b/src/EFCore/Infrastructure/ModelSource.cs @@ -43,8 +43,6 @@ public class ModelSource : IModelSource /// The dependencies to use. public ModelSource(ModelSourceDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -183,8 +181,6 @@ protected virtual IModel CreateModel( DbContext context, IConventionSetBuilder conventionSetBuilder) { - Check.NotNull(context, nameof(context)); - var modelBuilder = new ModelBuilder(conventionSetBuilder.CreateConventionSet()); Dependencies.ModelCustomizer.Customize(modelBuilder, context); diff --git a/src/EFCore/Infrastructure/ModelSourceDependencies.cs b/src/EFCore/Infrastructure/ModelSourceDependencies.cs index 91d0ce4a1b8..6647ea73195 100644 --- a/src/EFCore/Infrastructure/ModelSourceDependencies.cs +++ b/src/EFCore/Infrastructure/ModelSourceDependencies.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; @@ -54,10 +53,6 @@ public ModelSourceDependencies( IModelCacheKeyFactory modelCacheKeyFactory, IMemoryCache memoryCache) { - Check.NotNull(modelCustomizer, nameof(modelCustomizer)); - Check.NotNull(modelCacheKeyFactory, nameof(modelCacheKeyFactory)); - Check.NotNull(memoryCache, nameof(memoryCache)); - ModelCustomizer = modelCustomizer; ModelCacheKeyFactory = modelCacheKeyFactory; MemoryCache = memoryCache; diff --git a/src/EFCore/Infrastructure/ModelValidator.cs b/src/EFCore/Infrastructure/ModelValidator.cs index fa1d933aa11..042c27d011d 100644 --- a/src/EFCore/Infrastructure/ModelValidator.cs +++ b/src/EFCore/Infrastructure/ModelValidator.cs @@ -41,8 +41,6 @@ public class ModelValidator : IModelValidator /// Parameter object containing dependencies for this service. public ModelValidator(ModelValidatorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -85,8 +83,6 @@ protected virtual void ValidateRelationships( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (var entityType in model.GetEntityTypes()) { foreach (var foreignKey in entityType.GetDeclaredForeignKeys()) @@ -153,8 +149,6 @@ protected virtual void ValidatePropertyMapping( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - if (model is not IConventionModel conventionModel) { return; @@ -323,8 +317,6 @@ protected virtual void ValidateIgnoredMembers( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - if (!(model is IConventionModel conventionModel)) { return; @@ -415,8 +407,6 @@ protected virtual void ValidateNoShadowKeys( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (IConventionEntityType entityType in model.GetEntityTypes()) { foreach (var key in entityType.GetDeclaredKeys()) @@ -456,8 +446,6 @@ protected virtual void ValidateNoMutableKeys( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (var entityType in model.GetEntityTypes()) { foreach (var key in entityType.GetDeclaredKeys()) @@ -480,8 +468,6 @@ protected virtual void ValidateNoCycles( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - var graph = new Multigraph(); foreach (var entityType in model.GetEntityTypes()) { @@ -522,8 +508,6 @@ protected virtual void ValidateNonNullPrimaryKeys( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - var entityTypeWithNullPk = model.GetEntityTypes() .FirstOrDefault(et => !((IConventionEntityType)et).IsKeyless && et.BaseType == null && et.FindPrimaryKey() == null); @@ -544,8 +528,6 @@ protected virtual void ValidateClrInheritance( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - var validEntityTypes = new HashSet(); foreach (var entityType in model.GetEntityTypes()) { @@ -558,10 +540,6 @@ private void ValidateClrInheritance( IEntityType entityType, HashSet validEntityTypes) { - Check.NotNull(model, nameof(model)); - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(validEntityTypes, nameof(validEntityTypes)); - if (validEntityTypes.Contains(entityType)) { return; @@ -691,8 +669,6 @@ protected virtual void ValidateChangeTrackingStrategy( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - var requireFullNotifications = (bool?)model[CoreAnnotationNames.FullChangeTrackingNotificationsRequired] == true; foreach (var entityType in model.GetEntityTypes()) { @@ -715,8 +691,6 @@ protected virtual void ValidateOwnership( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (var entityType in model.GetEntityTypes()) { var ownerships = entityType.GetForeignKeys().Where(fk => fk.IsOwnership).ToList(); @@ -792,8 +766,6 @@ protected virtual void ValidateForeignKeys( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (var entityType in model.GetEntityTypes()) { foreach (var declaredForeignKey in entityType.GetDeclaredForeignKeys()) @@ -864,8 +836,6 @@ protected virtual void ValidateFieldMapping( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (var entityType in model.GetEntityTypes()) { var properties = new HashSet( @@ -925,9 +895,6 @@ protected virtual void ValidateTypeMappings( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - Check.NotNull(logger, nameof(logger)); - foreach (var entityType in model.GetEntityTypes()) { foreach (var property in entityType.GetDeclaredProperties()) @@ -964,8 +931,6 @@ protected virtual void ValidateQueryFilters( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (var entityType in model.GetEntityTypes()) { if (entityType.GetQueryFilter() != null) @@ -1009,8 +974,6 @@ protected virtual void ValidateQueryFilters( /// The logger to use. protected virtual void ValidateData(IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - var identityMaps = new Dictionary(); var sensitiveDataLogged = logger.ShouldLogSensitiveData(); @@ -1148,8 +1111,6 @@ protected virtual void LogShadowProperties( IModel model, IDiagnosticsLogger logger) { - Check.NotNull(model, nameof(model)); - foreach (IConventionEntityType entityType in model.GetEntityTypes()) { foreach (var property in entityType.GetDeclaredProperties()) diff --git a/src/EFCore/Infrastructure/ModelValidatorDependencies.cs b/src/EFCore/Infrastructure/ModelValidatorDependencies.cs index 962cbfc6e5a..b113f854c44 100644 --- a/src/EFCore/Infrastructure/ModelValidatorDependencies.cs +++ b/src/EFCore/Infrastructure/ModelValidatorDependencies.cs @@ -4,7 +4,6 @@ using System; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -55,9 +54,6 @@ public ModelValidatorDependencies( ITypeMappingSource typeMappingSource, IMemberClassifier memberClassifier) { - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - Check.NotNull(memberClassifier, nameof(memberClassifier)); - #pragma warning disable CS0618 // Type or member is obsolete TypeMappingSource = typeMappingSource; #pragma warning restore CS0618 // Type or member is obsolete diff --git a/src/EFCore/Infrastructure/RuntimeModelDependencies.cs b/src/EFCore/Infrastructure/RuntimeModelDependencies.cs index b7a42daad66..a1444af055a 100644 --- a/src/EFCore/Infrastructure/RuntimeModelDependencies.cs +++ b/src/EFCore/Infrastructure/RuntimeModelDependencies.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -55,10 +54,6 @@ public RuntimeModelDependencies( IConstructorBindingFactory constructorBindingFactory, IParameterBindingFactories parameterBindingFactories) { - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - Check.NotNull(constructorBindingFactory, nameof(constructorBindingFactory)); - Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories)); - TypeMappingSource = typeMappingSource; ConstructorBindingFactory = constructorBindingFactory; ParameterBindingFactories = parameterBindingFactories; diff --git a/src/EFCore/Infrastructure/ServiceCollectionMap.cs b/src/EFCore/Infrastructure/ServiceCollectionMap.cs index c1acafcf1cd..2cdf6435d6a 100644 --- a/src/EFCore/Infrastructure/ServiceCollectionMap.cs +++ b/src/EFCore/Infrastructure/ServiceCollectionMap.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using Microsoft.EntityFrameworkCore.Infrastructure.Internal; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure @@ -35,8 +34,6 @@ public class ServiceCollectionMap : IInfrastructureThe collection to work with. public ServiceCollectionMap(IServiceCollection serviceCollection) { - Check.NotNull(serviceCollection, nameof(serviceCollection)); - _map = new InternalServiceCollectionMap(serviceCollection); } @@ -127,9 +124,6 @@ public virtual ServiceCollectionMap TryAdd( Type implementationType, ServiceLifetime lifetime) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(implementationType, nameof(implementationType)); - Validate?.Invoke(serviceType); var indexes = _map.GetOrCreateDescriptorIndexes(serviceType); @@ -259,9 +253,6 @@ public virtual ServiceCollectionMap TryAdd( Func factory, ServiceLifetime lifetime) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(factory, nameof(factory)); - Validate?.Invoke(serviceType); var indexes = _map.GetOrCreateDescriptorIndexes(serviceType); @@ -293,8 +284,6 @@ public virtual ServiceCollectionMap TryAddSingleton(TService implement /// The map, such that further calls can be chained. public virtual ServiceCollectionMap TryAddSingleton(Type serviceType, object implementation) { - Check.NotNull(serviceType, nameof(serviceType)); - Validate?.Invoke(serviceType); var indexes = _map.GetOrCreateDescriptorIndexes(serviceType); @@ -392,9 +381,6 @@ public virtual ServiceCollectionMap TryAddEnumerable( Type implementationType, ServiceLifetime lifetime) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(implementationType, nameof(implementationType)); - Validate?.Invoke(serviceType); var indexes = _map.GetOrCreateDescriptorIndexes(serviceType); @@ -467,10 +453,6 @@ public virtual ServiceCollectionMap TryAddEnumerable( Func factory, ServiceLifetime lifetime) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(implementationType, nameof(implementationType)); - Check.NotNull(factory, nameof(factory)); - Validate?.Invoke(serviceType); var indexes = _map.GetOrCreateDescriptorIndexes(serviceType); @@ -504,9 +486,6 @@ public virtual ServiceCollectionMap TryAddSingletonEnumerable(TService /// The map, such that further calls can be chained. public virtual ServiceCollectionMap TryAddSingletonEnumerable(Type serviceType, object implementation) { - Check.NotNull(serviceType, nameof(serviceType)); - Check.NotNull(implementation, nameof(implementation)); - Validate?.Invoke(serviceType); var implementationType = implementation.GetType(); diff --git a/src/EFCore/Internal/DbContextFactory.cs b/src/EFCore/Internal/DbContextFactory.cs index dec9e4b5924..a6cc7b1ff4d 100644 --- a/src/EFCore/Internal/DbContextFactory.cs +++ b/src/EFCore/Internal/DbContextFactory.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Internal { @@ -30,10 +29,6 @@ public DbContextFactory( DbContextOptions options, IDbContextFactorySource factorySource) { - Check.NotNull(serviceProvider, nameof(serviceProvider)); - Check.NotNull(options, nameof(options)); - Check.NotNull(factorySource, nameof(factorySource)); - _serviceProvider = serviceProvider; _options = options; _factory = factorySource.Factory; diff --git a/src/EFCore/Internal/InternalDbSet.cs b/src/EFCore/Internal/InternalDbSet.cs index 281308596f3..d5677a2260e 100644 --- a/src/EFCore/Internal/InternalDbSet.cs +++ b/src/EFCore/Internal/InternalDbSet.cs @@ -47,8 +47,6 @@ public class InternalDbSet : /// public InternalDbSet(DbContext context, string? entityTypeName) { - Check.NotNull(context, nameof(context)); - // Just storing context/service locator here so that the context will be initialized by the time the // set is used and services will be obtained from the correctly scoped container when this happens. _context = context; diff --git a/src/EFCore/Metadata/Builders/DiscriminatorBuilder`.cs b/src/EFCore/Metadata/Builders/DiscriminatorBuilder`.cs index 32557d68acc..3f4ea85a9bf 100644 --- a/src/EFCore/Metadata/Builders/DiscriminatorBuilder`.cs +++ b/src/EFCore/Metadata/Builders/DiscriminatorBuilder`.cs @@ -3,7 +3,6 @@ using System; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Builders { @@ -25,8 +24,6 @@ public class DiscriminatorBuilder [EntityFrameworkInternal] public DiscriminatorBuilder(DiscriminatorBuilder builder) { - Check.NotNull(builder, nameof(builder)); - Builder = builder; } diff --git a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilder.cs b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilder.cs index 83ed2c935f8..796d5f19c5d 100644 --- a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilder.cs +++ b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilder.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure @@ -42,8 +41,6 @@ public class ProviderConventionSetBuilder : IProviderConventionSetBuilder /// Parameter object containing dependencies for this service. public ProviderConventionSetBuilder(ProviderConventionSetBuilderDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs index eaaaf3f7f9d..0d1a00b2d13 100644 --- a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs +++ b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure @@ -72,15 +71,6 @@ public ProviderConventionSetBuilderDependencies( ICurrentDbContext currentContext, IModelValidator validator) { - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - Check.NotNull(constructorBindingFactory, nameof(constructorBindingFactory)); - Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories)); - Check.NotNull(memberClassifier, nameof(memberClassifier)); - Check.NotNull(logger, nameof(logger)); - Check.NotNull(validationLogger, nameof(validationLogger)); - Check.NotNull(setFinder, nameof(setFinder)); - Check.NotNull(validator, nameof(validator)); - TypeMappingSource = typeMappingSource; ConstructorBindingFactory = constructorBindingFactory; ParameterBindingFactories = parameterBindingFactories; diff --git a/src/EFCore/Metadata/Internal/ForeignKey.cs b/src/EFCore/Metadata/Internal/ForeignKey.cs index fbfd3dc141c..e8c7d9dc916 100644 --- a/src/EFCore/Metadata/Internal/ForeignKey.cs +++ b/src/EFCore/Metadata/Internal/ForeignKey.cs @@ -57,11 +57,6 @@ public ForeignKey( EntityType principalEntityType, ConfigurationSource configurationSource) { - Check.NotEmpty(dependentProperties, nameof(dependentProperties)); - Check.HasNoNulls(dependentProperties, nameof(dependentProperties)); - Check.NotNull(principalKey, nameof(principalKey)); - Check.NotNull(principalEntityType, nameof(principalEntityType)); - Validate(dependentProperties, principalKey, dependentEntityType, principalEntityType); Properties = dependentProperties; diff --git a/src/EFCore/Metadata/Internal/Index.cs b/src/EFCore/Metadata/Internal/Index.cs index a796af71e62..f41fcce0764 100644 --- a/src/EFCore/Metadata/Internal/Index.cs +++ b/src/EFCore/Metadata/Internal/Index.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -42,10 +41,6 @@ public Index( EntityType declaringEntityType, ConfigurationSource configurationSource) { - Check.NotEmpty(properties, nameof(properties)); - Check.HasNoNulls(properties, nameof(properties)); - Check.NotNull(declaringEntityType, nameof(declaringEntityType)); - Properties = properties; DeclaringEntityType = declaringEntityType; _configurationSource = configurationSource; @@ -66,8 +61,6 @@ public Index( ConfigurationSource configurationSource) : this(properties, declaringEntityType, configurationSource) { - Check.NotEmpty(name, nameof(name)); - Name = name; } diff --git a/src/EFCore/Metadata/Internal/Key.cs b/src/EFCore/Metadata/Internal/Key.cs index f9c96652846..88deea175d3 100644 --- a/src/EFCore/Metadata/Internal/Key.cs +++ b/src/EFCore/Metadata/Internal/Key.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -39,9 +38,6 @@ public class Key : ConventionAnnotatable, IMutableKey, IConventionKey, IRuntimeK /// public Key(IReadOnlyList properties, ConfigurationSource configurationSource) { - Check.NotEmpty(properties, nameof(properties)); - Check.HasNoNulls(properties, nameof(properties)); - Properties = properties; _configurationSource = configurationSource; diff --git a/src/EFCore/Metadata/Internal/MemberClassifier.cs b/src/EFCore/Metadata/Internal/MemberClassifier.cs index 44a9aebcb21..e8bd4895409 100644 --- a/src/EFCore/Metadata/Internal/MemberClassifier.cs +++ b/src/EFCore/Metadata/Internal/MemberClassifier.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure.Internal; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -34,9 +33,6 @@ public MemberClassifier( ITypeMappingSource typeMappingSource, IParameterBindingFactories parameterBindingFactories) { - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories)); - _typeMappingSource = typeMappingSource; _parameterBindingFactories = parameterBindingFactories; } diff --git a/src/EFCore/Metadata/Internal/Navigation.cs b/src/EFCore/Metadata/Internal/Navigation.cs index 2ff2500e801..5cbba7e366a 100644 --- a/src/EFCore/Metadata/Internal/Navigation.cs +++ b/src/EFCore/Metadata/Internal/Navigation.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -40,8 +39,6 @@ public Navigation( ForeignKey foreignKey) : base(name, propertyInfo, fieldInfo, ConfigurationSource.Convention) { - Check.NotNull(foreignKey, nameof(foreignKey)); - ForeignKey = foreignKey; _builder = new InternalNavigationBuilder(this, foreignKey.DeclaringEntityType.Model.Builder); diff --git a/src/EFCore/Metadata/Internal/Property.cs b/src/EFCore/Metadata/Internal/Property.cs index d4370279826..62e6a87ce9b 100644 --- a/src/EFCore/Metadata/Internal/Property.cs +++ b/src/EFCore/Metadata/Internal/Property.cs @@ -14,7 +14,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.EntityFrameworkCore.ValueGeneration; namespace Microsoft.EntityFrameworkCore.Metadata.Internal @@ -55,9 +54,6 @@ public Property( ConfigurationSource? typeConfigurationSource) : base(name, propertyInfo, fieldInfo, configurationSource) { - Check.NotNull(clrType, nameof(clrType)); - Check.NotNull(declaringEntityType, nameof(declaringEntityType)); - DeclaringEntityType = declaringEntityType; ClrType = clrType; _typeConfigurationSource = typeConfigurationSource; @@ -830,7 +826,7 @@ public virtual CoreTypeMapping? TypeMapping /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ValueComparer? GetValueComparer() - => (ValueComparer?)this[CoreAnnotationNames.ValueComparer] + => (ValueComparer?)this[CoreAnnotationNames.ValueComparer] ?? FindFirstDifferentPrincipal()?.GetValueComparer() ?? TypeMapping?.Comparer; @@ -848,7 +844,7 @@ public virtual CoreTypeMapping? TypeMapping private IProperty? FindFirstDifferentPrincipal() { var principal = ((IProperty)this).FindFirstPrincipal(); - + return principal != this ? principal : null; } diff --git a/src/EFCore/Metadata/Internal/PropertyBase.cs b/src/EFCore/Metadata/Internal/PropertyBase.cs index 9fcde2850e3..4883d77ee14 100644 --- a/src/EFCore/Metadata/Internal/PropertyBase.cs +++ b/src/EFCore/Metadata/Internal/PropertyBase.cs @@ -47,8 +47,6 @@ protected PropertyBase( FieldInfo? fieldInfo, ConfigurationSource configurationSource) { - Check.NotEmpty(name, nameof(name)); - Name = name; PropertyInfo = propertyInfo; _fieldInfo = fieldInfo; diff --git a/src/EFCore/Metadata/Internal/PropertyConfiguration.cs b/src/EFCore/Metadata/Internal/PropertyConfiguration.cs index fa601bd63a8..1506f845e2f 100644 --- a/src/EFCore/Metadata/Internal/PropertyConfiguration.cs +++ b/src/EFCore/Metadata/Internal/PropertyConfiguration.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -28,8 +27,6 @@ public class PropertyConfiguration : AnnotatableBase, ITypeMappingConfiguration /// public PropertyConfiguration(Type clrType) { - Check.NotNull(clrType, nameof(clrType)); - ClrType = clrType; } diff --git a/src/EFCore/Metadata/Internal/ServiceProperty.cs b/src/EFCore/Metadata/Internal/ServiceProperty.cs index 481be069463..d68aef545a7 100644 --- a/src/EFCore/Metadata/Internal/ServiceProperty.cs +++ b/src/EFCore/Metadata/Internal/ServiceProperty.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -39,8 +38,6 @@ public ServiceProperty( ConfigurationSource configurationSource) : base(name, propertyInfo, fieldInfo, configurationSource) { - Check.NotNull(declaringEntityType, nameof(declaringEntityType)); - DeclaringEntityType = declaringEntityType; ClrType = (propertyInfo?.PropertyType ?? fieldInfo?.FieldType)!; diff --git a/src/EFCore/Metadata/Internal/SkipNavigation.cs b/src/EFCore/Metadata/Internal/SkipNavigation.cs index 75f6047a928..7a4d1fccd86 100644 --- a/src/EFCore/Metadata/Internal/SkipNavigation.cs +++ b/src/EFCore/Metadata/Internal/SkipNavigation.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Internal { @@ -47,9 +46,6 @@ public SkipNavigation( ConfigurationSource configurationSource) : base(name, propertyInfo, fieldInfo, configurationSource) { - Check.NotNull(declaringEntityType, nameof(declaringEntityType)); - Check.NotNull(targetEntityType, nameof(targetEntityType)); - DeclaringEntityType = declaringEntityType; TargetEntityType = targetEntityType; IsCollection = collection; diff --git a/src/EFCore/Metadata/Internal/TypeBase.cs b/src/EFCore/Metadata/Internal/TypeBase.cs index bc904f5c174..0d51c64e5b3 100644 --- a/src/EFCore/Metadata/Internal/TypeBase.cs +++ b/src/EFCore/Metadata/Internal/TypeBase.cs @@ -56,10 +56,6 @@ protected TypeBase(Type type, Model model, ConfigurationSource configurationSour /// protected TypeBase(string name, Type type, Model model, ConfigurationSource configurationSource) { - Check.NotEmpty(name, nameof(name)); - Check.NotNull(type, nameof(type)); - Check.NotNull(model, nameof(model)); - Name = name; ClrType = type; Model = model; diff --git a/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs b/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs index 33d8aeb871a..3f2a7764ed2 100644 --- a/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs +++ b/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs @@ -38,8 +38,6 @@ public class LazyLoaderParameterBindingFactory : ServiceParameterBindingFactory public LazyLoaderParameterBindingFactory(LazyLoaderParameterBindingFactoryDependencies dependencies) : base(typeof(ILazyLoader)) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -57,14 +55,9 @@ public LazyLoaderParameterBindingFactory(LazyLoaderParameterBindingFactoryDepend public override bool CanBind( Type parameterType, string parameterName) - { - Check.NotNull(parameterType, nameof(parameterType)); - Check.NotEmpty(parameterName, nameof(parameterName)); - - return IsLazyLoader(parameterType) + => IsLazyLoader(parameterType) || IsLazyLoaderMethod(parameterType, parameterName) || IsLazyLoaderAsyncMethod(parameterType, parameterName); - } /// /// Creates a for the given type and name on the given entity type. @@ -78,10 +71,6 @@ public override ParameterBinding Bind( Type parameterType, string parameterName) { - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(parameterType, nameof(parameterType)); - Check.NotEmpty(parameterName, nameof(parameterName)); - var baseType = entityType; do { @@ -105,10 +94,6 @@ public override ParameterBinding Bind( Type parameterType, string parameterName) { - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(parameterType, nameof(parameterType)); - Check.NotEmpty(parameterName, nameof(parameterName)); - var baseType = entityType; do { @@ -131,13 +116,7 @@ public override ParameterBinding Bind( IReadOnlyEntityType entityType, Type parameterType, string parameterName) - { - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(parameterType, nameof(parameterType)); - Check.NotEmpty(parameterName, nameof(parameterName)); - - return Bind((IEntityType)entityType, parameterType); - } + => Bind((IEntityType)entityType, parameterType); private static ParameterBinding Bind(IEntityType entityType, Type parameterType) => parameterType == typeof(ILazyLoader) diff --git a/src/EFCore/Metadata/ServiceParameterBindingFactory.cs b/src/EFCore/Metadata/ServiceParameterBindingFactory.cs index 4c2b934d443..75d460753c5 100644 --- a/src/EFCore/Metadata/ServiceParameterBindingFactory.cs +++ b/src/EFCore/Metadata/ServiceParameterBindingFactory.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Metadata @@ -32,8 +31,6 @@ public class ServiceParameterBindingFactory : IParameterBindingFactory /// The service type. public ServiceParameterBindingFactory(Type serviceType) { - Check.NotNull(serviceType, nameof(serviceType)); - _serviceType = serviceType; } @@ -85,15 +82,9 @@ public virtual ParameterBinding Bind( IReadOnlyEntityType entityType, Type parameterType, string parameterName) - { - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(parameterType, nameof(parameterType)); - Check.NotEmpty(parameterName, nameof(parameterName)); - - return new DependencyInjectionParameterBinding( + => new DependencyInjectionParameterBinding( _serviceType, _serviceType, entityType.GetServiceProperties().Cast().Where(p => p.ClrType == _serviceType).ToArray()); - } } } diff --git a/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs b/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs index e8a7e4ec95e..a4451794b84 100644 --- a/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs +++ b/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Query @@ -39,8 +38,6 @@ public class CompiledQueryCacheKeyGenerator : ICompiledQueryCacheKeyGenerator /// Parameter object containing dependencies for this service. public CompiledQueryCacheKeyGenerator(CompiledQueryCacheKeyGeneratorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -66,7 +63,7 @@ public virtual object GenerateCacheKey(Expression query, bool async) /// The cache key. protected CompiledQueryCacheKey GenerateCacheKeyCore(Expression query, bool async) // Intentionally non-virtual => new( - Check.NotNull(query, nameof(query)), + query, Dependencies.Model, Dependencies.CurrentContext.Context.ChangeTracker.QueryTrackingBehavior, async); diff --git a/src/EFCore/Query/EntityShaperExpression.cs b/src/EFCore/Query/EntityShaperExpression.cs index 879a1862561..21eee8d1aac 100644 --- a/src/EFCore/Query/EntityShaperExpression.cs +++ b/src/EFCore/Query/EntityShaperExpression.cs @@ -12,7 +12,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -68,9 +67,6 @@ protected EntityShaperExpression( bool nullable, LambdaExpression? materializationCondition) { - Check.NotNull(entityType, nameof(entityType)); - Check.NotNull(valueBufferExpression, nameof(valueBufferExpression)); - if (materializationCondition == null) { materializationCondition = GenerateMaterializationCondition(entityType, nullable); @@ -100,8 +96,8 @@ protected static Expression CreateUnableToDiscriminateExceptionExpression(IEntit Throw( Call( _createUnableToDiscriminateException, - Constant(Check.NotNull(entityType, nameof(entityType))), - Convert(Check.NotNull(discriminatorValue, nameof(discriminatorValue)), typeof(object)))), + Constant(entityType), + Convert(discriminatorValue, typeof(object)))), Constant(null, typeof(IEntityType))); /// @@ -112,8 +108,6 @@ protected static Expression CreateUnableToDiscriminateExceptionExpression(IEntit /// An expression of representing materilization condition for the entity type. protected virtual LambdaExpression GenerateMaterializationCondition(IEntityType entityType, bool nullable) { - Check.NotNull(entityType, nameof(EntityType)); - var valueBufferParameter = Parameter(typeof(ValueBuffer)); Expression body; var concreteEntityTypes = entityType.GetConcreteDerivedTypesInclusive().ToArray(); @@ -208,8 +202,6 @@ protected virtual LambdaExpression GenerateMaterializationCondition(IEntityType /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var valueBufferExpression = visitor.Visit(ValueBufferExpression); return Update(valueBufferExpression); @@ -221,13 +213,9 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The new entity type to use. /// This expression if entity type not changed, or an expression with updated entity type. public virtual EntityShaperExpression WithEntityType(IEntityType entityType) - { - Check.NotNull(entityType, nameof(entityType)); - - return entityType != EntityType + => entityType != EntityType ? new EntityShaperExpression(entityType, ValueBufferExpression, IsNullable) : this; - } /// /// Assigns nullability for this shaper, indicating whether it can shape null entity instances or not. @@ -247,13 +235,9 @@ public virtual EntityShaperExpression MakeNullable(bool nullable = true) /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual EntityShaperExpression Update(Expression valueBufferExpression) - { - Check.NotNull(valueBufferExpression, nameof(valueBufferExpression)); - - return valueBufferExpression != ValueBufferExpression + => valueBufferExpression != ValueBufferExpression ? new EntityShaperExpression(EntityType, valueBufferExpression, IsNullable, MaterializationCondition) : this; - } /// public override Type Type @@ -266,8 +250,6 @@ public sealed override ExpressionType NodeType /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine(nameof(EntityShaperExpression) + ": "); using (expressionPrinter.Indent()) { diff --git a/src/EFCore/Query/EvaluatableExpressionFilter.cs b/src/EFCore/Query/EvaluatableExpressionFilter.cs index bd645f727df..2061eceacbf 100644 --- a/src/EFCore/Query/EvaluatableExpressionFilter.cs +++ b/src/EFCore/Query/EvaluatableExpressionFilter.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Query @@ -69,8 +68,6 @@ private static readonly MethodInfo _randomNextTwoArgs public EvaluatableExpressionFilter( EvaluatableExpressionFilterDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -87,9 +84,6 @@ public EvaluatableExpressionFilter( /// if the expression can be evaluated; otherwise. public virtual bool IsEvaluatableExpression(Expression expression, IModel model) { - Check.NotNull(expression, nameof(expression)); - Check.NotNull(model, nameof(model)); - switch (expression) { case MemberExpression memberExpression: diff --git a/src/EFCore/Query/EvaluatableExpressionFilterDependencies.cs b/src/EFCore/Query/EvaluatableExpressionFilterDependencies.cs index d86cfdb023e..f039d7d0e3e 100644 --- a/src/EFCore/Query/EvaluatableExpressionFilterDependencies.cs +++ b/src/EFCore/Query/EvaluatableExpressionFilterDependencies.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Query @@ -51,8 +50,6 @@ public sealed record EvaluatableExpressionFilterDependencies [EntityFrameworkInternal] public EvaluatableExpressionFilterDependencies(IEnumerable plugins) { - Check.NotNull(plugins, nameof(plugins)); - Plugins = plugins; } diff --git a/src/EFCore/Query/ExpressionPrinter.cs b/src/EFCore/Query/ExpressionPrinter.cs index cc778e04694..d164e7c1d6f 100644 --- a/src/EFCore/Query/ExpressionPrinter.cs +++ b/src/EFCore/Query/ExpressionPrinter.cs @@ -11,7 +11,6 @@ using System.Runtime.CompilerServices; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -88,8 +87,6 @@ public virtual void VisitCollection( Action? joinAction = null) where T : Expression { - Check.NotNull(items, nameof(items)); - joinAction ??= (p => p.Append(", ")); var first = true; @@ -184,8 +181,6 @@ private string PrintCore( int? characterLimit, bool verbose) { - Check.NotNull(expression, nameof(expression)); - _stringBuilder.Clear(); _parametersInScope.Clear(); _namelessParameters.Clear(); @@ -349,8 +344,6 @@ public virtual string GenerateBinaryOperator(ExpressionType expressionType) /// protected override Expression VisitBinary(BinaryExpression binaryExpression) { - Check.NotNull(binaryExpression, nameof(binaryExpression)); - Visit(binaryExpression.Left); if (binaryExpression.NodeType == ExpressionType.ArrayIndex) @@ -381,8 +374,6 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) /// protected override Expression VisitBlock(BlockExpression blockExpression) { - Check.NotNull(blockExpression, nameof(blockExpression)); - AppendLine(); AppendLine("{"); @@ -426,8 +417,6 @@ protected override Expression VisitBlock(BlockExpression blockExpression) /// protected override Expression VisitConditional(ConditionalExpression conditionalExpression) { - Check.NotNull(conditionalExpression, nameof(conditionalExpression)); - Visit(conditionalExpression.Test); _stringBuilder.Append(" ? "); @@ -444,8 +433,6 @@ protected override Expression VisitConditional(ConditionalExpression conditional /// protected override Expression VisitConstant(ConstantExpression constantExpression) { - Check.NotNull(constantExpression, nameof(constantExpression)); - if (constantExpression.Value is IPrintableExpression printable) { printable.Print(this); @@ -501,8 +488,6 @@ private void Print(object? value) /// protected override Expression VisitGoto(GotoExpression gotoExpression) { - Check.NotNull(gotoExpression, nameof(gotoExpression)); - AppendLine("return (" + gotoExpression.Target.Type.ShortDisplayName() + ")" + gotoExpression.Target + " {"); using (_stringBuilder.Indent()) { @@ -517,8 +502,6 @@ protected override Expression VisitGoto(GotoExpression gotoExpression) /// protected override Expression VisitLabel(LabelExpression labelExpression) { - Check.NotNull(labelExpression, nameof(labelExpression)); - _stringBuilder.Append(labelExpression.Target.ToString()); return labelExpression; @@ -527,8 +510,6 @@ protected override Expression VisitLabel(LabelExpression labelExpression) /// protected override Expression VisitLambda(Expression lambdaExpression) { - Check.NotNull(lambdaExpression, nameof(lambdaExpression)); - if (lambdaExpression.Parameters.Count != 1) { _stringBuilder.Append("("); @@ -572,8 +553,6 @@ protected override Expression VisitLambda(Expression lambdaExpression) /// protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - if (memberExpression.Expression != null) { if (memberExpression.Expression.NodeType == ExpressionType.Convert @@ -602,8 +581,6 @@ protected override Expression VisitMember(MemberExpression memberExpression) /// protected override Expression VisitMemberInit(MemberInitExpression memberInitExpression) { - Check.NotNull(memberInitExpression, nameof(memberInitExpression)); - _stringBuilder.Append("new " + memberInitExpression.Type.ShortDisplayName()); var appendAction = memberInitExpression.Bindings.Count > 1 ? (Func)AppendLine : Append; @@ -634,8 +611,6 @@ protected override Expression VisitMemberInit(MemberInitExpression memberInitExp /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (methodCallExpression.Object != null) { if (methodCallExpression.Object is BinaryExpression) @@ -766,8 +741,6 @@ static void PrintGenericArguments(MethodInfo method, IndentedStringBuilder strin /// protected override Expression VisitNew(NewExpression newExpression) { - Check.NotNull(newExpression, nameof(newExpression)); - _stringBuilder.Append("new "); var isComplex = newExpression.Arguments.Count > 1; @@ -821,8 +794,6 @@ protected override Expression VisitNew(NewExpression newExpression) /// protected override Expression VisitNewArray(NewArrayExpression newArrayExpression) { - Check.NotNull(newArrayExpression, nameof(newArrayExpression)); - var isComplex = newArrayExpression.Expressions.Count > 1; var appendAction = isComplex ? s => AppendLine(s) : (Action)(s => Append(s)); @@ -850,8 +821,6 @@ protected override Expression VisitNewArray(NewArrayExpression newArrayExpressio /// protected override Expression VisitParameter(ParameterExpression parameterExpression) { - Check.NotNull(parameterExpression, nameof(parameterExpression)); - if (_parametersInScope.TryGetValue(parameterExpression, out var parameterName)) { if (parameterName == null) @@ -911,8 +880,6 @@ protected override Expression VisitParameter(ParameterExpression parameterExpres /// protected override Expression VisitUnary(UnaryExpression unaryExpression) { - Check.NotNull(unaryExpression, nameof(unaryExpression)); - // ReSharper disable once SwitchStatementMissingSomeCases switch (unaryExpression.NodeType) { @@ -964,8 +931,6 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) /// protected override Expression VisitDefault(DefaultExpression defaultExpression) { - Check.NotNull(defaultExpression, nameof(defaultExpression)); - _stringBuilder.Append("default(" + defaultExpression.Type.ShortDisplayName() + ")"); return defaultExpression; @@ -974,8 +939,6 @@ protected override Expression VisitDefault(DefaultExpression defaultExpression) /// protected override Expression VisitTry(TryExpression tryExpression) { - Check.NotNull(tryExpression, nameof(tryExpression)); - _stringBuilder.Append("try { "); Visit(tryExpression.Body); _stringBuilder.Append(" } "); @@ -991,8 +954,6 @@ protected override Expression VisitTry(TryExpression tryExpression) /// protected override Expression VisitIndex(IndexExpression indexExpression) { - Check.NotNull(indexExpression, nameof(indexExpression)); - Visit(indexExpression.Object); _stringBuilder.Append("["); VisitArguments( @@ -1005,8 +966,6 @@ protected override Expression VisitIndex(IndexExpression indexExpression) /// protected override Expression VisitTypeBinary(TypeBinaryExpression typeBinaryExpression) { - Check.NotNull(typeBinaryExpression, nameof(typeBinaryExpression)); - _stringBuilder.Append("("); Visit(typeBinaryExpression.Expression); _stringBuilder.Append(" is " + typeBinaryExpression.TypeOperand.ShortDisplayName() + ")"); @@ -1060,8 +1019,6 @@ protected override Expression VisitSwitch(SwitchExpression switchExpression) /// protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - if (extensionExpression is IPrintableExpression printable) { printable.Print(this); diff --git a/src/EFCore/Query/GroupByShaperExpression.cs b/src/EFCore/Query/GroupByShaperExpression.cs index 0f7be966cd2..58156aca372 100644 --- a/src/EFCore/Query/GroupByShaperExpression.cs +++ b/src/EFCore/Query/GroupByShaperExpression.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using System.Linq.Expressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -32,9 +31,6 @@ public GroupByShaperExpression( Expression keySelector, ShapedQueryExpression groupingEnumerable) { - Check.NotNull(keySelector, nameof(keySelector)); - Check.NotNull(groupingEnumerable, nameof(groupingEnumerable)); - KeySelector = keySelector; GroupingEnumerable = groupingEnumerable; } @@ -60,8 +56,6 @@ public sealed override ExpressionType NodeType /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var keySelector = visitor.Visit(KeySelector); var groupingEnumerable = (ShapedQueryExpression)visitor.Visit(GroupingEnumerable); @@ -76,20 +70,13 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual GroupByShaperExpression Update(Expression keySelector, ShapedQueryExpression groupingEnumerable) - { - Check.NotNull(keySelector, nameof(keySelector)); - Check.NotNull(groupingEnumerable, nameof(groupingEnumerable)); - - return keySelector != KeySelector || groupingEnumerable != GroupingEnumerable + => keySelector != KeySelector || groupingEnumerable != GroupingEnumerable ? new GroupByShaperExpression(keySelector, groupingEnumerable) : this; - } /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine($"{nameof(GroupByShaperExpression)}:"); expressionPrinter.Append("KeySelector: "); expressionPrinter.Visit(KeySelector); diff --git a/src/EFCore/Query/IncludeExpression.cs b/src/EFCore/Query/IncludeExpression.cs index e48d99a5568..71d6c51fe94 100644 --- a/src/EFCore/Query/IncludeExpression.cs +++ b/src/EFCore/Query/IncludeExpression.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -52,10 +51,6 @@ public IncludeExpression( INavigationBase navigation, bool setLoaded) { - Check.NotNull(entityExpression, nameof(entityExpression)); - Check.NotNull(navigationExpression, nameof(navigationExpression)); - Check.NotNull(navigation, nameof(navigation)); - EntityExpression = entityExpression; NavigationExpression = navigationExpression; Navigation = navigation; @@ -97,8 +92,6 @@ public sealed override ExpressionType NodeType /// protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - var newEntityExpression = visitor.Visit(EntityExpression); var newNavigationExpression = visitor.Visit(NavigationExpression); @@ -113,20 +106,13 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual IncludeExpression Update(Expression entityExpression, Expression navigationExpression) - { - Check.NotNull(entityExpression, nameof(entityExpression)); - Check.NotNull(navigationExpression, nameof(navigationExpression)); - - return entityExpression != EntityExpression || navigationExpression != NavigationExpression + => entityExpression != EntityExpression || navigationExpression != NavigationExpression ? new IncludeExpression(entityExpression, navigationExpression, Navigation, SetLoaded) : this; - } /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine("IncludeExpression("); using (expressionPrinter.Indent()) { diff --git a/src/EFCore/Query/Internal/CompiledQueryBase.cs b/src/EFCore/Query/Internal/CompiledQueryBase.cs index 10a15076d2e..63ea3e58032 100644 --- a/src/EFCore/Query/Internal/CompiledQueryBase.cs +++ b/src/EFCore/Query/Internal/CompiledQueryBase.cs @@ -8,7 +8,6 @@ using System.Threading; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -113,8 +112,6 @@ public QueryExpressionRewriter( protected override Expression VisitParameter(ParameterExpression parameterExpression) { - Check.NotNull(parameterExpression, nameof(parameterExpression)); - if (typeof(TContext).IsAssignableFrom(parameterExpression.Type)) { return Expression.Constant(_context); diff --git a/src/EFCore/Query/Internal/EntityQueryable`.cs b/src/EFCore/Query/Internal/EntityQueryable`.cs index 6d8b5ab4136..52a27914cb5 100644 --- a/src/EFCore/Query/Internal/EntityQueryable`.cs +++ b/src/EFCore/Query/Internal/EntityQueryable`.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -47,9 +46,6 @@ public EntityQueryable(IAsyncQueryProvider queryProvider, IEntityType entityType /// public EntityQueryable(IAsyncQueryProvider queryProvider, Expression expression) { - Check.NotNull(queryProvider, nameof(queryProvider)); - Check.NotNull(expression, nameof(expression)); - _queryProvider = queryProvider; Expression = expression; } diff --git a/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs b/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs index 96cad159081..a2f262eef07 100644 --- a/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs @@ -4,7 +4,6 @@ using System.Collections.ObjectModel; using System.Linq; using System.Linq.Expressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -24,8 +23,6 @@ public class InvocationExpressionRemovingExpressionVisitor : ExpressionVisitor /// protected override Expression VisitInvocation(InvocationExpression invocationExpression) { - Check.NotNull(invocationExpression, nameof(invocationExpression)); - var invokedExpression = StripTrivialConversions(invocationExpression.Expression); return invokedExpression is LambdaExpression lambdaExpression diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs index 19b65bed747..7c84f91df7f 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs @@ -57,8 +57,6 @@ public Expression Expand(Expression expression, bool applyIncludes = false) protected override Expression VisitExtension(Expression expression) { - Check.NotNull(expression, nameof(expression)); - switch (expression) { case NavigationExpansionExpression _: @@ -72,8 +70,6 @@ protected override Expression VisitExtension(Expression expression) protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - var innerExpression = Visit(memberExpression.Expression); return TryExpandNavigation(innerExpression, MemberIdentity.Create(memberExpression.Member)) ?? memberExpression.Update(innerExpression); @@ -81,8 +77,6 @@ protected override Expression VisitMember(MemberExpression memberExpression) protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (methodCallExpression.TryGetEFPropertyArguments(out var source, out var navigationName)) { source = Visit(source); @@ -548,8 +542,6 @@ bool IsEntityReference(Expression expression) protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - switch (extensionExpression) { case NavigationTreeExpression navigationTreeExpression: @@ -581,8 +573,6 @@ protected override Expression VisitExtension(Expression extensionExpression) protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - if (memberExpression.Expression != null) { // If it is mapped property then, it would get converted to a column so we don't need to expand includes. @@ -599,8 +589,6 @@ protected override Expression VisitMember(MemberExpression memberExpression) protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (methodCallExpression.TryGetEFPropertyArguments(out _, out _)) { // If it is EF.Property then, it would get converted to a column or throw @@ -624,8 +612,6 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp protected override Expression VisitNew(NewExpression newExpression) { - Check.NotNull(newExpression, nameof(newExpression)); - var arguments = new Expression[newExpression.Arguments.Count]; for (var i = 0; i < newExpression.Arguments.Count; i++) { @@ -1094,14 +1080,10 @@ public SelfReferenceEntityQueryableRewritingExpressionVisitor( } protected override Expression VisitExtension(Expression extensionExpression) - { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - - return extensionExpression is QueryRootExpression queryRootExpression + => extensionExpression is QueryRootExpression queryRootExpression && queryRootExpression.EntityType == _entityType ? _navigationExpandingExpressionVisitor.CreateNavigationExpansionExpression(queryRootExpression, _entityType) : base.VisitExtension(extensionExpression); - } } private sealed class CloningExpressionVisitor : ExpressionVisitor diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs index 705d906a102..cdb5796f42b 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -38,11 +37,7 @@ public override Type Type => EntityType.ClrType; protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; public EntityReference Snapshot() { @@ -60,8 +55,6 @@ public void MarkAsOptional() void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Append($"{nameof(EntityReference)}: {EntityType.DisplayName()}"); if (IsOptional) { @@ -303,16 +296,10 @@ public override Type Type : PendingSelector.Type; protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine(nameof(NavigationExpansionExpression)); using (expressionPrinter.Indent()) { @@ -369,16 +356,10 @@ public override ExpressionType NodeType public override Type Type { get; } protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine(nameof(GroupByNavigationExpansionExpression)); using (expressionPrinter.Indent()) { @@ -412,8 +393,6 @@ public NavigationTreeExpression(Expression value) protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - Value = visitor.Visit(Value); return this; @@ -424,8 +403,6 @@ public override Type Type void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine(nameof(NavigationTreeExpression)); using (expressionPrinter.Indent()) { @@ -505,8 +482,6 @@ public OwnedNavigationReference(Expression parent, INavigation navigation, Entit protected override Expression VisitChildren(ExpressionVisitor visitor) { - Check.NotNull(visitor, nameof(visitor)); - Parent = visitor.Visit(Parent); return this; diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs index a93212904ef..52b2483f121 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs @@ -153,8 +153,6 @@ public virtual Expression Expand(Expression query) /// protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - switch (extensionExpression) { case QueryRootExpression queryRootExpression: @@ -203,8 +201,6 @@ protected override Expression VisitExtension(Expression extensionExpression) /// protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - var innerExpression = Visit(memberExpression.Expression); // Convert ICollection.Count to Count() @@ -255,8 +251,6 @@ protected override Expression VisitMember(MemberExpression memberExpression) /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - var method = methodCallExpression.Method; if (method.DeclaringType == typeof(Queryable) || method.DeclaringType == typeof(QueryableExtensions) diff --git a/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs b/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs index a20e90ca62a..1df4230476c 100644 --- a/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/NullCheckRemovingExpressionVisitor.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -41,8 +40,6 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) /// protected override Expression VisitConditional(ConditionalExpression conditionalExpression) { - Check.NotNull(conditionalExpression, nameof(conditionalExpression)); - var test = Visit(conditionalExpression.Test); if (test is BinaryExpression binaryTest @@ -150,8 +147,6 @@ public bool Verify(Expression caller, Expression result) protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - var innerExpression = Visit(memberExpression.Expression); if (innerExpression != null && _nullSafeAccesses.Contains(innerExpression)) @@ -164,8 +159,6 @@ protected override Expression VisitMember(MemberExpression memberExpression) protected override Expression VisitUnary(UnaryExpression unaryExpression) { - Check.NotNull(unaryExpression, nameof(unaryExpression)); - var operand = Visit(unaryExpression.Operand); if ((unaryExpression.NodeType == ExpressionType.Convert || unaryExpression.NodeType == ExpressionType.ConvertChecked) diff --git a/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs b/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs index d6a8045e746..e746c791577 100644 --- a/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs +++ b/src/EFCore/Query/Internal/QueryCompilationContextFactory.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; - namespace Microsoft.EntityFrameworkCore.Query.Internal { /// @@ -21,8 +19,6 @@ public class QueryCompilationContextFactory : IQueryCompilationContextFactory /// public QueryCompilationContextFactory(QueryCompilationContextDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Query/Internal/QueryCompiler.cs b/src/EFCore/Query/Internal/QueryCompiler.cs index fa7cc821dd0..6b12583f60b 100644 --- a/src/EFCore/Query/Internal/QueryCompiler.cs +++ b/src/EFCore/Query/Internal/QueryCompiler.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -46,15 +45,6 @@ public QueryCompiler( IEvaluatableExpressionFilter evaluatableExpressionFilter, IModel model) { - Check.NotNull(queryContextFactory, nameof(queryContextFactory)); - Check.NotNull(compiledQueryCache, nameof(compiledQueryCache)); - Check.NotNull(compiledQueryCacheKeyGenerator, nameof(compiledQueryCacheKeyGenerator)); - Check.NotNull(database, nameof(database)); - Check.NotNull(logger, nameof(logger)); - Check.NotNull(currentContext, nameof(currentContext)); - Check.NotNull(evaluatableExpressionFilter, nameof(evaluatableExpressionFilter)); - Check.NotNull(model, nameof(model)); - _queryContextFactory = queryContextFactory; _compiledQueryCache = compiledQueryCache; _compiledQueryCacheKeyGenerator = compiledQueryCacheKeyGenerator; @@ -73,8 +63,6 @@ public QueryCompiler( /// public virtual TResult Execute(Expression query) { - Check.NotNull(query, nameof(query)); - var queryContext = _queryContextFactory.Create(); query = ExtractParameters(query, queryContext, _logger); @@ -109,8 +97,6 @@ public virtual Func CompileQueryCore( /// public virtual Func CreateCompiledQuery(Expression query) { - Check.NotNull(query, nameof(query)); - query = ExtractParameters(query, _queryContextFactory.Create(), _logger, parameterize: false); return CompileQueryCore(_database, query, _model, false); @@ -124,8 +110,6 @@ public virtual Func CreateCompiledQuery(Expressi /// public virtual TResult ExecuteAsync(Expression query, CancellationToken cancellationToken = default) { - Check.NotNull(query, nameof(query)); - var queryContext = _queryContextFactory.Create(); queryContext.CancellationToken = cancellationToken; @@ -149,8 +133,6 @@ var compiledQuery /// public virtual Func CreateCompiledAsyncQuery(Expression query) { - Check.NotNull(query, nameof(query)); - query = ExtractParameters(query, _queryContextFactory.Create(), _logger, parameterize: false); return CompileQueryCore(_database, query, _model, true); diff --git a/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs b/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs index a1358d8caaf..74433501b53 100644 --- a/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs @@ -8,7 +8,6 @@ using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -165,8 +164,6 @@ protected override ElementInit VisitElementInit(ElementInit elementInit) /// protected override Expression VisitLambda(Expression lambdaExpression) { - Check.NotNull(lambdaExpression, nameof(lambdaExpression)); - var body = Visit(lambdaExpression.Body); return body.Type != lambdaExpression.Body.Type @@ -216,8 +213,6 @@ protected override MemberAssignment VisitMemberAssignment(MemberAssignment membe /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (Equals(_startsWithMethodInfo, methodCallExpression.Method) || Equals(_endsWithMethodInfo, methodCallExpression.Method)) { @@ -383,8 +378,6 @@ protected override Expression VisitNewArray(NewArrayExpression newArrayExpressio /// protected override Expression VisitUnary(UnaryExpression unaryExpression) { - Check.NotNull(unaryExpression, nameof(unaryExpression)); - if (unaryExpression.NodeType == ExpressionType.Not && unaryExpression.Operand is MethodCallExpression innerMethodCall && (Equals(_startsWithMethodInfo, innerMethodCall.Method) diff --git a/src/EFCore/Query/Internal/QueryTranslationPostprocessorFactory.cs b/src/EFCore/Query/Internal/QueryTranslationPostprocessorFactory.cs index 3297b82c9f1..a0a27fdd7ae 100644 --- a/src/EFCore/Query/Internal/QueryTranslationPostprocessorFactory.cs +++ b/src/EFCore/Query/Internal/QueryTranslationPostprocessorFactory.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; - namespace Microsoft.EntityFrameworkCore.Query.Internal { /// @@ -39,10 +37,6 @@ public QueryTranslationPostprocessorFactory(QueryTranslationPostprocessorDepende /// 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 QueryTranslationPostprocessor(Dependencies, queryCompilationContext); - } + => new QueryTranslationPostprocessor(Dependencies, queryCompilationContext); } } diff --git a/src/EFCore/Query/Internal/QueryTranslationPreprocessorFactory.cs b/src/EFCore/Query/Internal/QueryTranslationPreprocessorFactory.cs index 8c3d2ea8379..f201e002818 100644 --- a/src/EFCore/Query/Internal/QueryTranslationPreprocessorFactory.cs +++ b/src/EFCore/Query/Internal/QueryTranslationPreprocessorFactory.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; - namespace Microsoft.EntityFrameworkCore.Query.Internal { /// @@ -39,10 +37,6 @@ public QueryTranslationPreprocessorFactory(QueryTranslationPreprocessorDependenc /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QueryTranslationPreprocessor Create(QueryCompilationContext queryCompilationContext) - { - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - - return new QueryTranslationPreprocessor(Dependencies, queryCompilationContext); - } + => new QueryTranslationPreprocessor(Dependencies, queryCompilationContext); } } diff --git a/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs b/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs index e3180068c70..58775458884 100644 --- a/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -34,8 +33,6 @@ public class QueryableMethodNormalizingExpressionVisitor : ExpressionVisitor /// public QueryableMethodNormalizingExpressionVisitor(QueryCompilationContext queryCompilationContext) { - Check.NotNull(queryCompilationContext, nameof(Query)); - _queryCompilationContext = queryCompilationContext; } @@ -47,8 +44,6 @@ public QueryableMethodNormalizingExpressionVisitor(QueryCompilationContext query /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - var method = methodCallExpression.Method; // Extract information from query metadata method and prune them @@ -703,8 +698,6 @@ public bool VerifyCollectionSelector(Expression body, ParameterExpression rootPa protected override Expression VisitLambda(Expression lambdaExpression) { - Check.NotNull(lambdaExpression, nameof(lambdaExpression)); - try { _allowedParameters.AddRange(lambdaExpression.Parameters); @@ -722,8 +715,6 @@ protected override Expression VisitLambda(Expression lambdaExpression) protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (_correlated) { return methodCallExpression; @@ -753,8 +744,6 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp protected override Expression VisitParameter(ParameterExpression parameterExpression) { - Check.NotNull(parameterExpression, nameof(parameterExpression)); - if (_allowedParameters.Contains(parameterExpression)) { return parameterExpression; diff --git a/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs b/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs index 14a0932969d..62d199dd1d5 100644 --- a/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs @@ -7,7 +7,6 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query.Internal { @@ -68,8 +67,6 @@ public SubqueryMemberPushdownExpressionVisitor(IModel model) /// protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - var innerExpression = Visit(memberExpression.Expression); if (innerExpression is MethodCallExpression methodCallExpression && methodCallExpression.Method.IsGenericMethod @@ -99,8 +96,6 @@ protected override Expression VisitMember(MemberExpression memberExpression) /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (methodCallExpression.TryGetEFPropertyArguments(out var source, out _)) { source = Visit(source); diff --git a/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs b/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs index 9035fab4ccf..481f1a3df14 100644 --- a/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs +++ b/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -30,9 +29,6 @@ public class MaterializeCollectionNavigationExpression : Expression, IPrintableE /// A navigation associated with this collection. public MaterializeCollectionNavigationExpression(Expression subquery, INavigationBase navigation) { - Check.NotNull(subquery, nameof(subquery)); - Check.NotNull(navigation, nameof(navigation)); - Subquery = subquery; Navigation = navigation; } @@ -57,11 +53,7 @@ public override Type Type /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return Update(visitor.Visit(Subquery)); - } + => Update(visitor.Visit(Subquery)); /// /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will @@ -70,19 +62,13 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual MaterializeCollectionNavigationExpression Update(Expression subquery) - { - Check.NotNull(subquery, nameof(subquery)); - - return subquery != Subquery + => subquery != Subquery ? new MaterializeCollectionNavigationExpression(subquery, Navigation) : this; - } /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine("MaterializeCollectionNavigation("); using (expressionPrinter.Indent()) { diff --git a/src/EFCore/Query/ProjectionBindingExpression.cs b/src/EFCore/Query/ProjectionBindingExpression.cs index c62e790f770..023da7cb18f 100644 --- a/src/EFCore/Query/ProjectionBindingExpression.cs +++ b/src/EFCore/Query/ProjectionBindingExpression.cs @@ -37,10 +37,6 @@ public ProjectionBindingExpression( ProjectionMember projectionMember, Type type) { - Check.NotNull(queryExpression, nameof(queryExpression)); - Check.NotNull(projectionMember, nameof(projectionMember)); - Check.NotNull(type, nameof(type)); - QueryExpression = queryExpression; ProjectionMember = projectionMember; Type = type; @@ -57,9 +53,6 @@ public ProjectionBindingExpression( int index, Type type) { - Check.NotNull(queryExpression, nameof(queryExpression)); - Check.NotNull(type, nameof(type)); - QueryExpression = queryExpression; Index = index; Type = type; @@ -89,17 +82,11 @@ public sealed override ExpressionType NodeType /// protected override Expression VisitChildren(ExpressionVisitor visitor) - { - Check.NotNull(visitor, nameof(visitor)); - - return this; - } + => this; /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.Append(nameof(ProjectionBindingExpression) + ": "); if (ProjectionMember != null) { diff --git a/src/EFCore/Query/ProjectionMember.cs b/src/EFCore/Query/ProjectionMember.cs index 9cf91fc9dcf..d64fe84dcc5 100644 --- a/src/EFCore/Query/ProjectionMember.cs +++ b/src/EFCore/Query/ProjectionMember.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Linq; using System.Reflection; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -38,8 +37,6 @@ public ProjectionMember() private ProjectionMember(IList memberChain) { - Check.NotNull(memberChain, nameof(memberChain)); - _memberChain = memberChain; } @@ -50,8 +47,6 @@ private ProjectionMember(IList memberChain) /// A new projection member with given member info appended to existing chain. public ProjectionMember Append(MemberInfo member) { - Check.NotNull(member, nameof(member)); - var existingChain = _memberChain.ToList(); existingChain.Add(member); @@ -65,8 +60,6 @@ public ProjectionMember Append(MemberInfo member) /// A new projection member with given member info prepended to existing chain. public ProjectionMember Prepend(MemberInfo member) { - Check.NotNull(member, nameof(member)); - var existingChain = _memberChain.ToList(); existingChain.Insert(0, member); diff --git a/src/EFCore/Query/QueryCompilationContext.cs b/src/EFCore/Query/QueryCompilationContext.cs index a3aa10e9fce..b822b6adcbb 100644 --- a/src/EFCore/Query/QueryCompilationContext.cs +++ b/src/EFCore/Query/QueryCompilationContext.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -80,8 +79,6 @@ public QueryCompilationContext( QueryCompilationContextDependencies dependencies, bool async) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; IsAsync = async; QueryTrackingBehavior = dependencies.QueryTrackingBehavior; @@ -159,11 +156,7 @@ public QueryCompilationContext( /// /// The tag to add. public virtual void AddTag(string tag) - { - Check.NotEmpty(tag, nameof(tag)); - - Tags.Add(tag); - } + => Tags.Add(tag); /// /// Creates the query executor func which gives results for this query. @@ -173,8 +166,6 @@ public virtual void AddTag(string tag) /// Returns which can be invoked to get results of this query. public virtual Func CreateQueryExecutor(Expression query) { - Check.NotNull(query, nameof(query)); - Logger.QueryCompilationStarting(_expressionPrinter, query); query = _queryTranslationPreprocessorFactory.Create(this).Process(query); @@ -211,9 +202,6 @@ public virtual Func CreateQueryExecutor(Expressi /// public virtual ParameterExpression RegisterRuntimeParameter(string name, LambdaExpression valueExtractor) { - Check.NotEmpty(name, nameof(name)); - Check.NotNull(valueExtractor, nameof(valueExtractor)); - if (valueExtractor.Parameters.Count != 1 || valueExtractor.Parameters[0] != QueryContextParameter) { diff --git a/src/EFCore/Query/QueryContext.cs b/src/EFCore/Query/QueryContext.cs index 6c01b70f3a7..bb3677d22fa 100644 --- a/src/EFCore/Query/QueryContext.cs +++ b/src/EFCore/Query/QueryContext.cs @@ -43,11 +43,8 @@ public abstract class QueryContext : IParameterValues /// /// /// The dependencies to use. - protected QueryContext( - QueryContextDependencies dependencies) + protected QueryContext(QueryContextDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; Context = dependencies.CurrentContext.Context; } @@ -69,9 +66,6 @@ protected QueryContext( /// The navigation property. public virtual void SetNavigationIsLoaded(object entity, INavigationBase navigation) { - Check.NotNull(entity, nameof(entity)); - Check.NotNull(navigation, nameof(navigation)); - // InitializeStateManager will populate the field before calling here _stateManager!.TryGetEntry(entity)!.SetIsLoaded(navigation); } @@ -117,11 +111,7 @@ public virtual IDiagnosticsLogger QueryLogger /// The name. /// The value. public virtual void AddParameter(string name, object? value) - { - Check.NotEmpty(name, nameof(name)); - - _parameterValues.Add(name, value); - } + => _parameterValues.Add(name, value); /// /// Initializes the to be used with this QueryContext. diff --git a/src/EFCore/Query/QueryRootExpression.cs b/src/EFCore/Query/QueryRootExpression.cs index 981a4177ded..8fc660b7f7b 100644 --- a/src/EFCore/Query/QueryRootExpression.cs +++ b/src/EFCore/Query/QueryRootExpression.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -33,9 +32,6 @@ public class QueryRootExpression : Expression, IPrintableExpression /// The entity type this query root represents. public QueryRootExpression(IAsyncQueryProvider asyncQueryProvider, IEntityType entityType) { - Check.NotNull(asyncQueryProvider, nameof(asyncQueryProvider)); - Check.NotNull(entityType, nameof(entityType)); - QueryProvider = asyncQueryProvider; EntityType = entityType; Type = typeof(IQueryable<>).MakeGenericType(entityType.ClrType); @@ -47,8 +43,6 @@ public QueryRootExpression(IAsyncQueryProvider asyncQueryProvider, IEntityType e /// The entity type this query root represents. public QueryRootExpression(IEntityType entityType) { - Check.NotNull(entityType, nameof(entityType)); - EntityType = entityType; QueryProvider = null; Type = typeof(IQueryable<>).MakeGenericType(entityType.ClrType); @@ -103,8 +97,6 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The expression printer to use. protected virtual void Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - if (EntityType.HasSharedClrType) { expressionPrinter.Append($"DbSet<{EntityType.ClrType.ShortDisplayName()}>(\"{EntityType.Name}\")"); diff --git a/src/EFCore/Query/QueryTranslationPostprocessor.cs b/src/EFCore/Query/QueryTranslationPostprocessor.cs index 09ee42a4353..d0121f4baca 100644 --- a/src/EFCore/Query/QueryTranslationPostprocessor.cs +++ b/src/EFCore/Query/QueryTranslationPostprocessor.cs @@ -31,9 +31,6 @@ public QueryTranslationPostprocessor( QueryTranslationPostprocessorDependencies dependencies, QueryCompilationContext queryCompilationContext) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - Dependencies = dependencies; QueryCompilationContext = queryCompilationContext; } @@ -54,10 +51,6 @@ public QueryTranslationPostprocessor( /// The query to process. /// A query expression after transformations. public virtual Expression Process(Expression query) - { - Check.NotNull(query, nameof(query)); - - return query; - } + => query; } } diff --git a/src/EFCore/Query/QueryTranslationPreprocessor.cs b/src/EFCore/Query/QueryTranslationPreprocessor.cs index 80bb7dea857..431b6292e6c 100644 --- a/src/EFCore/Query/QueryTranslationPreprocessor.cs +++ b/src/EFCore/Query/QueryTranslationPreprocessor.cs @@ -3,7 +3,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -31,9 +30,6 @@ public QueryTranslationPreprocessor( QueryTranslationPreprocessorDependencies dependencies, QueryCompilationContext queryCompilationContext) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - Dependencies = dependencies; QueryCompilationContext = queryCompilationContext; } @@ -55,8 +51,6 @@ public QueryTranslationPreprocessor( /// A query expression after transformations. public virtual Expression Process(Expression query) { - Check.NotNull(query, nameof(query)); - query = new InvocationExpressionRemovingExpressionVisitor().Visit(query); query = NormalizeQueryableMethod(query); query = new NullCheckRemovingExpressionVisitor().Visit(query); @@ -85,6 +79,6 @@ public virtual Expression Process(Expression query) /// A query expression after normalization has been done. public virtual Expression NormalizeQueryableMethod(Expression expression) => new QueryableMethodNormalizingExpressionVisitor(QueryCompilationContext) - .Visit(Check.NotNull(expression, nameof(expression))); + .Visit(expression); } } diff --git a/src/EFCore/Query/QueryTranslationPreprocessorDependencies.cs b/src/EFCore/Query/QueryTranslationPreprocessorDependencies.cs index 8c502a65527..a534e3bdfd6 100644 --- a/src/EFCore/Query/QueryTranslationPreprocessorDependencies.cs +++ b/src/EFCore/Query/QueryTranslationPreprocessorDependencies.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Query @@ -53,9 +52,6 @@ public QueryTranslationPreprocessorDependencies( IEvaluatableExpressionFilter evaluatableExpressionFilter, INavigationExpansionExtensibilityHelper navigationExpansionExtensibilityHelper) { - Check.NotNull(evaluatableExpressionFilter, nameof(evaluatableExpressionFilter)); - Check.NotNull(navigationExpansionExtensibilityHelper, nameof(navigationExpansionExtensibilityHelper)); - EvaluatableExpressionFilter = evaluatableExpressionFilter; NavigationExpansionExtensibilityHelper = navigationExpansionExtensibilityHelper; } diff --git a/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs index 553d75c3ec9..48bd620660b 100644 --- a/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs @@ -5,12 +5,10 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; -using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -43,9 +41,6 @@ protected QueryableMethodTranslatingExpressionVisitor( QueryCompilationContext queryCompilationContext, bool subquery) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - Dependencies = dependencies; QueryCompilationContext = queryCompilationContext; _subquery = subquery; @@ -68,8 +63,6 @@ protected QueryableMethodTranslatingExpressionVisitor( /// Error encountered during translation. protected virtual void AddTranslationErrorDetails(string details) { - Check.NotNull(details, nameof(details)); - if (TranslationErrorDetails == null) { TranslationErrorDetails = details; @@ -87,22 +80,16 @@ protected virtual void AddTranslationErrorDetails(string details) /// protected override Expression VisitExtension(Expression extensionExpression) - { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - - return extensionExpression switch + => extensionExpression switch { ShapedQueryExpression _ => extensionExpression, QueryRootExpression queryRootExpression => CreateShapedQueryExpression(queryRootExpression.EntityType), _ => base.VisitExtension(extensionExpression), }; - } /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - ShapedQueryExpression CheckTranslated(ShapedQueryExpression? translated) { return translated @@ -504,13 +491,9 @@ LambdaExpression GetLambdaExpressionFromArgument(int argumentIndex) private sealed class EntityShaperNullableMarkingExpressionVisitor : ExpressionVisitor { protected override Expression VisitExtension(Expression extensionExpression) - { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - - return extensionExpression is EntityShaperExpression entityShaper + => extensionExpression is EntityShaperExpression entityShaper ? entityShaper.MakeNullable() : base.VisitExtension(extensionExpression); - } } /// @@ -519,11 +502,7 @@ protected override Expression VisitExtension(Expression extensionExpression) /// The shaper expression to process. /// New shaper expression in which all entity shapers are nullable. protected virtual Expression MarkShaperNullable(Expression shaperExpression) - { - Check.NotNull(shaperExpression, nameof(shaperExpression)); - - return _entityShaperNullableMarkingExpressionVisitor.Visit(shaperExpression); - } + => _entityShaperNullableMarkingExpressionVisitor.Visit(shaperExpression); /// /// Translates the given subquery. @@ -532,8 +511,6 @@ protected virtual Expression MarkShaperNullable(Expression shaperExpression) /// The translation of the given subquery. public virtual ShapedQueryExpression? TranslateSubquery(Expression expression) { - Check.NotNull(expression, nameof(expression)); - var subqueryVisitor = CreateSubqueryVisitor(); var translation = subqueryVisitor.Visit(expression) as ShapedQueryExpression; if (translation == null && subqueryVisitor.TranslationErrorDetails != null) diff --git a/src/EFCore/Query/QueryableMethods.cs b/src/EFCore/Query/QueryableMethods.cs index 398a2de32df..5e6408bea10 100644 --- a/src/EFCore/Query/QueryableMethods.cs +++ b/src/EFCore/Query/QueryableMethods.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -376,11 +375,7 @@ public static class QueryableMethods /// The method to check. /// if the method matches; otherwise. public static bool IsAverageWithoutSelector(MethodInfo methodInfo) - { - Check.NotNull(methodInfo, nameof(methodInfo)); - - return AverageWithoutSelectorMethods.Values.Contains(methodInfo); - } + => AverageWithoutSelectorMethods.Values.Contains(methodInfo); /// /// Checks whether or not the given is one of the with a selector. @@ -388,12 +383,8 @@ public static bool IsAverageWithoutSelector(MethodInfo methodInfo) /// The method to check. /// if the method matches; otherwise. public static bool IsAverageWithSelector(MethodInfo methodInfo) - { - Check.NotNull(methodInfo, nameof(methodInfo)); - - return methodInfo.IsGenericMethod + => methodInfo.IsGenericMethod && AverageWithSelectorMethods.Values.Contains(methodInfo.GetGenericMethodDefinition()); - } /// /// Checks whether or not the given is one of the without a selector. @@ -401,11 +392,7 @@ public static bool IsAverageWithSelector(MethodInfo methodInfo) /// The method to check. /// if the method matches; otherwise. public static bool IsSumWithoutSelector(MethodInfo methodInfo) - { - Check.NotNull(methodInfo, nameof(methodInfo)); - - return SumWithoutSelectorMethods.Values.Contains(methodInfo); - } + => SumWithoutSelectorMethods.Values.Contains(methodInfo); /// /// Checks whether or not the given is one of the with a selector. @@ -413,12 +400,8 @@ public static bool IsSumWithoutSelector(MethodInfo methodInfo) /// The method to check. /// if the method matches; otherwise. public static bool IsSumWithSelector(MethodInfo methodInfo) - { - Check.NotNull(methodInfo, nameof(methodInfo)); - - return methodInfo.IsGenericMethod + => methodInfo.IsGenericMethod && SumWithSelectorMethods.Values.Contains(methodInfo.GetGenericMethodDefinition()); - } /// /// Returns the for the method without a selector for the given type. @@ -426,11 +409,7 @@ public static bool IsSumWithSelector(MethodInfo methodInfo) /// The generic type of the method to create. /// The . public static MethodInfo GetAverageWithoutSelector(Type type) - { - Check.NotNull(type, nameof(type)); - - return AverageWithoutSelectorMethods[type]; - } + => AverageWithoutSelectorMethods[type]; /// /// Returns the for the method with a selector for the given type. @@ -438,11 +417,7 @@ public static MethodInfo GetAverageWithoutSelector(Type type) /// The generic type of the method to create. /// The . public static MethodInfo GetAverageWithSelector(Type type) - { - Check.NotNull(type, nameof(type)); - - return AverageWithSelectorMethods[type]; - } + => AverageWithSelectorMethods[type]; /// /// Returns the for the method without a selector for the given type. @@ -450,11 +425,7 @@ public static MethodInfo GetAverageWithSelector(Type type) /// The generic type of the method to create. /// The . public static MethodInfo GetSumWithoutSelector(Type type) - { - Check.NotNull(type, nameof(type)); - - return SumWithoutSelectorMethods[type]; - } + => SumWithoutSelectorMethods[type]; /// /// Returns the for the method with a selector for the given type. @@ -462,11 +433,7 @@ public static MethodInfo GetSumWithoutSelector(Type type) /// The generic type of the method to create. /// The . public static MethodInfo GetSumWithSelector(Type type) - { - Check.NotNull(type, nameof(type)); - - return SumWithSelectorMethods[type]; - } + => SumWithSelectorMethods[type]; private static Dictionary AverageWithoutSelectorMethods { get; } private static Dictionary AverageWithSelectorMethods { get; } diff --git a/src/EFCore/Query/ReplacingExpressionVisitor.cs b/src/EFCore/Query/ReplacingExpressionVisitor.cs index 6ea386a822e..22015a885c6 100644 --- a/src/EFCore/Query/ReplacingExpressionVisitor.cs +++ b/src/EFCore/Query/ReplacingExpressionVisitor.cs @@ -37,13 +37,7 @@ public class ReplacingExpressionVisitor : ExpressionVisitor /// The expression tree in which replacement is going to be performed. /// An expression tree with replacements made. public static Expression Replace(Expression original, Expression replacement, Expression tree) - { - Check.NotNull(original, nameof(original)); - Check.NotNull(replacement, nameof(replacement)); - Check.NotNull(tree, nameof(tree)); - - return new ReplacingExpressionVisitor(new[] { original }, new[] { replacement }).Visit(tree); - } + => new ReplacingExpressionVisitor(new[] { original }, new[] { replacement }).Visit(tree); /// /// Creates a new instance of the class. @@ -52,9 +46,6 @@ public static Expression Replace(Expression original, Expression replacement, Ex /// A list of expressions to be used as replacements. public ReplacingExpressionVisitor(IReadOnlyList originals, IReadOnlyList replacements) { - Check.NotNull(originals, nameof(originals)); - Check.NotNull(replacements, nameof(replacements)); - _originals = originals; _replacements = replacements; } @@ -86,8 +77,6 @@ public ReplacingExpressionVisitor(IReadOnlyList originals, IReadOnly /// protected override Expression VisitMember(MemberExpression memberExpression) { - Check.NotNull(memberExpression, nameof(memberExpression)); - var innerExpression = Visit(memberExpression.Expression); if (innerExpression is GroupByShaperExpression groupByShaperExpression @@ -119,8 +108,6 @@ protected override Expression VisitMember(MemberExpression memberExpression) /// protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (methodCallExpression.TryGetEFPropertyArguments(out var entityExpression, out var propertyName)) { var newEntityExpression = Visit(entityExpression); diff --git a/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs b/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs index 21b95474d1d..c06fadd780b 100644 --- a/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs +++ b/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs @@ -15,7 +15,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -60,9 +59,6 @@ protected ShapedQueryCompilingExpressionVisitor( ShapedQueryCompilingExpressionVisitorDependencies dependencies, QueryCompilationContext queryCompilationContext) { - Check.NotNull(dependencies, nameof(dependencies)); - Check.NotNull(queryCompilationContext, nameof(queryCompilationContext)); - Dependencies = dependencies; QueryCompilationContext = queryCompilationContext; @@ -98,8 +94,6 @@ protected ShapedQueryCompilingExpressionVisitor( /// protected override Expression VisitExtension(Expression extensionExpression) { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - if (extensionExpression is ShapedQueryExpression shapedQueryExpression) { var serverEnumerable = VisitShapedQuery(shapedQueryExpression); @@ -199,8 +193,6 @@ private static async Task SingleAsync( /// A expression with entity materializers injected. protected virtual Expression InjectEntityMaterializers(Expression expression) { - Check.NotNull(expression, nameof(expression)); - VerifyNoClientConstant(expression); return _entityMaterializerInjectingExpressionVisitor.Inject(expression); @@ -211,11 +203,7 @@ protected virtual Expression InjectEntityMaterializers(Expression expression) /// /// An expression to verify. protected virtual void VerifyNoClientConstant(Expression expression) - { - Check.NotNull(expression, nameof(expression)); - - _constantVerifyingExpressionVisitor.Visit(expression); - } + => _constantVerifyingExpressionVisitor.Visit(expression); private sealed class ConstantVerifyingExpressionVisitor : ExpressionVisitor { @@ -236,8 +224,6 @@ private bool ValidConstant(ConstantExpression constantExpression) protected override Expression VisitConstant(ConstantExpression constantExpression) { - Check.NotNull(constantExpression, nameof(constantExpression)); - if (!ValidConstant(constantExpression)) { throw new InvalidOperationException( @@ -249,8 +235,6 @@ protected override Expression VisitConstant(ConstantExpression constantExpressio protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { - Check.NotNull(methodCallExpression, nameof(methodCallExpression)); - if (RemoveConvert(methodCallExpression.Object) is ConstantExpression constantInstance && !ValidConstant(constantInstance)) { @@ -276,14 +260,10 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp } protected override Expression VisitExtension(Expression extensionExpression) - { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - - return extensionExpression is EntityShaperExpression + => extensionExpression is EntityShaperExpression || extensionExpression is ProjectionBindingExpression ? extensionExpression : base.VisitExtension(extensionExpression); - } private static Expression? RemoveConvert(Expression? expression) { @@ -364,13 +344,9 @@ bool ContainsOwner(IEntityType? owner) } protected override Expression VisitExtension(Expression extensionExpression) - { - Check.NotNull(extensionExpression, nameof(extensionExpression)); - - return extensionExpression is EntityShaperExpression entityShaperExpression + => extensionExpression is EntityShaperExpression entityShaperExpression ? ProcessEntityShaper(entityShaperExpression) : base.VisitExtension(extensionExpression); - } private Expression ProcessEntityShaper(EntityShaperExpression entityShaperExpression) { diff --git a/src/EFCore/Query/ShapedQueryCompilingExpressionVisitorDependencies.cs b/src/EFCore/Query/ShapedQueryCompilingExpressionVisitorDependencies.cs index 5591cc49ddf..9036aed8581 100644 --- a/src/EFCore/Query/ShapedQueryCompilingExpressionVisitorDependencies.cs +++ b/src/EFCore/Query/ShapedQueryCompilingExpressionVisitorDependencies.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; @@ -57,11 +56,6 @@ public ShapedQueryCompilingExpressionVisitorDependencies( IMemoryCache memoryCache, ICoreSingletonOptions coreSingletonOptions) { - Check.NotNull(entityMaterializerSource, nameof(entityMaterializerSource)); - Check.NotNull(typeMappingSource, nameof(typeMappingSource)); - Check.NotNull(memoryCache, nameof(memoryCache)); - Check.NotNull(coreSingletonOptions, nameof(coreSingletonOptions)); - EntityMaterializerSource = entityMaterializerSource; TypeMappingSource = typeMappingSource; MemoryCache = memoryCache; diff --git a/src/EFCore/Query/ShapedQueryExpression.cs b/src/EFCore/Query/ShapedQueryExpression.cs index d007179c3d7..500e299b8a5 100644 --- a/src/EFCore/Query/ShapedQueryExpression.cs +++ b/src/EFCore/Query/ShapedQueryExpression.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -31,8 +30,8 @@ public class ShapedQueryExpression : Expression, IPrintableExpression /// The shaper expression to create result objects from server results. public ShapedQueryExpression(Expression queryExpression, Expression shaperExpression) : this( - Check.NotNull(queryExpression, nameof(queryExpression)), - Check.NotNull(shaperExpression, nameof(shaperExpression)), + queryExpression, + shaperExpression, ResultCardinality.Enumerable) { } @@ -85,14 +84,9 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual ShapedQueryExpression Update(Expression queryExpression, Expression shaperExpression) - { - Check.NotNull(queryExpression, nameof(queryExpression)); - Check.NotNull(shaperExpression, nameof(shaperExpression)); - - return queryExpression != QueryExpression || shaperExpression != ShaperExpression + => queryExpression != QueryExpression || shaperExpression != ShaperExpression ? new ShapedQueryExpression(queryExpression, shaperExpression, ResultCardinality) : this; - } /// /// Creates a new expression that is like this one, but using the supplied shaper expression. If shaper expression is the same, it will @@ -101,13 +95,9 @@ public virtual ShapedQueryExpression Update(Expression queryExpression, Expressi /// The property of the result. /// This expression if shaper expression did not change, or an expression with the updated shaper expression. public virtual ShapedQueryExpression UpdateShaperExpression(Expression shaperExpression) - { - Check.NotNull(shaperExpression, nameof(shaperExpression)); - - return shaperExpression != ShaperExpression + => shaperExpression != ShaperExpression ? new ShapedQueryExpression(QueryExpression, shaperExpression, ResultCardinality) : this; - } /// /// Creates a new expression that is like this one, but with supplied result cardinality. @@ -120,8 +110,6 @@ public virtual ShapedQueryExpression UpdateResultCardinality(ResultCardinality r /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { - Check.NotNull(expressionPrinter, nameof(expressionPrinter)); - expressionPrinter.AppendLine(nameof(ShapedQueryExpression) + ": "); using (expressionPrinter.Indent()) { diff --git a/src/EFCore/Query/TransparentIdentifierFactory.cs b/src/EFCore/Query/TransparentIdentifierFactory.cs index 4466e467e6b..609c13ec143 100644 --- a/src/EFCore/Query/TransparentIdentifierFactory.cs +++ b/src/EFCore/Query/TransparentIdentifierFactory.cs @@ -3,7 +3,6 @@ using System; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Query { @@ -31,12 +30,7 @@ public static class TransparentIdentifierFactory /// The inner type of the transparent identifier. /// The created transparent identifier type. public static Type Create(Type outerType, Type innerType) - { - Check.NotNull(outerType, nameof(outerType)); - Check.NotNull(innerType, nameof(innerType)); - - return typeof(TransparentIdentifier<,>).MakeGenericType(outerType, innerType); - } + => typeof(TransparentIdentifier<,>).MakeGenericType(outerType, innerType); private readonly struct TransparentIdentifier { diff --git a/src/EFCore/Storage/CoreTypeMapping.cs b/src/EFCore/Storage/CoreTypeMapping.cs index c24fe2e7dba..56a64ca938d 100644 --- a/src/EFCore/Storage/CoreTypeMapping.cs +++ b/src/EFCore/Storage/CoreTypeMapping.cs @@ -49,8 +49,6 @@ public CoreTypeMappingParameters( ValueComparer? keyComparer = null, Func? valueGeneratorFactory = null) { - Check.NotNull(clrType, nameof(clrType)); - ClrType = clrType; Converter = converter; Comparer = comparer; @@ -77,8 +75,6 @@ public CoreTypeMappingParameters( ValueComparer? structuralComparer, Func? valueGeneratorFactory) { - Check.NotNull(clrType, nameof(clrType)); - ClrType = clrType; Converter = converter; Comparer = comparer; diff --git a/src/EFCore/Storage/Database.cs b/src/EFCore/Storage/Database.cs index 9d05469e9f5..efc691cc606 100644 --- a/src/EFCore/Storage/Database.cs +++ b/src/EFCore/Storage/Database.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Update; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Storage @@ -42,8 +41,6 @@ public abstract class Database : IDatabase /// Parameter object containing dependencies for this service. protected Database(DatabaseDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Storage/DatabaseDependencies.cs b/src/EFCore/Storage/DatabaseDependencies.cs index 4723273fc75..201e2435265 100644 --- a/src/EFCore/Storage/DatabaseDependencies.cs +++ b/src/EFCore/Storage/DatabaseDependencies.cs @@ -4,7 +4,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Update; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Storage @@ -55,9 +54,6 @@ public DatabaseDependencies( IQueryCompilationContextFactory queryCompilationContextFactory, IUpdateAdapterFactory updateAdapterFactory) { - Check.NotNull(queryCompilationContextFactory, nameof(queryCompilationContextFactory)); - Check.NotNull(updateAdapterFactory, nameof(updateAdapterFactory)); - QueryCompilationContextFactory = queryCompilationContextFactory; UpdateAdapterFactory = updateAdapterFactory; } diff --git a/src/EFCore/Storage/DatabaseProvider.cs b/src/EFCore/Storage/DatabaseProvider.cs index 51a24f4bc90..db1013d4738 100644 --- a/src/EFCore/Storage/DatabaseProvider.cs +++ b/src/EFCore/Storage/DatabaseProvider.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Storage @@ -42,8 +41,6 @@ public class DatabaseProvider : IDatabaseProvider /// Parameter object containing dependencies for this service. public DatabaseProvider(DatabaseProviderDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -73,6 +70,6 @@ public virtual string? Version /// The options for the context. /// if the database provider has been selected, otherwise . public virtual bool IsConfigured(IDbContextOptions options) - => Check.NotNull(options, nameof(options)).Extensions.OfType().Any(); + => options.Extensions.OfType().Any(); } } diff --git a/src/EFCore/Storage/ExecutionStrategyDependencies.cs b/src/EFCore/Storage/ExecutionStrategyDependencies.cs index 94a2d2da68a..82521d33ca2 100644 --- a/src/EFCore/Storage/ExecutionStrategyDependencies.cs +++ b/src/EFCore/Storage/ExecutionStrategyDependencies.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Storage @@ -55,8 +54,6 @@ public ExecutionStrategyDependencies( IDbContextOptions options, IDiagnosticsLogger logger) { - Check.NotNull(currentContext, nameof(currentContext)); - Options = options; CurrentContext = currentContext; Logger = logger; diff --git a/src/EFCore/Storage/ExecutionStrategyExtensions.cs b/src/EFCore/Storage/ExecutionStrategyExtensions.cs index 32a973f94f3..8976c589ff7 100644 --- a/src/EFCore/Storage/ExecutionStrategyExtensions.cs +++ b/src/EFCore/Storage/ExecutionStrategyExtensions.cs @@ -392,7 +392,7 @@ public static TResult Execute( TState state, Func operation, Func>? verifySucceeded) - => Check.NotNull(strategy, nameof(strategy)).Execute( + => strategy.Execute( state, (c, s) => operation(s), verifySucceeded == null ? null : (c, s) => verifySucceeded(s)); @@ -431,7 +431,7 @@ public static Task ExecuteAsync( Func> operation, Func>>? verifySucceeded, CancellationToken cancellationToken = default) - => Check.NotNull(strategy, nameof(strategy)).ExecuteAsync( + => strategy.ExecuteAsync( state, (c, s, ct) => operation(s, ct), verifySucceeded == null diff --git a/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs b/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs index 100b871b487..42f77b4b03b 100644 --- a/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs +++ b/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.EntityFrameworkCore.Utilities; - namespace Microsoft.EntityFrameworkCore.Storage.Internal { /// @@ -21,8 +19,6 @@ public class ExecutionStrategyFactory : IExecutionStrategyFactory /// Parameter object containing dependencies for this service. public ExecutionStrategyFactory(ExecutionStrategyDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; _instance = new NonRetryingExecutionStrategy(Dependencies); } diff --git a/src/EFCore/Storage/TypeMappingInfo.cs b/src/EFCore/Storage/TypeMappingInfo.cs index a8031b19c8a..35421603f67 100644 --- a/src/EFCore/Storage/TypeMappingInfo.cs +++ b/src/EFCore/Storage/TypeMappingInfo.cs @@ -6,7 +6,6 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Storage { @@ -55,8 +54,6 @@ public TypeMappingInfo( int? fallbackPrecision = null, int? fallbackScale = null) { - Check.NotNull(principals, nameof(principals)); - ValueConverter? customConverter = null; int? size = null; int? precision = null; @@ -137,7 +134,7 @@ public TypeMappingInfo( int? size = null, int? precision = null, int? scale = null) - : this(Check.NotNull(member, nameof(member)).GetMemberType()) + : this(member.GetMemberType()) { IsUnicode = unicode; Size = size; @@ -191,8 +188,6 @@ public TypeMappingInfo( int? precision = null, int? scale = null) { - Check.NotNull(source, nameof(source)); - IsRowVersion = source.IsRowVersion; IsKeyOrIndex = source.IsKeyOrIndex; diff --git a/src/EFCore/Storage/TypeMappingSourceBase.cs b/src/EFCore/Storage/TypeMappingSourceBase.cs index cc33413205a..9c7d6ca2112 100644 --- a/src/EFCore/Storage/TypeMappingSourceBase.cs +++ b/src/EFCore/Storage/TypeMappingSourceBase.cs @@ -4,7 +4,6 @@ using System; using System.Reflection; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Storage @@ -38,8 +37,6 @@ public abstract class TypeMappingSourceBase : ITypeMappingSource /// Parameter object containing dependencies for this service. protected TypeMappingSourceBase(TypeMappingSourceDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } diff --git a/src/EFCore/Storage/TypeMappingSourceDependencies.cs b/src/EFCore/Storage/TypeMappingSourceDependencies.cs index f0d26b3e6aa..d8bd425fabe 100644 --- a/src/EFCore/Storage/TypeMappingSourceDependencies.cs +++ b/src/EFCore/Storage/TypeMappingSourceDependencies.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Storage @@ -55,9 +54,6 @@ public TypeMappingSourceDependencies( IValueConverterSelector valueConverterSelector, IEnumerable plugins) { - Check.NotNull(valueConverterSelector, nameof(valueConverterSelector)); - Check.NotNull(plugins, nameof(plugins)); - ValueConverterSelector = valueConverterSelector; Plugins = plugins; } diff --git a/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs b/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs index 1631edcd86a..8b1b412a3df 100644 --- a/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs +++ b/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs @@ -8,7 +8,6 @@ using System.Net; using System.Net.NetworkInformation; using System.Reflection; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Storage.ValueConversion @@ -69,8 +68,6 @@ public class ValueConverterSelector : IValueConverterSelector /// Parameter object containing dependencies for this service. public ValueConverterSelector(ValueConverterSelectorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -91,8 +88,6 @@ public virtual IEnumerable Select( Type modelClrType, Type? providerClrType = null) { - Check.NotNull(modelClrType, nameof(modelClrType)); - if (modelClrType.IsEnum) { foreach (var converterInfo in FindNumericConventions( diff --git a/src/EFCore/ValueGeneration/HiLoValueGenerator.cs b/src/EFCore/ValueGeneration/HiLoValueGenerator.cs index 61716fccb72..b9dee3dfae6 100644 --- a/src/EFCore/ValueGeneration/HiLoValueGenerator.cs +++ b/src/EFCore/ValueGeneration/HiLoValueGenerator.cs @@ -5,7 +5,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.ChangeTracking; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.ValueGeneration { @@ -33,8 +32,6 @@ public abstract class HiLoValueGenerator : ValueGenerator /// The state used to keep track of which value to return next. protected HiLoValueGenerator(HiLoValueGeneratorState generatorState) { - Check.NotNull(generatorState, nameof(generatorState)); - _generatorState = generatorState; } diff --git a/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs b/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs index 771a7231f92..dd773bc1c73 100644 --- a/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs +++ b/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs @@ -6,7 +6,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.ValueGeneration { @@ -50,8 +49,6 @@ public HiLoValueGeneratorState(int blockSize) /// The value to be assigned to a property. public virtual TValue Next(Func getNewLowValue) { - Check.NotNull(getNewLowValue, nameof(getNewLowValue)); - var newValue = GetNextValue(); // If the chosen value is outside of the current block then we need a new block. @@ -98,8 +95,6 @@ public virtual async ValueTask NextAsync( Func> getNewLowValue, CancellationToken cancellationToken = default) { - Check.NotNull(getNewLowValue, nameof(getNewLowValue)); - var newValue = GetNextValue(); // If the chosen value is outside of the current block then we need a new block. diff --git a/src/EFCore/ValueGeneration/ValueGeneratorCache.cs b/src/EFCore/ValueGeneration/ValueGeneratorCache.cs index cce60ed8383..ab9e12f686b 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorCache.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorCache.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Concurrent; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.ValueGeneration @@ -37,8 +36,6 @@ public class ValueGeneratorCache : IValueGeneratorCache /// Parameter object containing dependencies for this service. public ValueGeneratorCache(ValueGeneratorCacheDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -86,11 +83,6 @@ public virtual ValueGenerator GetOrAdd( IProperty property, IEntityType entityType, Func factory) - { - Check.NotNull(property, nameof(property)); - Check.NotNull(factory, nameof(factory)); - - return _cache.GetOrAdd(new CacheKey(property, entityType), static (ck, f) => f(ck.Property, ck.EntityType), factory); - } + => _cache.GetOrAdd(new CacheKey(property, entityType), static (ck, f) => f(ck.Property, ck.EntityType), factory); } } diff --git a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs index 5464e0a69d7..718edf61b66 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.ValueGeneration @@ -45,8 +44,6 @@ public virtual IValueGeneratorCache Cache /// Parameter object containing dependencies for this service. public ValueGeneratorSelector(ValueGeneratorSelectorDependencies dependencies) { - Check.NotNull(dependencies, nameof(dependencies)); - Dependencies = dependencies; } @@ -65,12 +62,7 @@ public ValueGeneratorSelector(ValueGeneratorSelectorDependencies dependencies) /// /// The value generator to be used. public virtual ValueGenerator Select(IProperty property, IEntityType entityType) - { - Check.NotNull(property, nameof(property)); - Check.NotNull(entityType, nameof(entityType)); - - return Cache.GetOrAdd(property, entityType, (p, t) => CreateFromFactory(p, t) ?? Create(p, t)); - } + => Cache.GetOrAdd(property, entityType, (p, t) => CreateFromFactory(p, t) ?? Create(p, t)); private static ValueGenerator? CreateFromFactory(IProperty property, IEntityType entityType) { @@ -116,9 +108,6 @@ public virtual ValueGenerator Select(IProperty property, IEntityType entityType) /// The newly created value generator. public virtual ValueGenerator Create(IProperty property, IEntityType entityType) { - Check.NotNull(property, nameof(property)); - Check.NotNull(entityType, nameof(entityType)); - var propertyType = property.ClrType.UnwrapNullableType().UnwrapEnumType(); if (propertyType == typeof(Guid)) diff --git a/src/EFCore/ValueGeneration/ValueGeneratorSelectorDependencies.cs b/src/EFCore/ValueGeneration/ValueGeneratorSelectorDependencies.cs index 58d1736f54b..8f0f7cf99b9 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorSelectorDependencies.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorSelectorDependencies.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.ValueGeneration @@ -51,8 +50,6 @@ public sealed record ValueGeneratorSelectorDependencies [EntityFrameworkInternal] public ValueGeneratorSelectorDependencies(IValueGeneratorCache cache) { - Check.NotNull(cache, nameof(cache)); - Cache = cache; } diff --git a/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs b/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs index 63bde3024e2..36fd4b186c7 100644 --- a/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs +++ b/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs @@ -346,82 +346,20 @@ public async Task Extension_methods_validate_arguments() { // ReSharper disable AssignNullToNotNullAttribute - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstAsync(null, s => true)); await ArgumentNullTest("predicate", () => Source().FirstAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(null, s => true)); await ArgumentNullTest("predicate", () => Source().FirstOrDefaultAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleAsync(null, s => true)); await ArgumentNullTest("predicate", () => Source().SingleAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync(null, s => true)); await ArgumentNullTest("predicate", () => Source().SingleOrDefaultAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.ContainsAsync(null, 1)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.ContainsAsync(null, 1, new CancellationToken())); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AnyAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AnyAsync(null, s => true)); await ArgumentNullTest("predicate", () => Source().AnyAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.AllAsync(null, s => true)); - await ArgumentNullTest( - "source", () => EntityFrameworkQueryableExtensions.AllAsync(null, s => true, new CancellationToken())); await ArgumentNullTest("predicate", () => Source().AllAsync(null)); await ArgumentNullTest("predicate", () => Source().AllAsync(null, new CancellationToken())); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.CountAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.CountAsync(null, s => true)); await ArgumentNullTest("predicate", () => Source().CountAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync(null, new CancellationToken())); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.LongCountAsync(null, s => true)); - await ArgumentNullTest( - "source", () => EntityFrameworkQueryableExtensions.LongCountAsync(null, s => true, new CancellationToken())); await ArgumentNullTest("predicate", () => Source().LongCountAsync(null)); await ArgumentNullTest("predicate", () => Source().LongCountAsync(null, new CancellationToken())); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync(null, new CancellationToken())); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MinAsync(null, s => true)); - await ArgumentNullTest( - "source", () => EntityFrameworkQueryableExtensions.MinAsync(null, s => true, new CancellationToken())); await ArgumentNullTest("selector", () => Source().MinAsync(null)); await ArgumentNullTest("selector", () => Source().MinAsync(null, new CancellationToken())); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync(null)); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync(null, new CancellationToken())); - await ArgumentNullTest("source", () => EntityFrameworkQueryableExtensions.MaxAsync(null, s => true)); - await ArgumentNullTest( - "source", () => EntityFrameworkQueryableExtensions.MaxAsync(null, s => true, new CancellationToken())); await ArgumentNullTest("selector", () => Source().MaxAsync(null)); await ArgumentNullTest("selector", () => Source().MaxAsync(null, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).SumAsync(i => 0, new CancellationToken())); await ArgumentNullTest("selector", () => Source().SumAsync(null)); await ArgumentNullTest("selector", () => Source().SumAsync(null)); await ArgumentNullTest("selector", () => Source().SumAsync(null)); @@ -432,46 +370,6 @@ await ArgumentNullTest( await ArgumentNullTest("selector", () => Source().SumAsync(null)); await ArgumentNullTest("selector", () => Source().SumAsync(null)); await ArgumentNullTest("selector", () => Source().SumAsync(null)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync()); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0)); - await ArgumentNullTest("source", () => ((IQueryable)null).AverageAsync(i => 0, new CancellationToken())); await ArgumentNullTest("selector", () => Source().AverageAsync(null)); await ArgumentNullTest("selector", () => Source().AverageAsync(null, new CancellationToken())); await ArgumentNullTest("selector", () => Source().AverageAsync(null));