diff --git a/src/EFCore/ChangeTracking/ChangeTracker.cs b/src/EFCore/ChangeTracking/ChangeTracker.cs index d650a9383f9..da8aa7835b4 100644 --- a/src/EFCore/ChangeTracking/ChangeTracker.cs +++ b/src/EFCore/ChangeTracking/ChangeTracker.cs @@ -196,10 +196,10 @@ private void TryDetectChanges() /// /// /// Note that this method calls unless - /// has been set to . + /// has been set to . /// /// - /// if there are changes to save, otherwise . + /// if there are changes to save, otherwise . public virtual bool HasChanges() { TryDetectChanges(); @@ -231,7 +231,8 @@ public virtual void DetectChanges() /// represent the current state of the database. This method is typically called by /// after changes have been successfully saved to the database. /// - public virtual void AcceptAllChanges() => StateManager.AcceptAllChanges(); + public virtual void AcceptAllChanges() + => StateManager.AcceptAllChanges(); /// /// @@ -402,7 +403,7 @@ Task IResettableService.ResetStateAsync(CancellationToken cancellationToken) /// Stops tracking all currently tracked entities. /// /// - /// is designed to have a short lifetime where a new instance is created for each unit-of-work. + /// is designed to have a short lifetime where a new instance is created for each unit-of-work. /// This manner means all tracked entities are discarded when the context is disposed at the end of each unit-of-work. /// However, clearing all tracked entities using this method may be useful in situations where creating a new context /// instance is not practical. @@ -413,7 +414,7 @@ Task IResettableService.ResetStateAsync(CancellationToken cancellationToken) /// This method is much more efficient at clearing all tracked entities from the context. /// /// - /// Note that this method does not generate events since entities are not individually detached. + /// Note that this method does not generate events since entities are not individually detached. /// /// public virtual void Clear() @@ -440,22 +441,25 @@ public virtual DebugView DebugView /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs b/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs index 8d27c457aea..87db70ecb50 100644 --- a/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs +++ b/src/EFCore/ChangeTracking/ChangeTrackerExtensions.cs @@ -51,7 +51,7 @@ public static string ToDebugString( private sealed class EntityEntryComparer : IComparer { - public static EntityEntryComparer Instance = new EntityEntryComparer(); + public static readonly EntityEntryComparer Instance = new EntityEntryComparer(); public int Compare(InternalEntityEntry x, InternalEntityEntry y) { @@ -79,6 +79,5 @@ public int Compare(InternalEntityEntry x, InternalEntityEntry y) return 0; } } - } } diff --git a/src/EFCore/ChangeTracking/CollectionEntry`.cs b/src/EFCore/ChangeTracking/CollectionEntry`.cs index cac937c6ec0..3e3842970c2 100644 --- a/src/EFCore/ChangeTracking/CollectionEntry`.cs +++ b/src/EFCore/ChangeTracking/CollectionEntry`.cs @@ -54,7 +54,8 @@ public CollectionEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] IN /// The to which this member belongs. /// /// An entry for the entity that owns this member. - public new virtual EntityEntry EntityEntry => new EntityEntry(InternalEntry); + public new virtual EntityEntry EntityEntry + => new EntityEntry(InternalEntry); /// /// Gets or sets the value currently assigned to this property. If the current value is set using this property, diff --git a/src/EFCore/ChangeTracking/EntityEntry.cs b/src/EFCore/ChangeTracking/EntityEntry.cs index 7c975caa4e2..5e932a4cebf 100644 --- a/src/EFCore/ChangeTracking/EntityEntry.cs +++ b/src/EFCore/ChangeTracking/EntityEntry.cs @@ -61,7 +61,8 @@ public EntityEntry([NotNull] InternalEntityEntry internalEntry) /// /// Gets the entity being tracked by this entry. /// - public virtual object Entity => InternalEntry.Entity; + public virtual object Entity + => InternalEntry.Entity; /// /// @@ -114,17 +115,20 @@ public virtual void DetectChanges() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - InternalEntityEntry IInfrastructure.Instance => InternalEntry; + InternalEntityEntry IInfrastructure.Instance + => InternalEntry; /// /// Gets the context that is tracking the entity. /// - public virtual DbContext Context => InternalEntry.StateManager.Context; + public virtual DbContext Context + => InternalEntry.StateManager.Context; /// /// Gets the metadata about the shape of the entity, its relationships to other entities, and how it maps to the database. /// - public virtual IEntityType Metadata => InternalEntry.EntityType; + public virtual IEntityType Metadata + => InternalEntry.EntityType; /// /// Provides access to change tracking information and operations for a given @@ -286,7 +290,8 @@ public virtual IEnumerable Collections /// true since any value is considered a valid key value. /// /// - public virtual bool IsKeySet => InternalEntry.IsKeySet.IsSet; + public virtual bool IsKeySet + => InternalEntry.IsKeySet.IsSet; /// /// Gets the current property values for this entity. @@ -372,7 +377,8 @@ public virtual async Task GetDatabaseValuesAsync(CancellationTok /// not yet have had its permanent key value created. /// /// - public virtual void Reload() => Reload(GetDatabaseValues()); + public virtual void Reload() + => Reload(GetDatabaseValues()); /// /// @@ -420,7 +426,8 @@ private IEntityFinder Finder /// Returns a string that represents the current object. /// /// A string that represents the current object. - public override string ToString() => InternalEntry.ToString(); + public override string ToString() + => InternalEntry.ToString(); /// /// @@ -442,16 +449,18 @@ public virtual DebugView DebugView /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/ChangeTracking/EntityEntryEventArgs.cs b/src/EFCore/ChangeTracking/EntityEntryEventArgs.cs index 4233f723395..59eb18e443e 100644 --- a/src/EFCore/ChangeTracking/EntityEntryEventArgs.cs +++ b/src/EFCore/ChangeTracking/EntityEntryEventArgs.cs @@ -32,6 +32,7 @@ public EntityEntryEventArgs( /// /// The for the entity. /// - public virtual EntityEntry Entry => _entry ??= new EntityEntry(_internalEntityEntry); + public virtual EntityEntry Entry + => _entry ??= new EntityEntry(_internalEntityEntry); } } diff --git a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs index eee90782d44..5057ae49b95 100644 --- a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs +++ b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs @@ -42,7 +42,8 @@ public EntityEntryGraphNode( /// /// Gets the entry tracking information about this entity. /// - public virtual EntityEntry SourceEntry => _sourceEntry == null ? null : new EntityEntry(_sourceEntry); + public virtual EntityEntry SourceEntry + => _sourceEntry == null ? null : new EntityEntry(_sourceEntry); /// /// Gets the navigation property that is being traversed to reach this node in the graph. @@ -52,7 +53,8 @@ public EntityEntryGraphNode( /// /// Gets the entry tracking information about this entity. /// - public virtual EntityEntry Entry => new EntityEntry(_entry); + public virtual EntityEntry Entry + => new EntityEntry(_entry); /// /// @@ -63,7 +65,8 @@ public EntityEntryGraphNode( /// application code. /// /// - InternalEntityEntry IInfrastructure.Instance => _entry; + InternalEntityEntry IInfrastructure.Instance + => _entry; /// /// Creates a new node for the entity that is being traversed next in the graph. diff --git a/src/EFCore/ChangeTracking/EntityEntry`.cs b/src/EFCore/ChangeTracking/EntityEntry`.cs index 050e3a09b72..9d604c845ff 100644 --- a/src/EFCore/ChangeTracking/EntityEntry`.cs +++ b/src/EFCore/ChangeTracking/EntityEntry`.cs @@ -42,7 +42,8 @@ public EntityEntry([NotNull] InternalEntityEntry internalEntry) /// /// Gets the entity being tracked by this entry. /// - public new virtual TEntity Entity => (TEntity)base.Entity; + public new virtual TEntity Entity + => (TEntity)base.Entity; /// /// Provides access to change tracking information and operations for a given diff --git a/src/EFCore/ChangeTracking/EntryCurrentValueComparer`.cs b/src/EFCore/ChangeTracking/EntryCurrentValueComparer`.cs index 0392df1a60c..b4c94b1f6fb 100644 --- a/src/EFCore/ChangeTracking/EntryCurrentValueComparer`.cs +++ b/src/EFCore/ChangeTracking/EntryCurrentValueComparer`.cs @@ -51,7 +51,7 @@ public int Compare(IUpdateEntry x, IUpdateEntry y) /// /// The first object to compare. /// The second object to compare. - /// if the specified objects are equal; otherwise, . + /// if the specified objects are equal; otherwise, . public bool Equals(IUpdateEntry x, IUpdateEntry y) => Compare(x, y) == 0; diff --git a/src/EFCore/ChangeTracking/IDependentKeyValueFactory.cs b/src/EFCore/ChangeTracking/IDependentKeyValueFactory.cs index fe2e4a30154..9dbba4a6398 100644 --- a/src/EFCore/ChangeTracking/IDependentKeyValueFactory.cs +++ b/src/EFCore/ChangeTracking/IDependentKeyValueFactory.cs @@ -25,7 +25,7 @@ public interface IDependentKeyValueFactory /// /// The value buffer representing the entity instance. /// The key instance. - /// if the key instance was created; otherwise. + /// if the key instance was created; otherwise. [ContractAnnotation("=>true, key:notnull; =>false, key:null")] bool TryCreateFromBuffer(in ValueBuffer valueBuffer, out TKey key); @@ -34,7 +34,7 @@ public interface IDependentKeyValueFactory /// /// The entry tracking an entity instance. /// The key instance. - /// if the key instance was created; otherwise. + /// if the key instance was created; otherwise. [ContractAnnotation("=>true, key:notnull; =>false, key:null")] bool TryCreateFromCurrentValues([NotNull] IUpdateEntry entry, out TKey key); @@ -44,7 +44,7 @@ public interface IDependentKeyValueFactory /// /// The entry tracking an entity instance. /// The key instance. - /// if the key instance was created; otherwise. + /// if the key instance was created; otherwise. [ContractAnnotation("=>true, key:notnull; =>false, key:null")] bool TryCreateFromPreStoreGeneratedCurrentValues([NotNull] IUpdateEntry entry, out TKey key); @@ -53,7 +53,7 @@ public interface IDependentKeyValueFactory /// /// The entry tracking an entity instance. /// The key instance. - /// if the key instance was created; otherwise. + /// if the key instance was created; otherwise. [ContractAnnotation("=>true, key:notnull; =>false, key:null")] bool TryCreateFromOriginalValues([NotNull] IUpdateEntry entry, out TKey key); @@ -63,7 +63,7 @@ public interface IDependentKeyValueFactory /// /// The entry tracking an entity instance. /// The key instance. - /// if the key instance was created; otherwise. + /// if the key instance was created; otherwise. [ContractAnnotation("=>true, key:notnull; =>false, key:null")] bool TryCreateFromRelationshipSnapshot([NotNull] IUpdateEntry entry, out TKey key); diff --git a/src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs b/src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs index b0cd3685fb8..3a15368e0d9 100644 --- a/src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs +++ b/src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs @@ -7,7 +7,6 @@ using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Query; @@ -34,7 +33,8 @@ public class ArrayPropertyValues : PropertyValues /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public ArrayPropertyValues([NotNull] InternalEntityEntry internalEntry, [NotNull] object[] values) - : base(internalEntry) => _values = values; + : base(internalEntry) + => _values = values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/Internal/ChangeDetector.cs b/src/EFCore/ChangeTracking/Internal/ChangeDetector.cs index 84508474c90..f1968310e7e 100644 --- a/src/EFCore/ChangeTracking/Internal/ChangeDetector.cs +++ b/src/EFCore/ChangeTracking/Internal/ChangeDetector.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -55,7 +54,8 @@ public ChangeDetector( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual void Suspend() => _suspended = true; + public virtual void Suspend() + => _suspended = true; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -63,7 +63,8 @@ public ChangeDetector( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual void Resume() => _suspended = false; + public virtual void Resume() + => _suspended = false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/Internal/CurrentValueComparerFactory.cs b/src/EFCore/ChangeTracking/Internal/CurrentValueComparerFactory.cs index 0596ec37e45..5225104e2d2 100644 --- a/src/EFCore/ChangeTracking/Internal/CurrentValueComparerFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/CurrentValueComparerFactory.cs @@ -81,7 +81,7 @@ public virtual IComparer Create([NotNull] IPropertyBase propertyBa propertyBase.DeclaringType.DisplayName(), propertyBase.Name, modelType.ShortDisplayName(), - providerType.ShortDisplayName() )); + providerType.ShortDisplayName())); } } diff --git a/src/EFCore/ChangeTracking/Internal/EmptyShadowValuesFactoryFactory.cs b/src/EFCore/ChangeTracking/Internal/EmptyShadowValuesFactoryFactory.cs index ac63a6131f0..f2161dbcbbf 100644 --- a/src/EFCore/ChangeTracking/Internal/EmptyShadowValuesFactoryFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/EmptyShadowValuesFactoryFactory.cs @@ -48,7 +48,8 @@ protected override ValueComparer GetValueComparer(IProperty property) /// 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. /// - protected override bool UseEntityVariable => false; + protected override bool UseEntityVariable + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/Internal/EntityEntryGraphIterator.cs b/src/EFCore/ChangeTracking/Internal/EntityEntryGraphIterator.cs index b723165e6b1..fd2773b413f 100644 --- a/src/EFCore/ChangeTracking/Internal/EntityEntryGraphIterator.cs +++ b/src/EFCore/ChangeTracking/Internal/EntityEntryGraphIterator.cs @@ -109,9 +109,9 @@ public virtual async Task TraverseGraphAsync( { var targetEntry = stateManager.GetOrCreateEntry(relatedEntity, targetType); await TraverseGraphAsync( - (EntityEntryGraphNode)node.CreateNode(node, targetEntry, navigation), - handleNode, - cancellationToken) + (EntityEntryGraphNode)node.CreateNode(node, targetEntry, navigation), + handleNode, + cancellationToken) .ConfigureAwait(false); } } @@ -119,9 +119,9 @@ await TraverseGraphAsync( { var targetEntry = stateManager.GetOrCreateEntry(navigationValue, targetType); await TraverseGraphAsync( - (EntityEntryGraphNode)node.CreateNode(node, targetEntry, navigation), - handleNode, - cancellationToken) + (EntityEntryGraphNode)node.CreateNode(node, targetEntry, navigation), + handleNode, + cancellationToken) .ConfigureAwait(false); } } diff --git a/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs b/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs index d0a405a4451..d7d5d9b16d1 100644 --- a/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs +++ b/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs @@ -34,7 +34,8 @@ public class EntityGraphAttacher : IEntityGraphAttacher /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public EntityGraphAttacher( - [NotNull] IEntityEntryGraphIterator graphIterator) => _graphIterator = graphIterator; + [NotNull] IEntityEntryGraphIterator graphIterator) + => _graphIterator = graphIterator; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs b/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs index 836774ecf4d..c03bbe187e8 100644 --- a/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs +++ b/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs @@ -85,7 +85,8 @@ public virtual void Update( _detachedReferenceMap[mapKey] = entry; break; case EntityState.Unchanged: - _unchangedReferenceMap ??= new Dictionary(LegacyReferenceEqualityComparer.Instance); + _unchangedReferenceMap ??= + new Dictionary(LegacyReferenceEqualityComparer.Instance); _unchangedReferenceMap[mapKey] = entry; break; case EntityState.Deleted: diff --git a/src/EFCore/ChangeTracking/Internal/IIdentityMap.cs b/src/EFCore/ChangeTracking/Internal/IIdentityMap.cs index 3da18511ef6..bf3a7862e6f 100644 --- a/src/EFCore/ChangeTracking/Internal/IIdentityMap.cs +++ b/src/EFCore/ChangeTracking/Internal/IIdentityMap.cs @@ -70,7 +70,8 @@ public interface IIdentityMap /// doing so can result in application failures when updating to a new Entity Framework Core release. /// InternalEntityEntry TryGetEntryUsingPreStoreGeneratedValues( - [NotNull] IForeignKey foreignKey, [NotNull] InternalEntityEntry dependentEntry); + [NotNull] IForeignKey foreignKey, + [NotNull] InternalEntityEntry dependentEntry); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -79,7 +80,8 @@ InternalEntityEntry TryGetEntryUsingPreStoreGeneratedValues( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// InternalEntityEntry TryGetEntryUsingRelationshipSnapshot( - [NotNull] IForeignKey foreignKey, [NotNull] InternalEntityEntry dependentEntry); + [NotNull] IForeignKey foreignKey, + [NotNull] InternalEntityEntry dependentEntry); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/Internal/IStateManager.cs b/src/EFCore/ChangeTracking/Internal/IStateManager.cs index e785ad20f1d..01f61126867 100644 --- a/src/EFCore/ChangeTracking/Internal/IStateManager.cs +++ b/src/EFCore/ChangeTracking/Internal/IStateManager.cs @@ -260,7 +260,9 @@ IEnumerable GetNonDeletedEntities() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// void RecordReferencedUntrackedEntity( - [NotNull] object referencedEntity, [NotNull] INavigationBase navigation, [NotNull] InternalEntityEntry referencedFromEntry); + [NotNull] object referencedEntity, + [NotNull] INavigationBase navigation, + [NotNull] InternalEntityEntry referencedFromEntry); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -285,7 +287,8 @@ void RecordReferencedUntrackedEntity( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// InternalEntityEntry FindPrincipalUsingPreStoreGeneratedValues( - [NotNull] InternalEntityEntry dependentEntry, [NotNull] IForeignKey foreignKey); + [NotNull] InternalEntityEntry dependentEntry, + [NotNull] IForeignKey foreignKey); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -294,7 +297,8 @@ InternalEntityEntry FindPrincipalUsingPreStoreGeneratedValues( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// InternalEntityEntry FindPrincipalUsingRelationshipSnapshot( - [NotNull] InternalEntityEntry dependentEntry, [NotNull] IForeignKey foreignKey); + [NotNull] InternalEntityEntry dependentEntry, + [NotNull] IForeignKey foreignKey); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -319,7 +323,8 @@ InternalEntityEntry FindPrincipalUsingRelationshipSnapshot( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IEnumerable GetDependentsFromNavigation( - [NotNull] IUpdateEntry principalEntry, [NotNull] IForeignKey foreignKey); + [NotNull] IUpdateEntry principalEntry, + [NotNull] IForeignKey foreignKey); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -336,7 +341,8 @@ IEnumerable GetDependentsFromNavigation( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IEnumerable GetDependentsUsingRelationshipSnapshot( - [NotNull] IUpdateEntry principalEntry, [NotNull] IForeignKey foreignKey); + [NotNull] IUpdateEntry principalEntry, + [NotNull] IForeignKey foreignKey); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/Internal/IdentityMap.cs b/src/EFCore/ChangeTracking/Internal/IdentityMap.cs index 94f4f1b233c..ff260eb0677 100644 --- a/src/EFCore/ChangeTracking/Internal/IdentityMap.cs +++ b/src/EFCore/ChangeTracking/Internal/IdentityMap.cs @@ -175,7 +175,8 @@ public virtual InternalEntityEntry TryGetEntry(IForeignKey foreignKey, InternalE /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityEntry TryGetEntryUsingPreStoreGeneratedValues( - IForeignKey foreignKey, InternalEntityEntry dependentEntry) + IForeignKey foreignKey, + InternalEntityEntry dependentEntry) => foreignKey.GetDependentKeyValueFactory().TryCreateFromPreStoreGeneratedCurrentValues(dependentEntry, out var key) && _identityMap.TryGetValue(key, out var entry) ? entry diff --git a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs index dccb6f7ad2d..f32feffaf9f 100644 --- a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs +++ b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs @@ -167,7 +167,10 @@ await StateManager.ValueGenerationManager.GenerateAsync(this, cancellationToken) } private EntityState PropagateToUnknownKey( - EntityState oldState, EntityState entityState, bool adding, EntityState? forceStateWhenUnknownKey) + EntityState oldState, + EntityState entityState, + bool adding, + EntityState? forceStateWhenUnknownKey) { var keyUnknown = IsKeyUnknown; @@ -401,7 +404,8 @@ public virtual void MarkUnchangedFromQuery() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual EntityState EntityState => _stateData.EntityState; + public virtual EntityState EntityState + => _stateData.EntityState; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -666,7 +670,8 @@ internal static readonly MethodInfo ReadShadowValueMethod /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [UsedImplicitly] - protected virtual T ReadShadowValue(int shadowIndex) => default; + protected virtual T ReadShadowValue(int shadowIndex) + => default; internal static readonly MethodInfo ReadOriginalValueMethod = typeof(InternalEntityEntry).GetTypeInfo().GetDeclaredMethod(nameof(ReadOriginalValue)); @@ -878,7 +883,9 @@ public virtual object GetRelationshipSnapshotValue(IPropertyBase propertyBase) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual void SetOriginalValue( - [NotNull] IPropertyBase propertyBase, [CanBeNull] object value, int index = -1) + [NotNull] IPropertyBase propertyBase, + [CanBeNull] object value, + int index = -1) { EnsureOriginalValues(); @@ -976,7 +983,8 @@ public virtual void EnsureRelationshipSnapshot() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual bool HasOriginalValuesSnapshot => !_originalValues.IsEmpty; + public virtual bool HasOriginalValuesSnapshot + => !_originalValues.IsEmpty; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -984,7 +992,8 @@ public virtual void EnsureRelationshipSnapshot() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual bool HasRelationshipSnapshot => !_relationshipsSnapshot.IsEmpty; + public virtual bool HasRelationshipSnapshot + => !_relationshipsSnapshot.IsEmpty; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1032,7 +1041,7 @@ public virtual void AddRangeToCollectionSnapshot( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public object this[[NotNull] IPropertyBase propertyBase] // Intentionally non-virtual + public object this[[NotNull] IPropertyBase propertyBase] // Intentionally non-virtual { get { @@ -1580,7 +1589,8 @@ public virtual bool IsKeyUnknown /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual EntityEntry ToEntityEntry() => new EntityEntry(this); + public virtual EntityEntry ToEntityEntry() + => new EntityEntry(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1714,7 +1724,8 @@ public virtual DebugView DebugView () => this.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault), () => this.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault)); - IUpdateEntry IUpdateEntry.SharedIdentityEntry => SharedIdentityEntry; + IUpdateEntry IUpdateEntry.SharedIdentityEntry + => SharedIdentityEntry; private enum CurrentValueType { diff --git a/src/EFCore/ChangeTracking/Internal/InternalEntityEntryFactory.cs b/src/EFCore/ChangeTracking/Internal/InternalEntityEntryFactory.cs index 9c2ea3287c4..8a61aa9c1d5 100644 --- a/src/EFCore/ChangeTracking/Internal/InternalEntityEntryFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/InternalEntityEntryFactory.cs @@ -40,7 +40,10 @@ public virtual InternalEntityEntry Create(IStateManager stateManager, IEntityTyp /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityEntry Create( - IStateManager stateManager, IEntityType entityType, object entity, in ValueBuffer valueBuffer) + IStateManager stateManager, + IEntityType entityType, + object entity, + in ValueBuffer valueBuffer) => NewInternalEntityEntry(stateManager, entityType, entity, valueBuffer); private static InternalEntityEntry NewInternalEntityEntry(IStateManager stateManager, IEntityType entityType, object entity) diff --git a/src/EFCore/ChangeTracking/Internal/InternalShadowEntityEntry.cs b/src/EFCore/ChangeTracking/Internal/InternalShadowEntityEntry.cs index 6643f668051..1abedb85ddf 100644 --- a/src/EFCore/ChangeTracking/Internal/InternalShadowEntityEntry.cs +++ b/src/EFCore/ChangeTracking/Internal/InternalShadowEntityEntry.cs @@ -26,7 +26,8 @@ public class InternalShadowEntityEntry : InternalEntityEntry /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override object Entity => null; + public override object Entity + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs b/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs index 48f62f1c39a..47d28511092 100644 --- a/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs +++ b/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs @@ -54,7 +54,10 @@ public NavigationFixer( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual void NavigationReferenceChanged( - InternalEntityEntry entry, INavigationBase navigationBase, object oldValue, object newValue) + InternalEntityEntry entry, + INavigationBase navigationBase, + object oldValue, + object newValue) { if (_inFixup) { @@ -97,7 +100,8 @@ public virtual void NavigationReferenceChanged( // null out its FKs and navigation property. A.k.a. reference stealing. // However, if the FK has already been changed or the reference is already set to point // to something else, then don't change it. - var victimDependentEntry = (InternalEntityEntry)stateManager.GetDependents(newTargetEntry, foreignKey).FirstOrDefault(); + var victimDependentEntry = + (InternalEntityEntry)stateManager.GetDependents(newTargetEntry, foreignKey).FirstOrDefault(); if (victimDependentEntry != null && victimDependentEntry != entry) { @@ -412,7 +416,8 @@ public virtual void KeyPropertyChanged( // However, if the FK has already been changed or the reference is already set to point // to something else, then don't change it. var targetDependentEntry - = (InternalEntityEntry)stateManager.GetDependentsUsingRelationshipSnapshot(newPrincipalEntry, foreignKey).FirstOrDefault(); + = (InternalEntityEntry)stateManager + .GetDependentsUsingRelationshipSnapshot(newPrincipalEntry, foreignKey).FirstOrDefault(); if (targetDependentEntry != null && targetDependentEntry != entry) @@ -875,7 +880,10 @@ private void InitialFixup( } private void DelayedFixup( - InternalEntityEntry entry, INavigationBase navigationBase, InternalEntityEntry referencedEntry, bool fromQuery) + InternalEntityEntry entry, + INavigationBase navigationBase, + InternalEntityEntry referencedEntry, + bool fromQuery) { var navigationValue = entry[navigationBase]; @@ -929,8 +937,11 @@ private void DelayedFixup( } private static InternalEntityEntry FindOrCreateJoinEntry( - InternalEntityEntry entry, InternalEntityEntry otherEntry, ISkipNavigation skipNavigation, - bool fromQuery, bool setModified) + InternalEntityEntry entry, + InternalEntityEntry otherEntry, + ISkipNavigation skipNavigation, + bool fromQuery, + bool setModified) { var joinEntry = FindJoinEntry(entry, otherEntry, skipNavigation); @@ -1030,11 +1041,13 @@ bool TryFind( var key = joinEntityType.FindKey(new[] { firstForeignKey.Properties[0], secondForeignKey.Properties[0] }); if (key != null) { - joinEntry = entry.StateManager.TryGetEntry(key, new[] - { - firstEntry[firstForeignKey.PrincipalKey.Properties[0]], - secondEntry[secondForeignKey.PrincipalKey.Properties[0]] - }); + joinEntry = entry.StateManager.TryGetEntry( + key, + new[] + { + firstEntry[firstForeignKey.PrincipalKey.Properties[0]], + secondEntry[secondForeignKey.PrincipalKey.Properties[0]] + }); return true; } @@ -1114,7 +1127,8 @@ private void ToDependentFixup( var oldDependentEntry = oldDependent != null && !ReferenceEquals(dependentEntry.Entity, oldDependent) ? dependentEntry.StateManager.TryGetEntry(oldDependent, foreignKey.DeclaringEntityType) - : (InternalEntityEntry)dependentEntry.StateManager.GetDependentsUsingRelationshipSnapshot(principalEntry, foreignKey) + : (InternalEntityEntry)dependentEntry.StateManager + .GetDependentsUsingRelationshipSnapshot(principalEntry, foreignKey) .FirstOrDefault(); if (oldDependentEntry != null diff --git a/src/EFCore/ChangeTracking/Internal/OriginalValues.cs b/src/EFCore/ChangeTracking/Internal/OriginalValues.cs index c07b4b789b1..e467209b2b9 100644 --- a/src/EFCore/ChangeTracking/Internal/OriginalValues.cs +++ b/src/EFCore/ChangeTracking/Internal/OriginalValues.cs @@ -3,7 +3,6 @@ using System; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Utilities; @@ -111,7 +110,8 @@ private static object SnapshotValue(IProperty property, object value) return comparer == null ? value : comparer.Snapshot(value); } - public bool IsEmpty => _values == null; + public bool IsEmpty + => _values == null; } } } diff --git a/src/EFCore/ChangeTracking/Internal/RelationshipsSnapshot.cs b/src/EFCore/ChangeTracking/Internal/RelationshipsSnapshot.cs index 2ffb92b7fc6..75e5239bd8c 100644 --- a/src/EFCore/ChangeTracking/Internal/RelationshipsSnapshot.cs +++ b/src/EFCore/ChangeTracking/Internal/RelationshipsSnapshot.cs @@ -108,7 +108,8 @@ private HashSet GetOrCreateCollection(int index) return snapshot; } - public bool IsEmpty => _values == null; + public bool IsEmpty + => _values == null; } } } diff --git a/src/EFCore/ChangeTracking/Internal/ShadowValuesFactoryFactory.cs b/src/EFCore/ChangeTracking/Internal/ShadowValuesFactoryFactory.cs index be1621aa3ee..b6547e1f71a 100644 --- a/src/EFCore/ChangeTracking/Internal/ShadowValuesFactoryFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/ShadowValuesFactoryFactory.cs @@ -50,7 +50,8 @@ protected override ValueComparer GetValueComparer(IProperty property) /// 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. /// - protected override bool UseEntityVariable => false; + protected override bool UseEntityVariable + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -59,7 +60,8 @@ protected override ValueComparer GetValueComparer(IProperty property) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression CreateReadShadowValueExpression( - ParameterExpression parameter, IPropertyBase property) + ParameterExpression parameter, + IPropertyBase property) => Expression.Convert( Expression.Call( parameter, @@ -74,7 +76,8 @@ protected override Expression CreateReadShadowValueExpression( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression CreateReadValueExpression( - ParameterExpression parameter, IPropertyBase property) + ParameterExpression parameter, + IPropertyBase property) => CreateReadShadowValueExpression(parameter, property); } } diff --git a/src/EFCore/ChangeTracking/Internal/SidecarValues.cs b/src/EFCore/ChangeTracking/Internal/SidecarValues.cs index a06ed108bfe..c4cc484490e 100644 --- a/src/EFCore/ChangeTracking/Internal/SidecarValues.cs +++ b/src/EFCore/ChangeTracking/Internal/SidecarValues.cs @@ -3,7 +3,6 @@ using System; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Utilities; @@ -57,7 +56,8 @@ private static object SnapshotValue(IProperty property, object value) return comparer == null ? value : comparer.Snapshot(value); } - public bool IsEmpty => _values == null; + public bool IsEmpty + => _values == null; } } } diff --git a/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs b/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs index e11a5cfe567..f01edd4f1c6 100644 --- a/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs @@ -120,8 +120,11 @@ private sealed class NoNullsStructuralEqualityComparer : IEqualityComparer private readonly IEqualityComparer _comparer = StructuralComparisons.StructuralEqualityComparer; - public bool Equals(TKey x, TKey y) => _comparer.Equals(x, y); - public int GetHashCode(TKey obj) => _comparer.GetHashCode(obj); + public bool Equals(TKey x, TKey y) + => _comparer.Equals(x, y); + + public int GetHashCode(TKey obj) + => _comparer.GetHashCode(obj); } private sealed class NoNullsCustomEqualityComparer : IEqualityComparer @@ -141,9 +144,11 @@ public NoNullsCustomEqualityComparer(ValueComparer comparer) _hashCode = (Func)comparer.HashCodeExpression.Compile(); } - public bool Equals(TKey x, TKey y) => _equals(x, y); + public bool Equals(TKey x, TKey y) + => _equals(x, y); - public int GetHashCode(TKey obj) => _hashCode(obj); + public int GetHashCode(TKey obj) + => _hashCode(obj); } } } diff --git a/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs b/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs index 51aef52a1e7..ceff009bb1f 100644 --- a/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs @@ -218,7 +218,8 @@ private Expression CreateSnapshotValueExpression(Expression expression, IPropert /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual Expression CreateReadShadowValueExpression( - [CanBeNull] ParameterExpression parameter, [NotNull] IPropertyBase property) + [CanBeNull] ParameterExpression parameter, + [NotNull] IPropertyBase property) => Expression.Call( parameter, InternalEntityEntry.ReadShadowValueMethod.MakeGenericMethod(property.ClrType), @@ -231,7 +232,8 @@ protected virtual Expression CreateReadShadowValueExpression( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual Expression CreateReadValueExpression( - [CanBeNull] ParameterExpression parameter, [NotNull] IPropertyBase property) + [CanBeNull] ParameterExpression parameter, + [NotNull] IPropertyBase property) => Expression.Call( parameter, InternalEntityEntry.GetCurrentValueMethod.MakeGenericMethod(property.ClrType), @@ -259,7 +261,8 @@ protected virtual Expression CreateReadValueExpression( /// 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. /// - protected virtual bool UseEntityVariable => true; + protected virtual bool UseEntityVariable + => true; private static readonly MethodInfo _snapshotCollectionMethod = typeof(SnapshotFactoryFactory).GetTypeInfo().GetDeclaredMethod(nameof(SnapshotCollection)); diff --git a/src/EFCore/ChangeTracking/Internal/StateManager.cs b/src/EFCore/ChangeTracking/Internal/StateManager.cs index 6f2d2ec4a1f..acdb22abb42 100644 --- a/src/EFCore/ChangeTracking/Internal/StateManager.cs +++ b/src/EFCore/ChangeTracking/Internal/StateManager.cs @@ -174,7 +174,8 @@ public virtual void StateChanging(InternalEntityEntry entry, EntityState newStat /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IModel Model => _model; + public virtual IModel Model + => _model; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -704,7 +705,9 @@ public virtual Task ResetStateAsync(CancellationToken cancellationToken = defaul /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual void RecordReferencedUntrackedEntity( - object referencedEntity, INavigationBase navigation, InternalEntityEntry referencedFromEntry) + object referencedEntity, + INavigationBase navigation, + InternalEntityEntry referencedFromEntry) { if (_referencedUntrackedEntities == null) { @@ -764,7 +767,8 @@ public virtual InternalEntityEntry FindPrincipal( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityEntry FindPrincipalUsingPreStoreGeneratedValues( - InternalEntityEntry dependentEntry, IForeignKey foreignKey) + InternalEntityEntry dependentEntry, + IForeignKey foreignKey) => FilterIncompatiblePrincipal( foreignKey, FindIdentityMap(foreignKey.PrincipalKey) @@ -777,7 +781,8 @@ public virtual InternalEntityEntry FindPrincipalUsingPreStoreGeneratedValues( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityEntry FindPrincipalUsingRelationshipSnapshot( - InternalEntityEntry dependentEntry, IForeignKey foreignKey) + InternalEntityEntry dependentEntry, + IForeignKey foreignKey) => FilterIncompatiblePrincipal( foreignKey, FindIdentityMap(foreignKey.PrincipalKey) @@ -839,7 +844,8 @@ public virtual void UpdateDependentMap(InternalEntityEntry entry, IForeignKey fo /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IEnumerable GetDependents( - IUpdateEntry principalEntry, IForeignKey foreignKey) + IUpdateEntry principalEntry, + IForeignKey foreignKey) { var dependentIdentityMap = FindIdentityMap(foreignKey.DeclaringEntityType.FindPrimaryKey()); return dependentIdentityMap != null && foreignKey.PrincipalEntityType.IsAssignableFrom(principalEntry.EntityType) @@ -854,7 +860,8 @@ public virtual IEnumerable GetDependents( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IEnumerable GetDependentsUsingRelationshipSnapshot( - IUpdateEntry principalEntry, IForeignKey foreignKey) + IUpdateEntry principalEntry, + IForeignKey foreignKey) { var dependentIdentityMap = FindIdentityMap(foreignKey.DeclaringEntityType.FindPrimaryKey()); return dependentIdentityMap != null @@ -869,7 +876,8 @@ public virtual IEnumerable GetDependentsUsingRelationshipSnapshot( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IEnumerable GetDependentsFromNavigation( - IUpdateEntry principalEntry, IForeignKey foreignKey) + IUpdateEntry principalEntry, + IForeignKey foreignKey) { var navigation = foreignKey.PrincipalToDependent; if (navigation == null @@ -1164,13 +1172,17 @@ private int SaveChanges(DbContext _, bool acceptAllChangesOnSuccess) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual Task SaveChangesAsync( - bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default) + bool acceptAllChangesOnSuccess, + CancellationToken cancellationToken = default) => Context.Database.AutoTransactionsEnabled - ? Dependencies.ExecutionStrategyFactory.Create().ExecuteAsync(acceptAllChangesOnSuccess, SaveChangesAsync, null, cancellationToken) + ? Dependencies.ExecutionStrategyFactory.Create().ExecuteAsync( + acceptAllChangesOnSuccess, SaveChangesAsync, null, cancellationToken) : SaveChangesAsync(Context, acceptAllChangesOnSuccess, cancellationToken); private async Task SaveChangesAsync( - DbContext _, bool acceptAllChangesOnSuccess, CancellationToken cancellationToken) + DbContext _, + bool acceptAllChangesOnSuccess, + CancellationToken cancellationToken) { if (ChangedCount == 0) { diff --git a/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs b/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs index fd40b2dd0d7..fcc6cd6fd5b 100644 --- a/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs +++ b/src/EFCore/ChangeTracking/Internal/StateManagerDependencies.cs @@ -474,7 +474,6 @@ public StateManagerDependencies With([NotNull] IEntityMaterializerSource entityM UpdateLogger, ChangeTrackingLogger); - /// /// Clones this dependency parameter object with one service replaced. /// diff --git a/src/EFCore/ChangeTracking/LocalView.cs b/src/EFCore/ChangeTracking/LocalView.cs index 99770c83834..04959f2af00 100644 --- a/src/EFCore/ChangeTracking/LocalView.cs +++ b/src/EFCore/ChangeTracking/LocalView.cs @@ -183,7 +183,8 @@ public virtual IEnumerator GetEnumerator() /// that are not marked as deleted. /// /// An enumerator for the collection. - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); /// /// @@ -248,11 +249,11 @@ public virtual void Clear() } /// - /// Returns if the entity is being tracked by the context and has not been + /// Returns if the entity is being tracked by the context and has not been /// marked as Deleted. /// /// The entity to check. - /// if the entity is being tracked by the context and has not been marked as Deleted. + /// if the entity is being tracked by the context and has not been marked as Deleted. public virtual bool Contains(TEntity item) { var entry = _context.GetDependencies().StateManager.TryGetEntry(item); @@ -286,7 +287,7 @@ public virtual void CopyTo(TEntity[] array, int arrayIndex) /// /// /// The entity to delete. - /// if the entity was being tracked and was not already Deleted. + /// if the entity was being tracked and was not already Deleted. public virtual bool Remove(TEntity item) { var entry = _context.GetDependencies().StateManager.TryGetEntry(item); @@ -384,7 +385,8 @@ public virtual int Count /// /// False, since the collection is not read-only. /// - public virtual bool IsReadOnly => false; + public virtual bool IsReadOnly + => false; /// /// Occurs when a property of this collection (such as ) changes. @@ -424,9 +426,11 @@ protected virtual void OnPropertyChanging([NotNull] PropertyChangingEventArgs e) protected virtual void OnCollectionChanged([NotNull] NotifyCollectionChangedEventArgs e) => CollectionChanged?.Invoke(this, e); - private void OnCountPropertyChanged() => OnPropertyChanged(ObservableHashSetSingletons._countPropertyChanged); + private void OnCountPropertyChanged() + => OnPropertyChanged(ObservableHashSetSingletons._countPropertyChanged); - private void OnCountPropertyChanging() => OnPropertyChanging(ObservableHashSetSingletons._countPropertyChanging); + private void OnCountPropertyChanging() + => OnPropertyChanging(ObservableHashSetSingletons._countPropertyChanging); private void OnCollectionChanged(NotifyCollectionChangedAction action, object item) => OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, item)); @@ -452,12 +456,14 @@ public virtual BindingList ToBindingList() /// /// Always thrown. /// Never returns, always throws an exception. - IList IListSource.GetList() => throw new NotSupportedException(CoreStrings.DataBindingToLocalWithIListSource); + IList IListSource.GetList() + => throw new NotSupportedException(CoreStrings.DataBindingToLocalWithIListSource); /// /// Gets a value indicating whether the collection is a collection of System.Collections.IList objects. - /// Always returns . + /// Always returns . /// - bool IListSource.ContainsListCollection => false; + bool IListSource.ContainsListCollection + => false; } } diff --git a/src/EFCore/ChangeTracking/MemberEntry.cs b/src/EFCore/ChangeTracking/MemberEntry.cs index 970c275aad6..4db26bffda0 100644 --- a/src/EFCore/ChangeTracking/MemberEntry.cs +++ b/src/EFCore/ChangeTracking/MemberEntry.cs @@ -87,7 +87,8 @@ public virtual object CurrentValue /// The to which this member belongs. /// /// An entry for the entity that owns this member. - public virtual EntityEntry EntityEntry => new EntityEntry(InternalEntry); + public virtual EntityEntry EntityEntry + => new EntityEntry(InternalEntry); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -96,7 +97,8 @@ public virtual object CurrentValue /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - InternalEntityEntry IInfrastructure.Instance => InternalEntry; + InternalEntityEntry IInfrastructure.Instance + => InternalEntry; #region Hidden System.Object members @@ -105,22 +107,25 @@ public virtual object CurrentValue /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/ChangeTracking/NavigationEntry.cs b/src/EFCore/ChangeTracking/NavigationEntry.cs index 0613bdd77e7..0e33c71d88b 100644 --- a/src/EFCore/ChangeTracking/NavigationEntry.cs +++ b/src/EFCore/ChangeTracking/NavigationEntry.cs @@ -156,7 +156,7 @@ private static INavigationBase GetNavigation(InternalEntityEntry internalEntry, /// /// /// - /// if all the related entities are loaded or the IsLoaded has been explicitly set to true. + /// if all the related entities are loaded or the IsLoaded has been explicitly set to true. /// public virtual bool IsLoaded { diff --git a/src/EFCore/ChangeTracking/ObservableHashSet.cs b/src/EFCore/ChangeTracking/ObservableHashSet.cs index d5fc62a2ae8..cec1a54cde2 100644 --- a/src/EFCore/ChangeTracking/ObservableHashSet.cs +++ b/src/EFCore/ChangeTracking/ObservableHashSet.cs @@ -88,7 +88,8 @@ public ObservableHashSet([NotNull] IEnumerable collection, [NotNull] IEqualit /// public virtual event NotifyCollectionChangedEventHandler CollectionChanged; - void ICollection.Add(T item) => Add(item); + void ICollection.Add(T item) + => Add(item); /// /// Removes all elements from the hash set. @@ -117,9 +118,10 @@ public virtual void Clear() /// /// The element to locate in the hash set. /// - /// if the hash set contains the specified element; otherwise, . + /// if the hash set contains the specified element; otherwise, . /// - public virtual bool Contains(T item) => _set.Contains(item); + public virtual bool Contains(T item) + => _set.Contains(item); /// /// Copies the elements of the hash set to an array, starting at the specified array index. @@ -129,14 +131,15 @@ public virtual void Clear() /// the hash set. The array must have zero-based indexing. /// /// The zero-based index in array at which copying begins. - public virtual void CopyTo(T[] array, int arrayIndex) => _set.CopyTo(array, arrayIndex); + public virtual void CopyTo(T[] array, int arrayIndex) + => _set.CopyTo(array, arrayIndex); /// /// Removes the specified element from the hash set. /// /// The element to remove. /// - /// if the element is successfully found and removed; otherwise, . + /// if the element is successfully found and removed; otherwise, . /// public virtual bool Remove(T item) { @@ -159,12 +162,14 @@ public virtual bool Remove(T item) /// /// Gets the number of elements that are contained in the hash set. /// - public virtual int Count => _set.Count; + public virtual int Count + => _set.Count; /// /// Gets a value indicating whether the hash set is read-only. /// - public virtual bool IsReadOnly => ((ICollection)_set).IsReadOnly; + public virtual bool IsReadOnly + => ((ICollection)_set).IsReadOnly; /// /// Returns an enumerator that iterates through the hash set. @@ -172,20 +177,23 @@ public virtual bool Remove(T item) /// /// An enumerator for the hash set. /// - public virtual HashSet.Enumerator GetEnumerator() => _set.GetEnumerator(); + public virtual HashSet.Enumerator GetEnumerator() + => _set.GetEnumerator(); /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); /// /// Adds the specified element to the hash set. /// /// The element to add to the set. /// - /// if the element is added to the hash set; if the element is already present. + /// if the element is added to the hash set; if the element is already present. /// public virtual bool Add(T item) { @@ -318,54 +326,60 @@ public virtual void SymmetricExceptWith(IEnumerable other) /// /// The collection to compare to the current hash set. /// - /// if the hash set is a subset of other; otherwise, . + /// if the hash set is a subset of other; otherwise, . /// - public virtual bool IsSubsetOf(IEnumerable other) => _set.IsSubsetOf(other); + public virtual bool IsSubsetOf(IEnumerable other) + => _set.IsSubsetOf(other); /// /// Determines whether the hash set is a proper subset of the specified collection. /// /// The collection to compare to the current hash set. /// - /// if the hash set is a proper subset of other; otherwise, . + /// if the hash set is a proper subset of other; otherwise, . /// - public virtual bool IsProperSubsetOf(IEnumerable other) => _set.IsProperSubsetOf(other); + public virtual bool IsProperSubsetOf(IEnumerable other) + => _set.IsProperSubsetOf(other); /// /// Determines whether the hash set is a superset of the specified collection. /// /// The collection to compare to the current hash set. /// - /// if the hash set is a superset of other; otherwise, . + /// if the hash set is a superset of other; otherwise, . /// - public virtual bool IsSupersetOf(IEnumerable other) => _set.IsSupersetOf(other); + public virtual bool IsSupersetOf(IEnumerable other) + => _set.IsSupersetOf(other); /// /// Determines whether the hash set is a proper superset of the specified collection. /// /// The collection to compare to the current hash set. /// - /// if the hash set is a proper superset of other; otherwise, . + /// if the hash set is a proper superset of other; otherwise, . /// - public virtual bool IsProperSupersetOf(IEnumerable other) => _set.IsProperSupersetOf(other); + public virtual bool IsProperSupersetOf(IEnumerable other) + => _set.IsProperSupersetOf(other); /// /// Determines whether the current System.Collections.Generic.HashSet`1 object and a specified collection share common elements. /// /// The collection to compare to the current hash set. /// - /// if the hash set and other share at least one common element; otherwise, . + /// if the hash set and other share at least one common element; otherwise, . /// - public virtual bool Overlaps(IEnumerable other) => _set.Overlaps(other); + public virtual bool Overlaps(IEnumerable other) + => _set.Overlaps(other); /// /// Determines whether the hash set and the specified collection contain the same elements. /// /// The collection to compare to the current hash set. /// - /// if the hash set is equal to other; otherwise, . + /// if the hash set is equal to other; otherwise, . /// - public virtual bool SetEquals(IEnumerable other) => _set.SetEquals(other); + public virtual bool SetEquals(IEnumerable other) + => _set.SetEquals(other); /// /// Copies the elements of the hash set to an array. @@ -374,7 +388,8 @@ public virtual void SymmetricExceptWith(IEnumerable other) /// The one-dimensional array that is the destination of the elements copied from /// the hash set. The array must have zero-based indexing. /// - public virtual void CopyTo([NotNull] T[] array) => _set.CopyTo(array); + public virtual void CopyTo([NotNull] T[] array) + => _set.CopyTo(array); /// /// Copies the specified number of elements of the hash set to an array, starting at the specified array index. @@ -385,7 +400,8 @@ public virtual void SymmetricExceptWith(IEnumerable other) /// /// The zero-based index in array at which copying begins. /// The number of elements to copy to array. - public virtual void CopyTo([NotNull] T[] array, int arrayIndex, int count) => _set.CopyTo(array, arrayIndex, count); + public virtual void CopyTo([NotNull] T[] array, int arrayIndex, int count) + => _set.CopyTo(array, arrayIndex, count); /// /// Removes all elements that match the conditions defined by the specified predicate @@ -422,13 +438,15 @@ public virtual int RemoveWhere([NotNull] Predicate match) /// /// Gets the object that is used to determine equality for the values in the set. /// - public virtual IEqualityComparer Comparer => _set.Comparer; + public virtual IEqualityComparer Comparer + => _set.Comparer; /// /// Sets the capacity of the hash set to the actual number of elements it contains, rounded up to a nearby, /// implementation-specific value. /// - public virtual void TrimExcess() => _set.TrimExcess(); + public virtual void TrimExcess() + => _set.TrimExcess(); /// /// Raises the event. @@ -444,9 +462,11 @@ protected virtual void OnPropertyChanged([NotNull] PropertyChangedEventArgs e) protected virtual void OnPropertyChanging([NotNull] PropertyChangingEventArgs e) => PropertyChanging?.Invoke(this, e); - private void OnCountPropertyChanged() => OnPropertyChanged(ObservableHashSetSingletons._countPropertyChanged); + private void OnCountPropertyChanged() + => OnPropertyChanged(ObservableHashSetSingletons._countPropertyChanged); - private void OnCountPropertyChanging() => OnPropertyChanging(ObservableHashSetSingletons._countPropertyChanging); + private void OnCountPropertyChanging() + => OnPropertyChanging(ObservableHashSetSingletons._countPropertyChanging); private void OnCollectionChanged(NotifyCollectionChangedAction action, object item) => OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, item)); diff --git a/src/EFCore/ChangeTracking/PropertyEntry.cs b/src/EFCore/ChangeTracking/PropertyEntry.cs index 0314cbef19b..4c0c58ffe68 100644 --- a/src/EFCore/ChangeTracking/PropertyEntry.cs +++ b/src/EFCore/ChangeTracking/PropertyEntry.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; namespace Microsoft.EntityFrameworkCore.ChangeTracking { diff --git a/src/EFCore/ChangeTracking/PropertyEntry`.cs b/src/EFCore/ChangeTracking/PropertyEntry`.cs index fc2ef3b404f..c9d1823b613 100644 --- a/src/EFCore/ChangeTracking/PropertyEntry`.cs +++ b/src/EFCore/ChangeTracking/PropertyEntry`.cs @@ -50,7 +50,8 @@ public PropertyEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] IPro /// The to which this member belongs. /// /// An entry for the entity that owns this member. - public new virtual EntityEntry EntityEntry => new EntityEntry(InternalEntry); + public new virtual EntityEntry EntityEntry + => new EntityEntry(InternalEntry); /// /// Gets or sets the value currently assigned to this property. If the current value is set using this property, diff --git a/src/EFCore/ChangeTracking/PropertyValues.cs b/src/EFCore/ChangeTracking/PropertyValues.cs index bdf6cd63b7f..23df1246e57 100644 --- a/src/EFCore/ChangeTracking/PropertyValues.cs +++ b/src/EFCore/ChangeTracking/PropertyValues.cs @@ -4,8 +4,8 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using JetBrains.Annotations; using System.Linq; +using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -160,14 +160,14 @@ public virtual IEntityType EntityType /// True if the property exists, otherwise false. public virtual bool TryGetValue([NotNull] string propertyName, out TValue value) { - var property = Properties.FirstOrDefault(p=> p.Name == propertyName); + var property = Properties.FirstOrDefault(p => p.Name == propertyName); if (property != null) { value = GetValue(propertyName); return true; } - value = default(TValue); + value = default; return false; } @@ -187,22 +187,25 @@ public virtual bool TryGetValue([NotNull] string propertyName, out TValu /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/ChangeTracking/ReferenceEntry.cs b/src/EFCore/ChangeTracking/ReferenceEntry.cs index 6c5f59a9b3a..93cc1cb5010 100644 --- a/src/EFCore/ChangeTracking/ReferenceEntry.cs +++ b/src/EFCore/ChangeTracking/ReferenceEntry.cs @@ -171,7 +171,7 @@ public override bool IsModified } } - private void SetFkPropertiesModified( + private void SetFkPropertiesModified( INavigation navigation, InternalEntityEntry internalEntityEntry, bool modified) diff --git a/src/EFCore/ChangeTracking/ReferenceEntry`.cs b/src/EFCore/ChangeTracking/ReferenceEntry`.cs index 955df0d0ea9..a612aba30e8 100644 --- a/src/EFCore/ChangeTracking/ReferenceEntry`.cs +++ b/src/EFCore/ChangeTracking/ReferenceEntry`.cs @@ -53,7 +53,8 @@ public ReferenceEntry([NotNull] InternalEntityEntry internalEntry, [NotNull] INa /// The to which this member belongs. /// /// An entry for the entity that owns this member. - public new virtual EntityEntry EntityEntry => new EntityEntry(InternalEntry); + public new virtual EntityEntry EntityEntry + => new EntityEntry(InternalEntry); /// /// The of the entity this navigation targets. diff --git a/src/EFCore/ChangeTracking/ValueComparer.cs b/src/EFCore/ChangeTracking/ValueComparer.cs index 9adfa50a968..2f4cb6665ae 100644 --- a/src/EFCore/ChangeTracking/ValueComparer.cs +++ b/src/EFCore/ChangeTracking/ValueComparer.cs @@ -30,11 +30,12 @@ public abstract class ValueComparer : IEqualityComparer { internal static readonly MethodInfo ArrayCopyMethod = typeof(Array).GetMethods() - .Single(t => t.Name == nameof(Array.Copy) - && t.GetParameters().Length == 3 - && t.GetParameters()[0].ParameterType == typeof(Array) - && t.GetParameters()[1].ParameterType == typeof(Array) - && t.GetParameters()[2].ParameterType == typeof(int)); + .Single( + t => t.Name == nameof(Array.Copy) + && t.GetParameters().Length == 3 + && t.GetParameters()[0].ParameterType == typeof(Array) + && t.GetParameters()[1].ParameterType == typeof(Array) + && t.GetParameters()[2].ParameterType == typeof(int)); internal static readonly MethodInfo EqualityComparerHashCodeMethod = typeof(IEqualityComparer).GetRuntimeMethod(nameof(IEqualityComparer.GetHashCode), new[] { typeof(object) }); diff --git a/src/EFCore/ChangeTracking/ValueComparerExtensions.cs b/src/EFCore/ChangeTracking/ValueComparerExtensions.cs index 393db07e24a..3d96ad50c22 100644 --- a/src/EFCore/ChangeTracking/ValueComparerExtensions.cs +++ b/src/EFCore/ChangeTracking/ValueComparerExtensions.cs @@ -11,10 +11,10 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking public static class ValueComparerExtensions { /// - /// Returns if the given is a default EF Core implementation. + /// Returns if the given is a default EF Core implementation. /// /// The value comparer. - /// if the value comparer is the default; otherwise. + /// if the value comparer is the default; otherwise. public static bool IsDefault([NotNull] this ValueComparer valueComparer) => valueComparer.GetType().IsGenericType && valueComparer.GetType().GetGenericTypeDefinition() == typeof(ValueComparer.DefaultValueComparer<>); diff --git a/src/EFCore/ChangeTracking/ValueComparer`.cs b/src/EFCore/ChangeTracking/ValueComparer`.cs index f9155d1f034..a7a95b58843 100644 --- a/src/EFCore/ChangeTracking/ValueComparer`.cs +++ b/src/EFCore/ChangeTracking/ValueComparer`.cs @@ -315,7 +315,8 @@ public virtual T Snapshot([CanBeNull] T instance) /// /// The type. /// - public override Type Type => typeof(T); + public override Type Type + => typeof(T); /// /// The comparison expression. diff --git a/src/EFCore/DbContext.cs b/src/EFCore/DbContext.cs index ac593d65f93..d63a38ec922 100644 --- a/src/EFCore/DbContext.cs +++ b/src/EFCore/DbContext.cs @@ -160,7 +160,8 @@ public virtual DbContextId ContextId /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - IDbSetSource IDbContextDependencies.SetSource => DbContextDependencies.SetSource; + IDbSetSource IDbContextDependencies.SetSource + => DbContextDependencies.SetSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -169,7 +170,8 @@ public virtual DbContextId ContextId /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - IEntityFinderFactory IDbContextDependencies.EntityFinderFactory => DbContextDependencies.EntityFinderFactory; + IEntityFinderFactory IDbContextDependencies.EntityFinderFactory + => DbContextDependencies.EntityFinderFactory; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -178,7 +180,8 @@ public virtual DbContextId ContextId /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - IAsyncQueryProvider IDbContextDependencies.QueryProvider => DbContextDependencies.QueryProvider; + IAsyncQueryProvider IDbContextDependencies.QueryProvider + => DbContextDependencies.QueryProvider; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -187,7 +190,8 @@ public virtual DbContextId ContextId /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - IStateManager IDbContextDependencies.StateManager => DbContextDependencies.StateManager; + IStateManager IDbContextDependencies.StateManager + => DbContextDependencies.StateManager; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -196,7 +200,8 @@ public virtual DbContextId ContextId /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - IChangeDetector IDbContextDependencies.ChangeDetector => DbContextDependencies.ChangeDetector; + IChangeDetector IDbContextDependencies.ChangeDetector + => DbContextDependencies.ChangeDetector; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -205,7 +210,8 @@ public virtual DbContextId ContextId /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - IEntityGraphAttacher IDbContextDependencies.EntityGraphAttacher => DbContextDependencies.EntityGraphAttacher; + IEntityGraphAttacher IDbContextDependencies.EntityGraphAttacher + => DbContextDependencies.EntityGraphAttacher; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -214,7 +220,8 @@ public virtual DbContextId ContextId /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - IDiagnosticsLogger IDbContextDependencies.UpdateLogger => DbContextDependencies.UpdateLogger; + IDiagnosticsLogger IDbContextDependencies.UpdateLogger + => DbContextDependencies.UpdateLogger; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -457,7 +464,8 @@ protected internal virtual void OnModelCreating(ModelBuilder modelBuilder) /// A concurrency violation occurs when an unexpected number of rows are affected during save. /// This is usually because the data in the database has been modified since it was loaded into memory. /// - public virtual int SaveChanges() => SaveChanges(acceptAllChangesOnSuccess: true); + public virtual int SaveChanges() + => SaveChanges(acceptAllChangesOnSuccess: true); /// /// @@ -652,17 +660,17 @@ await DbContextDependencies.UpdateLogger.OptimisticConcurrencyExceptionAsync(thi } /// - /// An event fired at the beginning of a call to or + /// An event fired at the beginning of a call to or /// public event EventHandler SavingChanges; /// - /// An event fired at the end of a call to or + /// An event fired at the end of a call to or /// public event EventHandler SavedChanges; /// - /// An event fired if a call to or fails with an exception. + /// An event fired if a call to or fails with an exception. /// public event EventHandler SaveChangesFailed; @@ -691,10 +699,13 @@ void IDbContextPoolable.SetLease(DbContextLease lease) if (_configurationSnapshot?.AutoDetectChangesEnabled != null) { - Check.DebugAssert(_configurationSnapshot.QueryTrackingBehavior.HasValue, "!configurationSnapshot.QueryTrackingBehavior.HasValue"); + Check.DebugAssert( + _configurationSnapshot.QueryTrackingBehavior.HasValue, "!configurationSnapshot.QueryTrackingBehavior.HasValue"); Check.DebugAssert(_configurationSnapshot.LazyLoadingEnabled.HasValue, "!configurationSnapshot.LazyLoadingEnabled.HasValue"); - Check.DebugAssert(_configurationSnapshot.CascadeDeleteTiming.HasValue, "!configurationSnapshot.CascadeDeleteTiming.HasValue"); - Check.DebugAssert(_configurationSnapshot.DeleteOrphansTiming.HasValue, "!configurationSnapshot.DeleteOrphansTiming.HasValue"); + Check.DebugAssert( + _configurationSnapshot.CascadeDeleteTiming.HasValue, "!configurationSnapshot.CascadeDeleteTiming.HasValue"); + Check.DebugAssert( + _configurationSnapshot.DeleteOrphansTiming.HasValue, "!configurationSnapshot.DeleteOrphansTiming.HasValue"); ChangeTracker.AutoDetectChangesEnabled = _configurationSnapshot.AutoDetectChangesEnabled.Value; ChangeTracker.QueryTrackingBehavior = _configurationSnapshot.QueryTrackingBehavior.Value; @@ -1518,9 +1529,9 @@ public virtual async Task AddRangeAsync( foreach (var entity in entities) { await SetEntityStateAsync( - stateManager.GetOrCreateEntry(entity), - EntityState.Added, - cancellationToken) + stateManager.GetOrCreateEntry(entity), + EntityState.Added, + cancellationToken) .ConfigureAwait(false); } } @@ -1688,7 +1699,9 @@ public virtual ValueTask FindAsync([NotNull] Type entityType, [CanBeNull /// A to observe while waiting for the task to complete. /// The entity found, or null. public virtual ValueTask FindAsync( - [NotNull] Type entityType, [CanBeNull] object[] keyValues, CancellationToken cancellationToken) + [NotNull] Type entityType, + [CanBeNull] object[] keyValues, + CancellationToken cancellationToken) { CheckDisposed(); @@ -1759,14 +1772,15 @@ public virtual ValueTask FindAsync([CanBeNull] object[] keyVal /// not directly exposed in the public API surface. /// /// - IServiceProvider IInfrastructure.Instance => InternalServiceProvider; + IServiceProvider IInfrastructure.Instance + => InternalServiceProvider; /// /// Creates a queryable for given query expression. /// /// The result type of the query expression. /// The query expression to create. - /// An representing the query. + /// An representing the query. public virtual IQueryable FromExpression([NotNull] Expression>> expression) { Check.NotNull(expression, nameof(expression)); @@ -1781,22 +1795,25 @@ public virtual IQueryable FromExpression([NotNull] Expression< /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/DbContextId.cs b/src/EFCore/DbContextId.cs index f7d8abd2c9d..9f4b946d9d7 100644 --- a/src/EFCore/DbContextId.cs +++ b/src/EFCore/DbContextId.cs @@ -21,7 +21,7 @@ public readonly struct DbContextId /// Compares this ID to another ID to see if they represent the same leased context. /// /// The other ID. - /// if they represent the same leased context; otherwise. + /// if they represent the same leased context; otherwise. public bool Equals(DbContextId other) => InstanceId == other.InstanceId && Lease == other.Lease; @@ -30,7 +30,7 @@ public bool Equals(DbContextId other) /// Compares this ID to another ID to see if they represent the same leased context. /// /// The other ID. - /// if they represent the same leased context; otherwise. + /// if they represent the same leased context; otherwise. public override bool Equals(object obj) => obj is DbContextId other && Equals(other); @@ -46,16 +46,18 @@ public override int GetHashCode() /// /// The first ID. /// The second ID. - /// if they represent the same leased context; otherwise. - public static bool operator ==(DbContextId left, DbContextId right) => left.Equals(right); + /// if they represent the same leased context; otherwise. + public static bool operator ==(DbContextId left, DbContextId right) + => left.Equals(right); /// /// Compares one ID to another ID to see if they represent different leased contexts. /// /// The first ID. /// The second ID. - /// if they represent different leased contexts; otherwise. - public static bool operator !=(DbContextId left, DbContextId right) => !left.Equals(right); + /// if they represent different leased contexts; otherwise. + public static bool operator !=(DbContextId left, DbContextId right) + => !left.Equals(right); /// /// Creates a new with the given and lease number. diff --git a/src/EFCore/DbContextOptions.cs b/src/EFCore/DbContextOptions.cs index 5271f39c4ff..d421ee6eafa 100644 --- a/src/EFCore/DbContextOptions.cs +++ b/src/EFCore/DbContextOptions.cs @@ -34,7 +34,8 @@ protected DbContextOptions( /// /// Gets the extensions that store the configured options. /// - public virtual IEnumerable Extensions => _extensions.Values; + public virtual IEnumerable Extensions + => _extensions.Values; /// /// Gets the extension of the specified type. Returns null if no extension of the specified type is configured. @@ -83,10 +84,11 @@ public abstract DbContextOptions WithExtension([NotNull] TExtension /// /// Specifies that no further configuration of this options object should occur. /// - public virtual void Freeze() => IsFrozen = true; + public virtual void Freeze() + => IsFrozen = true; /// - /// Returns if has been called. A frozen options object cannot be further + /// Returns if has been called. A frozen options object cannot be further /// configured with . /// public virtual bool IsFrozen { get; private set; } diff --git a/src/EFCore/DbContextOptionsBuilder.cs b/src/EFCore/DbContextOptionsBuilder.cs index 3b367ba212a..096d423cd0f 100644 --- a/src/EFCore/DbContextOptionsBuilder.cs +++ b/src/EFCore/DbContextOptionsBuilder.cs @@ -57,7 +57,8 @@ public DbContextOptionsBuilder([NotNull] DbContextOptions options) /// /// Gets the options being configured. /// - public virtual DbContextOptions Options => _options; + public virtual DbContextOptions Options + => _options; /// /// @@ -70,7 +71,8 @@ public DbContextOptionsBuilder([NotNull] DbContextOptions options) /// . /// /// - public virtual bool IsConfigured => _options.Extensions.Any(e => e.Info.IsDatabaseProvider); + public virtual bool IsConfigured + => _options.Extensions.Any(e => e.Info.IsDatabaseProvider); /// /// @@ -113,7 +115,9 @@ public virtual DbContextOptionsBuilder UseLoggerFactory([CanBeNull] ILoggerFacto /// /// /// This overload allows the minimum level of logging and the log formatting to be controlled. - /// Use the + /// Use the + /// /// overload to log only specific events. /// Use the /// overload to log only events in specific categories. @@ -637,22 +641,25 @@ private DbContextOptionsBuilder WithOption(Func /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/DbContextOptionsBuilder`.cs b/src/EFCore/DbContextOptionsBuilder`.cs index 6c78663630b..f58155e525a 100644 --- a/src/EFCore/DbContextOptionsBuilder`.cs +++ b/src/EFCore/DbContextOptionsBuilder`.cs @@ -51,7 +51,8 @@ public DbContextOptionsBuilder([NotNull] DbContextOptions options) /// /// Gets the options being configured. /// - public new virtual DbContextOptions Options => (DbContextOptions)base.Options; + public new virtual DbContextOptions Options + => (DbContextOptions)base.Options; /// /// Sets the model to be used for the context. If the model is set, then @@ -90,7 +91,9 @@ public DbContextOptionsBuilder([NotNull] DbContextOptions options) /// /// /// This overload allows the minimum level of logging and the log formatting to be controlled. - /// Use the + /// Use the + /// /// overload to log only specific events. /// Use the /// overload to log only events in specific categories. diff --git a/src/EFCore/DbContextOptions`.cs b/src/EFCore/DbContextOptions`.cs index 4509c7b0611..3f9b0937577 100644 --- a/src/EFCore/DbContextOptions`.cs +++ b/src/EFCore/DbContextOptions`.cs @@ -61,6 +61,7 @@ public override DbContextOptions WithExtension(TExtension extension) /// /// The type of context that these options are for (). /// - public override Type ContextType => typeof(TContext); + public override Type ContextType + => typeof(TContext); } } diff --git a/src/EFCore/DbFunctions.cs b/src/EFCore/DbFunctions.cs index c3bfafe48c3..f26ee36afd2 100644 --- a/src/EFCore/DbFunctions.cs +++ b/src/EFCore/DbFunctions.cs @@ -24,22 +24,25 @@ private DbFunctions() /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/DbFunctionsExtensions.cs b/src/EFCore/DbFunctionsExtensions.cs index f423fa0f14b..c1ed88c73a4 100644 --- a/src/EFCore/DbFunctionsExtensions.cs +++ b/src/EFCore/DbFunctionsExtensions.cs @@ -29,7 +29,7 @@ public static class DbFunctionsExtensions /// The DbFunctions instance. /// The string that is to be matched. /// The pattern which may involve wildcards %,_,[,],^. - /// if there is a match. + /// if there is a match. public static bool Like( [CanBeNull] this DbFunctions _, [CanBeNull] string matchExpression, @@ -55,7 +55,7 @@ public static bool Like( /// The escape character (as a single character string) to use in front of %,_,[,],^ /// if they are not used as wildcards. /// - /// if there is a match. + /// if there is a match. public static bool Like( [CanBeNull] this DbFunctions _, [CanBeNull] string matchExpression, diff --git a/src/EFCore/DbSet.cs b/src/EFCore/DbSet.cs index 79d0bd66cf2..871c445e23e 100644 --- a/src/EFCore/DbSet.cs +++ b/src/EFCore/DbSet.cs @@ -44,9 +44,10 @@ public abstract class DbSet where TEntity : class { /// - /// The metadata associated with this set. + /// The metadata associated with this set. /// - public virtual IEntityType EntityType => null; + public virtual IEntityType EntityType + => null; /// /// @@ -58,7 +59,8 @@ public abstract class DbSet /// /// /// This object. - public virtual IAsyncEnumerable AsAsyncEnumerable() => this; + public virtual IAsyncEnumerable AsAsyncEnumerable() + => this; /// /// @@ -70,7 +72,8 @@ public abstract class DbSet /// /// /// This object. - public virtual IQueryable AsQueryable() => this; + public virtual IQueryable AsQueryable() + => this; /// /// @@ -90,7 +93,8 @@ public abstract class DbSet /// for WinForms. /// /// - public virtual LocalView Local => throw new NotImplementedException(); + public virtual LocalView Local + => throw new NotImplementedException(); /// /// Finds an entity with the given primary key values. If an entity with the given primary key values @@ -101,7 +105,8 @@ public abstract class DbSet /// /// The values of the primary key for the entity to be found. /// The entity found, or null. - public virtual TEntity Find([CanBeNull] params object[] keyValues) => throw new NotImplementedException(); + public virtual TEntity Find([CanBeNull] params object[] keyValues) + => throw new NotImplementedException(); /// /// Finds an entity with the given primary key values. If an entity with the given primary key values @@ -112,7 +117,8 @@ public abstract class DbSet /// /// The values of the primary key for the entity to be found. /// The entity found, or null. - public virtual ValueTask FindAsync([CanBeNull] params object[] keyValues) => throw new NotImplementedException(); + public virtual ValueTask FindAsync([CanBeNull] params object[] keyValues) + => throw new NotImplementedException(); /// /// Finds an entity with the given primary key values. If an entity with the given primary key values @@ -142,7 +148,8 @@ public virtual ValueTask FindAsync([CanBeNull] object[] keyValues, Canc /// The for the entity. The entry provides /// access to change tracking information and operations for the entity. /// - public virtual EntityEntry Add([NotNull] TEntity entity) => throw new NotImplementedException(); + public virtual EntityEntry Add([NotNull] TEntity entity) + => throw new NotImplementedException(); /// /// @@ -168,7 +175,8 @@ public virtual ValueTask FindAsync([CanBeNull] object[] keyValues, Canc /// public virtual ValueTask> AddAsync( [NotNull] TEntity entity, - CancellationToken cancellationToken = default) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); /// /// @@ -204,7 +212,8 @@ public virtual ValueTask> AddAsync( /// The for the entity. The entry provides /// access to change tracking information and operations for the entity. /// - public virtual EntityEntry Attach([NotNull] TEntity entity) => throw new NotImplementedException(); + public virtual EntityEntry Attach([NotNull] TEntity entity) + => throw new NotImplementedException(); /// /// Begins tracking the given entity in the state such that it will @@ -230,7 +239,8 @@ public virtual ValueTask> AddAsync( /// The for the entity. The entry provides /// access to change tracking information and operations for the entity. /// - public virtual EntityEntry Remove([NotNull] TEntity entity) => throw new NotImplementedException(); + public virtual EntityEntry Remove([NotNull] TEntity entity) + => throw new NotImplementedException(); /// /// @@ -266,7 +276,8 @@ public virtual ValueTask> AddAsync( /// The for the entity. The entry provides /// access to change tracking information and operations for the entity. /// - public virtual EntityEntry Update([NotNull] TEntity entity) => throw new NotImplementedException(); + public virtual EntityEntry Update([NotNull] TEntity entity) + => throw new NotImplementedException(); /// /// Begins tracking the given entities, and any other reachable entities that are @@ -274,7 +285,8 @@ public virtual ValueTask> AddAsync( /// be inserted into the database when is called. /// /// The entities to add. - public virtual void AddRange([NotNull] params TEntity[] entities) => throw new NotImplementedException(); + public virtual void AddRange([NotNull] params TEntity[] entities) + => throw new NotImplementedException(); /// /// @@ -290,7 +302,8 @@ public virtual ValueTask> AddAsync( /// /// The entities to add. /// A task that represents the asynchronous operation. - public virtual Task AddRangeAsync([NotNull] params TEntity[] entities) => throw new NotImplementedException(); + public virtual Task AddRangeAsync([NotNull] params TEntity[] entities) + => throw new NotImplementedException(); /// /// @@ -322,7 +335,8 @@ public virtual ValueTask> AddAsync( /// /// /// The entities to attach. - public virtual void AttachRange([NotNull] params TEntity[] entities) => throw new NotImplementedException(); + public virtual void AttachRange([NotNull] params TEntity[] entities) + => throw new NotImplementedException(); /// /// Begins tracking the given entities in the state such that they will @@ -341,7 +355,8 @@ public virtual ValueTask> AddAsync( /// /// /// The entities to remove. - public virtual void RemoveRange([NotNull] params TEntity[] entities) => throw new NotImplementedException(); + public virtual void RemoveRange([NotNull] params TEntity[] entities) + => throw new NotImplementedException(); /// /// @@ -373,7 +388,8 @@ public virtual ValueTask> AddAsync( /// /// /// The entities to update. - public virtual void UpdateRange([NotNull] params TEntity[] entities) => throw new NotImplementedException(); + public virtual void UpdateRange([NotNull] params TEntity[] entities) + => throw new NotImplementedException(); /// /// Begins tracking the given entities, and any other reachable entities that are @@ -381,7 +397,8 @@ public virtual ValueTask> AddAsync( /// be inserted into the database when is called. /// /// The entities to add. - public virtual void AddRange([NotNull] IEnumerable entities) => throw new NotImplementedException(); + public virtual void AddRange([NotNull] IEnumerable entities) + => throw new NotImplementedException(); /// /// @@ -400,7 +417,8 @@ public virtual ValueTask> AddAsync( /// A task that represents the asynchronous operation. public virtual Task AddRangeAsync( [NotNull] IEnumerable entities, - CancellationToken cancellationToken = default) => throw new NotImplementedException(); + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); /// /// @@ -432,7 +450,8 @@ public virtual Task AddRangeAsync( /// /// /// The entities to attach. - public virtual void AttachRange([NotNull] IEnumerable entities) => throw new NotImplementedException(); + public virtual void AttachRange([NotNull] IEnumerable entities) + => throw new NotImplementedException(); /// /// Begins tracking the given entities in the state such that they will @@ -451,7 +470,8 @@ public virtual Task AddRangeAsync( /// /// /// The entities to remove. - public virtual void RemoveRange([NotNull] IEnumerable entities) => throw new NotImplementedException(); + public virtual void RemoveRange([NotNull] IEnumerable entities) + => throw new NotImplementedException(); /// /// @@ -483,21 +503,24 @@ public virtual Task AddRangeAsync( /// /// /// The entities to update. - public virtual void UpdateRange([NotNull] IEnumerable entities) => throw new NotImplementedException(); + public virtual void UpdateRange([NotNull] IEnumerable entities) + => throw new NotImplementedException(); /// /// Returns an which when enumerated will execute a query against the database /// to load all entities from the database. /// /// The query results. - IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); + IEnumerator IEnumerable.GetEnumerator() + => throw new NotImplementedException(); /// /// Returns an which when enumerated will execute a query against the database /// to load all entities from the database. /// /// The query results. - IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); + IEnumerator IEnumerable.GetEnumerator() + => throw new NotImplementedException(); /// /// Returns an which when enumerated will asynchronously execute a query against @@ -510,17 +533,20 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(Cancellat /// /// Gets the IQueryable element type. /// - Type IQueryable.ElementType => throw new NotImplementedException(); + Type IQueryable.ElementType + => throw new NotImplementedException(); /// /// Gets the IQueryable LINQ Expression. /// - Expression IQueryable.Expression => throw new NotImplementedException(); + Expression IQueryable.Expression + => throw new NotImplementedException(); /// /// Gets the IQueryable provider. /// - IQueryProvider IQueryable.Provider => throw new NotImplementedException(); + IQueryProvider IQueryable.Provider + => throw new NotImplementedException(); /// /// @@ -531,7 +557,8 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(Cancellat /// not directly exposed in the public API surface. /// /// - IServiceProvider IInfrastructure.Instance => throw new NotImplementedException(); + IServiceProvider IInfrastructure.Instance + => throw new NotImplementedException(); /// /// @@ -558,9 +585,10 @@ IList IListSource.GetList() /// /// Gets a value indicating whether the collection is a collection of System.Collections.IList objects. - /// Always returns . + /// Always returns . /// - bool IListSource.ContainsListCollection => false; + bool IListSource.ContainsListCollection + => false; #region Hidden System.Object members @@ -569,22 +597,25 @@ IList IListSource.GetList() /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/DbUpdateException.cs b/src/EFCore/DbUpdateException.cs index 73ebe798f7c..bc026e1ef0a 100644 --- a/src/EFCore/DbUpdateException.cs +++ b/src/EFCore/DbUpdateException.cs @@ -92,6 +92,7 @@ public DbUpdateException([NotNull] SerializationInfo info, StreamingContext cont /// Gets the entries that were involved in the error. Typically this is a single entry, but in some cases it /// may be zero or multiple entries. /// - public virtual IReadOnlyList Entries => _entries ??= new List(); + public virtual IReadOnlyList Entries + => _entries ??= new List(); } } diff --git a/src/EFCore/Diagnostics/CoreEventId.cs b/src/EFCore/Diagnostics/CoreEventId.cs index 1fc9d33b9b2..b5c7f3d3058 100644 --- a/src/EFCore/Diagnostics/CoreEventId.cs +++ b/src/EFCore/Diagnostics/CoreEventId.cs @@ -125,7 +125,9 @@ private enum Id } private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + "."; - private static EventId MakeUpdateId(Id id) => new EventId((int)id, _updatePrefix + id); + + private static EventId MakeUpdateId(Id id) + => new EventId((int)id, _updatePrefix + id); /// /// @@ -148,7 +150,9 @@ private enum Id MakeUpdateId(Id.DuplicateDependentEntityTypeInstanceWarning); private static readonly string _queryPrefix = DbLoggerCategory.Query.Name + "."; - private static EventId MakeQueryId(Id id) => new EventId((int)id, _queryPrefix + id); + + private static EventId MakeQueryId(Id id) + => new EventId((int)id, _queryPrefix + id); /// /// @@ -269,7 +273,9 @@ public static readonly EventId FirstWithoutOrderByAndFilterWarning = MakeQueryId(Id.FirstWithoutOrderByAndFilterWarning); private static readonly string _infraPrefix = DbLoggerCategory.Infrastructure.Name + "."; - private static EventId MakeInfraId(Id id) => new EventId((int)id, _infraPrefix + id); + + private static EventId MakeInfraId(Id id) + => new EventId((int)id, _infraPrefix + id); /// /// @@ -402,10 +408,14 @@ public static readonly EventId FirstWithoutOrderByAndFilterWarning public static readonly EventId RedundantAddServicesCallWarning = MakeInfraId(Id.RedundantAddServicesCallWarning); private static readonly string _modelPrefix = DbLoggerCategory.Model.Name + "."; - private static EventId MakeModelId(Id id) => new EventId((int)id, _modelPrefix + id); + + private static EventId MakeModelId(Id id) + => new EventId((int)id, _modelPrefix + id); private static readonly string _modelValidationPrefix = DbLoggerCategory.Model.Validation.Name + "."; - private static EventId MakeModelValidationId(Id id) => new EventId((int)id, _modelValidationPrefix + id); + + private static EventId MakeModelValidationId(Id id) + => new EventId((int)id, _modelValidationPrefix + id); /// /// @@ -518,7 +528,8 @@ public static readonly EventId FirstWithoutOrderByAndFilterWarning /// /// [Obsolete] - public static readonly EventId NonNullableReferenceOnBothNavigations = MakeModelId(Id.Obsolete_NonNullableReferenceOnBothNavigations); + public static readonly EventId NonNullableReferenceOnBothNavigations = + MakeModelId(Id.Obsolete_NonNullableReferenceOnBothNavigations); /// /// @@ -723,8 +734,8 @@ public static readonly EventId FirstWithoutOrderByAndFilterWarning /// /// - /// A attribute on the entity type is conflicting - /// with a attribute on at least one of its properties. + /// A attribute on the entity type is conflicting + /// with a attribute on at least one of its properties. /// /// /// This event is in the category. @@ -734,7 +745,8 @@ public static readonly EventId FirstWithoutOrderByAndFilterWarning /// . /// /// - public static readonly EventId ConflictingKeylessAndKeyAttributesWarning = MakeModelId(Id.ConflictingKeylessAndKeyAttributesWarning); + public static readonly EventId ConflictingKeylessAndKeyAttributesWarning = + MakeModelId(Id.ConflictingKeylessAndKeyAttributesWarning); /// /// @@ -753,7 +765,9 @@ public static readonly EventId PossibleIncorrectRequiredNavigationWithQueryFilte = MakeModelValidationId(Id.PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning); private static readonly string _changeTrackingPrefix = DbLoggerCategory.ChangeTracking.Name + "."; - private static EventId MakeChangeTrackingId(Id id) => new EventId((int)id, _changeTrackingPrefix + id); + + private static EventId MakeChangeTrackingId(Id id) + => new EventId((int)id, _changeTrackingPrefix + id); /// /// diff --git a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs index c99b31c7cbe..8597d9e4639 100644 --- a/src/EFCore/Diagnostics/CoreLoggerExtensions.cs +++ b/src/EFCore/Diagnostics/CoreLoggerExtensions.cs @@ -57,7 +57,8 @@ public static void SaveChangesFailed( exception); } - if (diagnostics.NeedsEventData(definition, + if (diagnostics.NeedsEventData( + definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = CreateDbContextErrorEventData(context, exception, definition); @@ -75,7 +76,7 @@ public static void SaveChangesFailed( /// The context in use. /// The exception that caused this event. /// The cancellation token. - /// A for the async result. + /// A for the async result. public static Task SaveChangesFailedAsync( [NotNull] this IDiagnosticsLogger diagnostics, [NotNull] DbContext context, @@ -92,7 +93,8 @@ public static Task SaveChangesFailedAsync( exception); } - if (diagnostics.NeedsEventData(definition, + if (diagnostics.NeedsEventData( + definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = CreateDbContextErrorEventData(context, exception, definition); @@ -109,7 +111,9 @@ public static Task SaveChangesFailedAsync( } private static DbContextErrorEventData CreateDbContextErrorEventData( - DbContext context, Exception exception, EventDefinition definition) + DbContext context, + Exception exception, + EventDefinition definition) => new DbContextErrorEventData(definition, SaveChangesFailed, context, exception); private static string SaveChangesFailed(EventDefinitionBase definition, EventData payload) @@ -137,7 +141,8 @@ public static void OptimisticConcurrencyException( definition.Log(diagnostics, exception); } - if (diagnostics.NeedsEventData(definition, + if (diagnostics.NeedsEventData( + definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = CreateDbContextErrorEventData(context, exception, definition); @@ -155,7 +160,7 @@ public static void OptimisticConcurrencyException( /// The context in use. /// The exception that caused this event. /// The cancellation token. - /// A for the async result. + /// A for the async result. public static Task OptimisticConcurrencyExceptionAsync( [NotNull] this IDiagnosticsLogger diagnostics, [NotNull] DbContext context, @@ -187,7 +192,9 @@ public static Task OptimisticConcurrencyExceptionAsync( } private static DbContextErrorEventData CreateDbContextErrorEventData( - DbContext context, Exception exception, EventDefinition definition) + DbContext context, + Exception exception, + EventDefinition definition) => new DbContextErrorEventData( definition, OptimisticConcurrencyException, @@ -216,7 +223,7 @@ public static void DuplicateDependentEntityTypeInstanceWarning( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,dependent1.DisplayName(), dependent2.DisplayName()); + definition.Log(diagnostics, dependent1.DisplayName(), dependent2.DisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -587,7 +594,10 @@ private static string PossibleUnintendedReferenceComparisonWarning(EventDefiniti /// Logs for the event. /// /// The diagnostics logger to use. - /// The navigation chain used in the + /// + /// The navigation chain used in the + /// + /// /// The navigation name which was not found in the model. public static void InvalidIncludePathError( [NotNull] this IDiagnosticsLogger diagnostics, @@ -863,7 +873,7 @@ public static void LazyLoadOnDisposedContextWarning( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,navigationName, entityType.GetType().ShortDisplayName()); + definition.Log(diagnostics, navigationName, entityType.GetType().ShortDisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -903,7 +913,7 @@ public static void NavigationLazyLoading( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,navigationName, entityType.GetType().ShortDisplayName()); + definition.Log(diagnostics, navigationName, entityType.GetType().ShortDisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -943,7 +953,7 @@ public static void DetachedLazyLoadingWarning( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,navigationName, entityType.GetType().ShortDisplayName()); + definition.Log(diagnostics, navigationName, entityType.GetType().ShortDisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -985,9 +995,9 @@ public static void RedundantAddServicesCallWarning( if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = new ServiceProviderEventData( - definition, - (d, p) => ((EventDefinition)d).GenerateMessage(), - serviceProvider); + definition, + (d, p) => ((EventDefinition)d).GenerateMessage(), + serviceProvider); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); } @@ -1006,7 +1016,7 @@ public static void ShadowPropertyCreated( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,property.Name, property.DeclaringEntityType.DisplayName()); + definition.Log(diagnostics, property.Name, property.DeclaringEntityType.DisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -1040,7 +1050,7 @@ public static void CollectionWithoutComparer( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,property.Name, property.DeclaringEntityType.DisplayName()); + definition.Log(diagnostics, property.Name, property.DeclaringEntityType.DisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -1148,8 +1158,14 @@ private static string RedundantForeignKeyWarning(EventDefinitionBase definition, /// Logs for the event. /// /// The diagnostics logger to use. - /// The name of the navigation property or entity type on the dependent end of the relationship. - /// The name of the navigation property or entity type on the principal end of the relationship. + /// + /// The name of the navigation property or entity type on the dependent end of the + /// relationship. + /// + /// + /// The name of the navigation property or entity type on the principal end of the + /// relationship. + /// /// The properties that make up the foreign key. /// The corresponding keys on the principal side. public static void IncompatibleMatchingForeignKeyProperties( @@ -1997,10 +2013,7 @@ public static void ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning var eventData = new TwoUnmappedPropertyCollectionsEventData( definition, ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning, - new[] - { - new Tuple(navigation.GetIdentifyingMemberInfo(), navigation.DeclaringEntityType.ClrType) - }, + new[] { new Tuple(navigation.GetIdentifyingMemberInfo(), navigation.DeclaringEntityType.ClrType) }, new[] { new Tuple(property, property.DeclaringType) }); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); @@ -2008,7 +2021,8 @@ public static void ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning } private static string ConflictingForeignKeyAttributesOnNavigationAndPropertyWarning( - EventDefinitionBase definition, EventData payload) + EventDefinitionBase definition, + EventData payload) { var d = (EventDefinition)definition; var p = (TwoUnmappedPropertyCollectionsEventData)payload; @@ -2068,7 +2082,7 @@ public static void DetectChangesCompleted( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,context.GetType().ShortDisplayName()); + definition.Log(diagnostics, context.GetType().ShortDisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -2108,7 +2122,7 @@ public static void PropertyChangeDetected( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,property.DeclaringEntityType.ShortName(),property.Name); + definition.Log(diagnostics, property.DeclaringEntityType.ShortName(), property.Name); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -2521,7 +2535,7 @@ public static void ReferenceChangeDetected( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,navigation.DeclaringEntityType.ShortName(),navigation.Name); + definition.Log(diagnostics, navigation.DeclaringEntityType.ShortName(), navigation.Name); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -3089,10 +3103,11 @@ public static InterceptionResult SaveChangesStarting( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,context.GetType().ShortDisplayName()); + definition.Log(diagnostics, context.GetType().ShortDisplayName()); } - if (diagnostics.NeedsEventData(definition, + if (diagnostics.NeedsEventData( + definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = CreateSaveChangesStartingEventData(context, definition); @@ -3124,10 +3139,11 @@ public static ValueTask> SaveChangesStartingAsync( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,context.GetType().ShortDisplayName()); + definition.Log(diagnostics, context.GetType().ShortDisplayName()); } - if (diagnostics.NeedsEventData(definition, + if (diagnostics.NeedsEventData( + definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = CreateSaveChangesStartingEventData(context, definition); @@ -3172,10 +3188,11 @@ public static int SaveChangesCompleted( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,context.GetType().ShortDisplayName(), entitiesSavedCount); + definition.Log(diagnostics, context.GetType().ShortDisplayName(), entitiesSavedCount); } - if (diagnostics.NeedsEventData(definition, + if (diagnostics.NeedsEventData( + definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = CreateSaveChangesCompletedEventData(context, entitiesSavedCount, definition); @@ -3209,10 +3226,11 @@ public static ValueTask SaveChangesCompletedAsync( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,context.GetType().ShortDisplayName(), entitiesSavedCount); + definition.Log(diagnostics, context.GetType().ShortDisplayName(), entitiesSavedCount); } - if (diagnostics.NeedsEventData(definition, + if (diagnostics.NeedsEventData( + definition, out var interceptor, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = CreateSaveChangesCompletedEventData(context, entitiesSavedCount, definition); @@ -3229,7 +3247,9 @@ public static ValueTask SaveChangesCompletedAsync( } private static SaveChangesCompletedEventData CreateSaveChangesCompletedEventData( - DbContext context, int entitiesSavedCount, EventDefinition definition) + DbContext context, + int entitiesSavedCount, + EventDefinition definition) => new SaveChangesCompletedEventData( definition, SaveChangesCompleted, @@ -3258,7 +3278,7 @@ public static void ContextDisposed( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics,context.GetType().ShortDisplayName()); + definition.Log(diagnostics, context.GetType().ShortDisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) @@ -3345,7 +3365,9 @@ public static void PossibleIncorrectRequiredNavigationWithQueryFilterInteraction } } - private static string PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning(EventDefinitionBase definition, EventData payload) + private static string PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning( + EventDefinitionBase definition, + EventData payload) { var d = (EventDefinition)definition; var p = (ForeignKeyEventData)payload; diff --git a/src/EFCore/Diagnostics/EventData.cs b/src/EFCore/Diagnostics/EventData.cs index c21a15a6cc5..a05aceae5ed 100644 --- a/src/EFCore/Diagnostics/EventData.cs +++ b/src/EFCore/Diagnostics/EventData.cs @@ -32,22 +32,26 @@ public EventData( /// /// The that defines the message ID and name. /// - public virtual EventId EventId => _eventDefinition.EventId; + public virtual EventId EventId + => _eventDefinition.EventId; /// /// The that would be used to log message for this event. /// - public virtual LogLevel LogLevel => _eventDefinition.Level; + public virtual LogLevel LogLevel + => _eventDefinition.Level; /// /// A string representing the code where this event is defined. /// - public virtual string EventIdCode => _eventDefinition.EventIdCode; + public virtual string EventIdCode + => _eventDefinition.EventIdCode; /// /// A logger message describing this event. /// /// A logger message describing this event. - public override string ToString() => _messageGenerator(_eventDefinition, this); + public override string ToString() + => _messageGenerator(_eventDefinition, this); } } diff --git a/src/EFCore/Diagnostics/EventDefinitionBase.cs b/src/EFCore/Diagnostics/EventDefinitionBase.cs index cc3ec0c0740..11150e259ca 100644 --- a/src/EFCore/Diagnostics/EventDefinitionBase.cs +++ b/src/EFCore/Diagnostics/EventDefinitionBase.cs @@ -85,9 +85,9 @@ protected virtual Exception WarningAsError([NotNull] string message) CoreStrings.WarningAsErrorTemplate(EventId.ToString(), message, EventIdCode)); /// - /// The configured . + /// The configured . /// - public virtual WarningBehavior WarningBehavior { get; } + public virtual WarningBehavior WarningBehavior { get; } internal sealed class MessageExtractingLogger : ILogger { @@ -109,9 +109,11 @@ void ILogger.Log( Message = formatter(state, exception); } - bool ILogger.IsEnabled(LogLevel logLevel) => true; + bool ILogger.IsEnabled(LogLevel logLevel) + => true; - IDisposable ILogger.BeginScope([CanBeNull] TState state) => throw new NotImplementedException(); + IDisposable ILogger.BeginScope([CanBeNull] TState state) + => throw new NotImplementedException(); } } } diff --git a/src/EFCore/Diagnostics/ForeignKeyCandidateEventData.cs b/src/EFCore/Diagnostics/ForeignKeyCandidateEventData.cs index 29c70cb6950..cbb49f78099 100644 --- a/src/EFCore/Diagnostics/ForeignKeyCandidateEventData.cs +++ b/src/EFCore/Diagnostics/ForeignKeyCandidateEventData.cs @@ -20,8 +20,14 @@ public class ForeignKeyCandidateEventData : TwoPropertyBaseCollectionsEventData /// /// The event definition. /// A delegate that generates a log message for this event. - /// The name of the navigation property or entity type on the dependent end of the relationship. - /// The name of the navigation property or entity type on the principal end of the relationship. + /// + /// The name of the navigation property or entity type on the dependent end of the + /// relationship. + /// + /// + /// The name of the navigation property or entity type on the principal end of the + /// relationship. + /// /// The first property collection. /// The second property collection. public ForeignKeyCandidateEventData( diff --git a/src/EFCore/Diagnostics/ICollectionChangedEventData.cs b/src/EFCore/Diagnostics/ICollectionChangedEventData.cs index 8cb43bea98a..a3dddbbe8fe 100644 --- a/src/EFCore/Diagnostics/ICollectionChangedEventData.cs +++ b/src/EFCore/Diagnostics/ICollectionChangedEventData.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics { /// /// An interface implemented by any subclass that represents a change to either - /// a skip collection navigation or a regular collection navigation. + /// a skip collection navigation or a regular collection navigation. /// public interface ICollectionChangedEventData { diff --git a/src/EFCore/Diagnostics/IDbContextLogger.cs b/src/EFCore/Diagnostics/IDbContextLogger.cs index 293eff64aaa..5c9343f8ed8 100644 --- a/src/EFCore/Diagnostics/IDbContextLogger.cs +++ b/src/EFCore/Diagnostics/IDbContextLogger.cs @@ -33,7 +33,7 @@ public interface IDbContextLogger /// /// The ID of the event. /// The level of the event. - /// Returns if the event should be logged; if it should be filtered out. + /// Returns if the event should be logged; if it should be filtered out. bool ShouldLog(EventId eventId, LogLevel logLevel); } } diff --git a/src/EFCore/Diagnostics/IDiagnosticsLogger.cs b/src/EFCore/Diagnostics/IDiagnosticsLogger.cs index 6b63cced80c..c6590a86fe8 100644 --- a/src/EFCore/Diagnostics/IDiagnosticsLogger.cs +++ b/src/EFCore/Diagnostics/IDiagnosticsLogger.cs @@ -61,10 +61,13 @@ public interface IDiagnosticsLogger IInterceptors Interceptors { get; } /// - /// Checks whether or not the message should be sent to the . + /// Checks whether or not the message should be sent to the . /// /// The definition of the event to log. - /// if logging is enabled and the event should not be ignored; otherwise. + /// + /// if logging is enabled and the event should not be ignored; + /// otherwise. + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] // Because hot path for logging bool ShouldLog([NotNull] EventDefinitionBase definition) // No null checks; low-level code in hot path for logging. @@ -78,8 +81,8 @@ bool ShouldLog([NotNull] EventDefinitionBase definition) /// /// The definition of the event to log. /// The event data. - /// True to dispatch to a ; otherwise. - /// True to dispatch to a ; otherwise. + /// True to dispatch to a ; otherwise. + /// True to dispatch to a ; otherwise. [MethodImpl(MethodImplOptions.AggressiveInlining)] // Because hot path for logging void DispatchEventData( [NotNull] EventDefinitionBase definition, @@ -106,9 +109,15 @@ void DispatchEventData( /// the given event. /// /// The definition of the event. - /// Set to if a is enabled; otherwise. - /// True to if a is enabled; otherwise. - /// if either a diagnostic source or a LogTo logger is enabled; otherwise. + /// + /// Set to if a is enabled; + /// otherwise. + /// + /// + /// True to if a is enabled; + /// otherwise. + /// + /// if either a diagnostic source or a LogTo logger is enabled; otherwise. [MethodImpl(MethodImplOptions.AggressiveInlining)] // Because hot path for logging bool NeedsEventData( [NotNull] EventDefinitionBase definition, @@ -133,9 +142,18 @@ bool NeedsEventData( /// /// The definition of the event. /// The to use if enabled; otherwise null. - /// Set to if a is enabled; otherwise. - /// True to if a is enabled; otherwise. - /// if either a diagnostic source, a LogTo logger, or an interceptor is enabled; otherwise. + /// + /// Set to if a is enabled; + /// otherwise. + /// + /// + /// True to if a is enabled; + /// otherwise. + /// + /// + /// if either a diagnostic source, a LogTo logger, or an interceptor is enabled; + /// otherwise. + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] // Because hot path for logging bool NeedsEventData( [NotNull] EventDefinitionBase definition, diff --git a/src/EFCore/Diagnostics/INavigationBaseEventData.cs b/src/EFCore/Diagnostics/INavigationBaseEventData.cs index dee078264ba..39a53002a39 100644 --- a/src/EFCore/Diagnostics/INavigationBaseEventData.cs +++ b/src/EFCore/Diagnostics/INavigationBaseEventData.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics { /// - /// A common interface for event payload classes that have an . + /// A common interface for event payload classes that have an . /// public interface INavigationBaseEventData { diff --git a/src/EFCore/Diagnostics/ISaveChangesInterceptor.cs b/src/EFCore/Diagnostics/ISaveChangesInterceptor.cs index 7749bc446af..c3788816be3 100644 --- a/src/EFCore/Diagnostics/ISaveChangesInterceptor.cs +++ b/src/EFCore/Diagnostics/ISaveChangesInterceptor.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics { /// /// - /// Allows interception of the and methods. + /// Allows interception of the and methods. /// /// /// Command interceptors can be used to view, change, or suppress execution of the SaveChanges call and @@ -33,10 +33,10 @@ public interface ISaveChangesInterceptor : IInterceptor /// /// Called at the start of . /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// Represents the current result if one exists. - /// This value will have set to if some previous + /// This value will have set to if some previous /// interceptor suppressed execution by calling . /// This value is typically used as the return value for the implementation of this method. /// @@ -60,7 +60,7 @@ InterceptionResult SavingChanges( /// In this case, is the result returned by . /// /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// The result of the call to . /// This value is typically used as the return value for the implementation of this method. @@ -75,7 +75,7 @@ int SavedChanges( int result); /// - /// Called when an exception has been thrown in . + /// Called when an exception has been thrown in . /// /// Contextual information about the failure. void SaveChangesFailed( @@ -84,10 +84,10 @@ void SaveChangesFailed( /// /// Called at the start of . /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// Represents the current result if one exists. - /// This value will have set to if some previous + /// This value will have set to if some previous /// interceptor suppressed execution by calling . /// This value is typically used as the return value for the implementation of this method. /// @@ -113,7 +113,7 @@ ValueTask> SavingChangesAsync( /// In this case, is the result returned by . /// /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// The result of the call to . /// This value is typically used as the return value for the implementation of this method. @@ -129,9 +129,8 @@ ValueTask SavedChangesAsync( int result, CancellationToken cancellationToken = default); - /// - /// Called when an exception has been thrown in . + /// Called when an exception has been thrown in . /// /// Contextual information about the failure. /// The cancellation token. diff --git a/src/EFCore/Diagnostics/InterceptionResult.cs b/src/EFCore/Diagnostics/InterceptionResult.cs index 0b3ddab75f3..a789c3dbcd0 100644 --- a/src/EFCore/Diagnostics/InterceptionResult.cs +++ b/src/EFCore/Diagnostics/InterceptionResult.cs @@ -22,9 +22,11 @@ public readonly struct InterceptionResult /// Creates a new instance indicating that /// execution should be suppressed. /// - public static InterceptionResult Suppress() => new InterceptionResult(true); + public static InterceptionResult Suppress() + => new InterceptionResult(true); - private InterceptionResult(bool suppress) => IsSuppressed = suppress; + private InterceptionResult(bool suppress) + => IsSuppressed = suppress; /// /// If true, then interception is suppressed. diff --git a/src/EFCore/Diagnostics/InterceptionResult`.cs b/src/EFCore/Diagnostics/InterceptionResult`.cs index 75e894a07e9..1e1994e26b8 100644 --- a/src/EFCore/Diagnostics/InterceptionResult`.cs +++ b/src/EFCore/Diagnostics/InterceptionResult`.cs @@ -48,7 +48,7 @@ private InterceptionResult(TResult result) /// is the same as and /// /// - /// when is . + /// when is . public TResult Result { get diff --git a/src/EFCore/Diagnostics/InterceptorAggregator.cs b/src/EFCore/Diagnostics/InterceptorAggregator.cs index fc30a5c1ad8..2ddcceda03c 100644 --- a/src/EFCore/Diagnostics/InterceptorAggregator.cs +++ b/src/EFCore/Diagnostics/InterceptorAggregator.cs @@ -22,7 +22,8 @@ public abstract class InterceptorAggregator : IInterceptorAggregat /// /// The interceptor type. /// - public virtual Type InterceptorType => typeof(TInterceptor); + public virtual Type InterceptorType + => typeof(TInterceptor); /// /// diff --git a/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs b/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs index a9f9cb5ed16..69cb148f587 100644 --- a/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs +++ b/src/EFCore/Diagnostics/Internal/FormattingDbContextLogger.cs @@ -109,7 +109,8 @@ public virtual void Log(EventData eventData) : messageBuilder .AppendLine() .Append(message) - .Replace(Environment.NewLine, Environment.NewLine + padding, preambleLength, messageBuilder.Length - preambleLength) + .Replace( + Environment.NewLine, Environment.NewLine + padding, preambleLength, messageBuilder.Length - preambleLength) .ToString(); } } diff --git a/src/EFCore/Diagnostics/Internal/NullDbContextLogger.cs b/src/EFCore/Diagnostics/Internal/NullDbContextLogger.cs index 036e99b0cd2..03fa2205b8f 100644 --- a/src/EFCore/Diagnostics/Internal/NullDbContextLogger.cs +++ b/src/EFCore/Diagnostics/Internal/NullDbContextLogger.cs @@ -29,6 +29,7 @@ public virtual void Log(EventData eventData) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual bool ShouldLog(EventId eventId, LogLevel logLevel) => false; + public virtual bool ShouldLog(EventId eventId, LogLevel logLevel) + => false; } } diff --git a/src/EFCore/Diagnostics/Internal/SaveChangesInterceptorAggregator.cs b/src/EFCore/Diagnostics/Internal/SaveChangesInterceptorAggregator.cs index a1f94309ed7..26dac767328 100644 --- a/src/EFCore/Diagnostics/Internal/SaveChangesInterceptorAggregator.cs +++ b/src/EFCore/Diagnostics/Internal/SaveChangesInterceptorAggregator.cs @@ -63,7 +63,9 @@ public void SaveChangesFailed(DbContextErrorEventData eventData) } public async ValueTask> SavingChangesAsync( - DbContextEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) + DbContextEventData eventData, + InterceptionResult result, + CancellationToken cancellationToken = default) { for (var i = 0; i < _interceptors.Length; i++) { @@ -74,7 +76,9 @@ public async ValueTask> SavingChangesAsync( } public async ValueTask SavedChangesAsync( - SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default) + SaveChangesCompletedEventData eventData, + int result, + CancellationToken cancellationToken = default) { for (var i = 0; i < _interceptors.Length; i++) { @@ -85,7 +89,8 @@ public async ValueTask SavedChangesAsync( } public async Task SaveChangesFailedAsync( - DbContextErrorEventData eventData, CancellationToken cancellationToken = default) + DbContextErrorEventData eventData, + CancellationToken cancellationToken = default) { for (var i = 0; i < _interceptors.Length; i++) { diff --git a/src/EFCore/Diagnostics/LoggerCategory.cs b/src/EFCore/Diagnostics/LoggerCategory.cs index d18228b6485..8c0345d2540 100644 --- a/src/EFCore/Diagnostics/LoggerCategory.cs +++ b/src/EFCore/Diagnostics/LoggerCategory.cs @@ -23,13 +23,15 @@ public abstract class LoggerCategory /// The logger category name. /// /// The logger category name. - public override string ToString() => Name; + public override string ToString() + => Name; /// /// The logger category name. /// /// The category. - public static implicit operator string([NotNull] LoggerCategory loggerCategory) => loggerCategory.ToString(); + public static implicit operator string([NotNull] LoggerCategory loggerCategory) + => loggerCategory.ToString(); private static string ToName(Type loggerCategoryType) { diff --git a/src/EFCore/Diagnostics/NavigationBaseEventData.cs b/src/EFCore/Diagnostics/NavigationBaseEventData.cs index 6984438a4aa..f958891c99a 100644 --- a/src/EFCore/Diagnostics/NavigationBaseEventData.cs +++ b/src/EFCore/Diagnostics/NavigationBaseEventData.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics { /// - /// A event payload class for events that have an . + /// A event payload class for events that have an . /// public class NavigationBaseEventData : EventData, INavigationBaseEventData { diff --git a/src/EFCore/Diagnostics/NavigationEventData.cs b/src/EFCore/Diagnostics/NavigationEventData.cs index 49d911cd7f4..2d3c36e4ad4 100644 --- a/src/EFCore/Diagnostics/NavigationEventData.cs +++ b/src/EFCore/Diagnostics/NavigationEventData.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics { /// - /// A event payload class for events that have an . + /// A event payload class for events that have an . /// public class NavigationEventData : EventData, INavigationBaseEventData { @@ -36,6 +36,7 @@ public NavigationEventData( /// /// The navigation. /// - INavigationBase INavigationBaseEventData.NavigationBase => Navigation; + INavigationBase INavigationBaseEventData.NavigationBase + => Navigation; } } diff --git a/src/EFCore/Diagnostics/SaveChangesInterceptor.cs b/src/EFCore/Diagnostics/SaveChangesInterceptor.cs index d56889daef8..84069d77fa3 100644 --- a/src/EFCore/Diagnostics/SaveChangesInterceptor.cs +++ b/src/EFCore/Diagnostics/SaveChangesInterceptor.cs @@ -17,10 +17,10 @@ public abstract class SaveChangesInterceptor : ISaveChangesInterceptor /// /// Called at the start of . /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// Represents the current result if one exists. - /// This value will have set to if some previous + /// This value will have set to if some previous /// interceptor suppressed execution by calling . /// This value is typically used as the return value for the implementation of this method. /// @@ -39,11 +39,12 @@ public virtual InterceptionResult SavingChanges(DbContextEventData eventDat /// Called at the end of . /// /// - /// This method is still called if an interceptor suppressed creation of a command in . + /// This method is still called if an interceptor suppressed creation of a command in + /// . /// In this case, is the result returned by . /// /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// The result of the call to . /// This value is typically used as the return value for the implementation of this method. @@ -57,7 +58,7 @@ public virtual int SavedChanges(SaveChangesCompletedEventData eventData, int res => result; /// - /// Called when an exception has been thrown in . + /// Called when an exception has been thrown in . /// /// Contextual information about the failure. public virtual void SaveChangesFailed(DbContextErrorEventData eventData) @@ -67,10 +68,10 @@ public virtual void SaveChangesFailed(DbContextErrorEventData eventData) /// /// Called at the start of . /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// Represents the current result if one exists. - /// This value will have set to if some previous + /// This value will have set to if some previous /// interceptor suppressed execution by calling . /// This value is typically used as the return value for the implementation of this method. /// @@ -93,11 +94,12 @@ public virtual ValueTask> SavingChangesAsync( /// Called at the end of . /// /// - /// This method is still called if an interceptor suppressed creation of a command in . + /// This method is still called if an interceptor suppressed creation of a command in + /// . /// In this case, is the result returned by . /// /// - /// Contextual information about the being used. + /// Contextual information about the being used. /// /// The result of the call to . /// This value is typically used as the return value for the implementation of this method. @@ -115,7 +117,7 @@ public virtual ValueTask SavedChangesAsync( => new ValueTask(result); /// - /// Called when an exception has been thrown in . + /// Called when an exception has been thrown in . /// /// Contextual information about the failure. /// The cancellation token. diff --git a/src/EFCore/Diagnostics/SkipNavigationEventData.cs b/src/EFCore/Diagnostics/SkipNavigationEventData.cs index 0e1fb208d78..968f8c29c1d 100644 --- a/src/EFCore/Diagnostics/SkipNavigationEventData.cs +++ b/src/EFCore/Diagnostics/SkipNavigationEventData.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Diagnostics { /// - /// A event payload class for events that have an . + /// A event payload class for events that have an . /// public class SkipNavigationEventData : EventData, INavigationBaseEventData { @@ -36,6 +36,7 @@ public SkipNavigationEventData( /// /// The navigation. /// - INavigationBase INavigationBaseEventData.NavigationBase => Navigation; + INavigationBase INavigationBaseEventData.NavigationBase + => Navigation; } } diff --git a/src/EFCore/Diagnostics/WarningsConfiguration.cs b/src/EFCore/Diagnostics/WarningsConfiguration.cs index ff70af7d546..7832bbe80e2 100644 --- a/src/EFCore/Diagnostics/WarningsConfiguration.cs +++ b/src/EFCore/Diagnostics/WarningsConfiguration.cs @@ -49,12 +49,14 @@ protected WarningsConfiguration([NotNull] WarningsConfiguration copyFrom) /// Override this method in a derived class to ensure that any clone created is also of that class. /// /// A clone of this instance, which can be modified before being returned as immutable. - protected virtual WarningsConfiguration Clone() => new WarningsConfiguration(this); + protected virtual WarningsConfiguration Clone() + => new WarningsConfiguration(this); /// /// The option set from the method. /// - public virtual WarningBehavior DefaultBehavior => _defaultBehavior; + public virtual WarningBehavior DefaultBehavior + => _defaultBehavior; /// /// Creates a new instance with all options the same as for this instance, but with the given option changed. @@ -80,7 +82,8 @@ public virtual WarningsConfiguration WithDefaultBehavior(WarningBehavior warning /// The behavior to set. /// A new instance with the behaviors set. public virtual WarningsConfiguration WithExplicit( - [NotNull] IEnumerable eventIds, WarningBehavior warningBehavior) + [NotNull] IEnumerable eventIds, + WarningBehavior warningBehavior) { var clone = Clone(); @@ -134,7 +137,7 @@ public virtual WarningsConfiguration WithExplicit( : null; /// - /// Gets the set for the given event ID, or + /// Gets the set for the given event ID, or /// if no explicit behavior has been set. /// /// The set for the given event ID. diff --git a/src/EFCore/Extensions/ConventionAnnotatableExtensions.cs b/src/EFCore/Extensions/ConventionAnnotatableExtensions.cs index f65f9d6a627..7638e690294 100644 --- a/src/EFCore/Extensions/ConventionAnnotatableExtensions.cs +++ b/src/EFCore/Extensions/ConventionAnnotatableExtensions.cs @@ -22,7 +22,8 @@ public static class ConventionAnnotatableExtensions /// The key of the annotation to find. /// The annotation with the specified name. public static IConventionAnnotation GetAnnotation( - [NotNull] this IConventionAnnotatable annotatable, [NotNull] string annotationName) + [NotNull] this IConventionAnnotatable annotatable, + [NotNull] string annotationName) => (IConventionAnnotation)((IAnnotatable)annotatable).GetAnnotation(annotationName); /// diff --git a/src/EFCore/Extensions/ConventionEntityTypeExtensions.cs b/src/EFCore/Extensions/ConventionEntityTypeExtensions.cs index 0ad132b0c7c..dd9ce0d576f 100644 --- a/src/EFCore/Extensions/ConventionEntityTypeExtensions.cs +++ b/src/EFCore/Extensions/ConventionEntityTypeExtensions.cs @@ -259,7 +259,8 @@ public static IEnumerable GetDerivedForeignKeys([NotNull] /// The property to find the foreign keys on. /// The foreign keys. public static IEnumerable FindForeignKeys( - [NotNull] this IConventionEntityType entityType, [NotNull] IProperty property) + [NotNull] this IConventionEntityType entityType, + [NotNull] IProperty property) => entityType.FindForeignKeys(new[] { property }); /// @@ -270,7 +271,8 @@ public static IEnumerable FindForeignKeys( /// The properties to find the foreign keys on. /// The foreign keys. public static IEnumerable FindForeignKeys( - [NotNull] this IConventionEntityType entityType, [NotNull] IReadOnlyList properties) + [NotNull] this IConventionEntityType entityType, + [NotNull] IReadOnlyList properties) => ((EntityType)entityType).FindForeignKeys(properties); /// @@ -382,7 +384,8 @@ public static IConventionForeignKey RemoveForeignKey( /// The navigation property on the entity class. /// The navigation property, or if none is found. public static IConventionNavigation FindNavigation( - [NotNull] this IConventionEntityType entityType, [NotNull] MemberInfo memberInfo) + [NotNull] this IConventionEntityType entityType, + [NotNull] MemberInfo memberInfo) => Check.NotNull(entityType, nameof(entityType)) .FindNavigation(Check.NotNull(memberInfo, nameof(memberInfo)).GetSimpleMemberName()); @@ -492,7 +495,8 @@ public static IConventionProperty AddProperty( /// Indicates whether the configuration was specified using a data annotation. /// The newly created property. public static IConventionProperty AddProperty( - [NotNull] this IConventionEntityType entityType, [NotNull] string name, + [NotNull] this IConventionEntityType entityType, + [NotNull] string name, bool fromDataAnnotation = false) => ((EntityType)entityType).AddProperty( name, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -507,8 +511,11 @@ public static IConventionProperty AddProperty( /// Indicates whether the configuration was specified using a data annotation. /// The newly created property. public static IConventionProperty AddProperty( - [NotNull] this IConventionEntityType entityType, [NotNull] string name, [NotNull] Type propertyType, - bool setTypeConfigurationSource = true, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [NotNull] string name, + [NotNull] Type propertyType, + bool setTypeConfigurationSource = true, + bool fromDataAnnotation = false) => ((EntityType)entityType).AddProperty( name, propertyType, @@ -527,8 +534,11 @@ public static IConventionProperty AddProperty( /// Indicates whether the configuration was specified using a data annotation. /// The newly created property. public static IConventionProperty AddIndexerProperty( - [NotNull] this IConventionEntityType entityType, [NotNull] string name, [NotNull] Type propertyType, - bool setTypeConfigurationSource = true, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [NotNull] string name, + [NotNull] Type propertyType, + bool setTypeConfigurationSource = true, + bool fromDataAnnotation = false) { Check.NotNull(entityType, nameof(entityType)); @@ -544,7 +554,7 @@ public static IConventionProperty AddIndexerProperty( /// /// - /// Gets the unnamed index defined on the given property. Returns if no such index is defined. + /// Gets the unnamed index defined on the given property. Returns if no such index is defined. /// /// /// Named indexes will not be returned even if the list of properties matches. @@ -673,7 +683,9 @@ public static IConventionProperty GetDiscriminatorProperty([NotNull] this IConve /// Indicates whether the configuration was specified using a data annotation. /// The discriminator property. public static IConventionProperty SetDiscriminatorProperty( - [NotNull] this IConventionEntityType entityType, [CanBeNull] IProperty property, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [CanBeNull] IProperty property, + bool fromDataAnnotation = false) => Check.NotNull(entityType, nameof(entityType)).AsEntityType() .SetDiscriminatorProperty( (Property)property, @@ -696,7 +708,9 @@ public static IConventionProperty SetDiscriminatorProperty( /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static bool? SetDiscriminatorMappingComplete( - [NotNull] this IConventionEntityType entityType, bool? complete, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + bool? complete, + bool fromDataAnnotation = false) { Check.NotNull(entityType, nameof(entityType)); @@ -710,7 +724,8 @@ public static IConventionProperty SetDiscriminatorProperty( /// /// The entity type. /// The or if discriminator completeness has not been set. - public static ConfigurationSource? GetDiscriminatorMappingCompleteConfigurationSource([NotNull] this IConventionEntityType entityType) + public static ConfigurationSource? GetDiscriminatorMappingCompleteConfigurationSource( + [NotNull] this IConventionEntityType entityType) => entityType.FindAnnotation(CoreAnnotationNames.DiscriminatorMappingComplete) ?.GetConfigurationSource(); @@ -722,7 +737,9 @@ public static IConventionProperty SetDiscriminatorProperty( /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static object SetDiscriminatorValue( - [NotNull] this IConventionEntityType entityType, [CanBeNull] object value, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [CanBeNull] object value, + bool fromDataAnnotation = false) { entityType.AsEntityType().CheckDiscriminatorValue(entityType, value); diff --git a/src/EFCore/Extensions/ConventionForeignKeyExtensions.cs b/src/EFCore/Extensions/ConventionForeignKeyExtensions.cs index af3ef7fa168..d040fb35112 100644 --- a/src/EFCore/Extensions/ConventionForeignKeyExtensions.cs +++ b/src/EFCore/Extensions/ConventionForeignKeyExtensions.cs @@ -19,7 +19,8 @@ public static class ConventionForeignKeyExtensions /// One of the entity types related by the foreign key. /// The entity type related to the given one. public static IConventionEntityType GetRelatedEntityType( - [NotNull] this IConventionForeignKey foreignKey, [NotNull] IConventionEntityType entityType) + [NotNull] this IConventionForeignKey foreignKey, + [NotNull] IConventionEntityType entityType) => (IConventionEntityType)((IForeignKey)foreignKey).GetRelatedEntityType(entityType); /// diff --git a/src/EFCore/Extensions/ConventionModelExtensions.cs b/src/EFCore/Extensions/ConventionModelExtensions.cs index 9ddccaccb12..392115faece 100644 --- a/src/EFCore/Extensions/ConventionModelExtensions.cs +++ b/src/EFCore/Extensions/ConventionModelExtensions.cs @@ -60,7 +60,8 @@ public static IReadOnlyCollection GetEntityTypes([NotNull /// The entity types found. [DebuggerStepThrough] public static IReadOnlyCollection GetEntityTypes( - [NotNull] this IConventionModel model, [NotNull] string name) + [NotNull] this IConventionModel model, + [NotNull] string name) => ((Model)model).GetEntityTypes(name); /// @@ -272,7 +273,8 @@ public static bool IsIgnored([NotNull] this IConventionModel model, [NotNull] Ty /// otherwise. /// public static ConfigurationSource? FindIgnoredConfigurationSource( - [NotNull] this IConventionModel model, [NotNull] Type type) + [NotNull] this IConventionModel model, + [NotNull] Type type) => Check.NotNull((Model)model, nameof(model)).FindIgnoredConfigurationSource( Check.NotNull(type, nameof(type))); @@ -318,6 +320,7 @@ public static void AddShared([NotNull] this IConventionModel model, [NotNull] Ty /// /// The model to finalize. /// The finalized . - public static IModel FinalizeModel([NotNull] this IConventionModel model) => ((Model)model).FinalizeModel(); + public static IModel FinalizeModel([NotNull] this IConventionModel model) + => ((Model)model).FinalizeModel(); } } diff --git a/src/EFCore/Extensions/ConventionPropertyExtensions.cs b/src/EFCore/Extensions/ConventionPropertyExtensions.cs index a1cc5af56bf..b551859f6a6 100644 --- a/src/EFCore/Extensions/ConventionPropertyExtensions.cs +++ b/src/EFCore/Extensions/ConventionPropertyExtensions.cs @@ -66,7 +66,7 @@ public static IEnumerable GetContainingIndexes([NotNull] this /// /// The property to get primary key for. /// - /// The primary that use this property, or if it is not part of the primary key. + /// The primary that use this property, or if it is not part of the primary key. /// public static IConventionKey FindContainingPrimaryKey([NotNull] this IConventionProperty property) => (IConventionKey)((IProperty)property).FindContainingPrimaryKey(); @@ -112,7 +112,9 @@ public static CoreTypeMapping SetTypeMapping( /// Indicates whether the configuration was specified using a data annotation. /// The configured property. public static int? SetMaxLength( - [NotNull] this IConventionProperty property, int? maxLength, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + int? maxLength, + bool fromDataAnnotation = false) => property.AsProperty().SetMaxLength( maxLength, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -169,12 +171,15 @@ public static CoreTypeMapping SetTypeMapping( /// /// The property to set the value for. /// - /// if the property accepts Unicode characters, if it does not, to clear the setting. + /// if the property accepts Unicode characters, if it does not, to + /// clear the setting. /// /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static bool? SetIsUnicode( - [NotNull] this IConventionProperty property, bool? unicode, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + bool? unicode, + bool fromDataAnnotation = false) => property.AsProperty().SetIsUnicode( unicode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -209,7 +214,9 @@ public static CoreTypeMapping SetTypeMapping( /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static PropertySaveBehavior? SetBeforeSaveBehavior( - [NotNull] this IConventionProperty property, PropertySaveBehavior? beforeSaveBehavior, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + PropertySaveBehavior? beforeSaveBehavior, + bool fromDataAnnotation = false) => property.AsProperty().SetBeforeSaveBehavior( beforeSaveBehavior, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -243,7 +250,9 @@ public static CoreTypeMapping SetTypeMapping( /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static PropertySaveBehavior? SetAfterSaveBehavior( - [NotNull] this IConventionProperty property, PropertySaveBehavior? afterSaveBehavior, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + PropertySaveBehavior? afterSaveBehavior, + bool fromDataAnnotation = false) => property.AsProperty().SetAfterSaveBehavior( afterSaveBehavior, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); diff --git a/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs b/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs index 4aaa204a249..70d6e552e44 100644 --- a/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs +++ b/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs @@ -36,7 +36,7 @@ public static class EntityFrameworkQueryableExtensions /// The query source. /// The query string for debugging. /// - /// is . + /// is . /// public static string ToQueryString([NotNull] this IQueryable source) { @@ -70,7 +70,7 @@ public static string ToQueryString([NotNull] this IQueryable source) /// The task result contains if the source sequence contains any elements; otherwise, . /// /// - /// is . + /// is . /// public static Task AnyAsync( [NotNull] this IQueryable source, @@ -104,7 +104,7 @@ public static Task AnyAsync( /// predicate; otherwise, . /// /// - /// or is . + /// or is . /// public static Task AnyAsync( [NotNull] this IQueryable source, @@ -140,7 +140,7 @@ public static Task AnyAsync( /// predicate; otherwise, . /// /// - /// or is . + /// or is . /// public static Task AllAsync( [NotNull] this IQueryable source, @@ -178,7 +178,7 @@ public static Task AllAsync( /// The task result contains the number of elements in the input sequence. /// /// - /// is . + /// is . /// public static Task CountAsync( [NotNull] this IQueryable source, @@ -212,7 +212,7 @@ public static Task CountAsync( /// function. /// /// - /// or is . + /// or is . /// public static Task CountAsync( [NotNull] this IQueryable source, @@ -246,7 +246,7 @@ public static Task CountAsync( /// The task result contains the number of elements in the input sequence. /// /// - /// is . + /// is . /// public static Task LongCountAsync( [NotNull] this IQueryable source, @@ -281,7 +281,7 @@ public static Task LongCountAsync( /// function. /// /// - /// or is . + /// or is . /// public static Task LongCountAsync( [NotNull] this IQueryable source, @@ -319,10 +319,10 @@ public static Task LongCountAsync( /// The task result contains the first element in . /// /// - /// is . + /// is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task FirstAsync( [NotNull] this IQueryable source, @@ -356,17 +356,17 @@ public static Task FirstAsync( /// . /// /// - /// or is . + /// or is . /// /// /// - /// No element satisfies the condition in + /// No element satisfies the condition in /// /// /// -or - /// /// - /// contains no elements. + /// contains no elements. /// /// public static Task FirstAsync( @@ -402,7 +402,7 @@ public static Task FirstAsync( /// is empty; otherwise, the first element in . /// /// - /// is . + /// is . /// public static Task FirstOrDefaultAsync( [NotNull] this IQueryable source, @@ -438,7 +438,7 @@ public static Task FirstOrDefaultAsync( /// element in that passes the test specified by . /// /// - /// or is . + /// or is . /// public static Task FirstOrDefaultAsync( [NotNull] this IQueryable source, @@ -476,10 +476,10 @@ public static Task FirstOrDefaultAsync( /// The task result contains the last element in . /// /// - /// is . + /// is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task LastAsync( [NotNull] this IQueryable source, @@ -513,17 +513,17 @@ public static Task LastAsync( /// . /// /// - /// or is . + /// or is . /// /// /// - /// No element satisfies the condition in . + /// No element satisfies the condition in . /// /// /// -or- /// /// - /// contains no elements. + /// contains no elements. /// /// public static Task LastAsync( @@ -559,7 +559,7 @@ public static Task LastAsync( /// is empty; otherwise, the last element in . /// /// - /// is . + /// is . /// public static Task LastOrDefaultAsync( [NotNull] this IQueryable source, @@ -595,7 +595,7 @@ public static Task LastOrDefaultAsync( /// element in that passes the test specified by . /// /// - /// or is . + /// or is . /// public static Task LastOrDefaultAsync( [NotNull] this IQueryable source, @@ -634,17 +634,17 @@ public static Task LastOrDefaultAsync( /// The task result contains the single element of the input sequence. /// /// - /// is . + /// is . /// /// /// - /// contains more than one elements. + /// contains more than one elements. /// /// /// -or- /// /// - /// contains no elements. + /// contains no elements. /// /// public static Task SingleAsync( @@ -680,23 +680,23 @@ public static Task SingleAsync( /// . /// /// - /// or is . + /// or is . /// /// /// - /// No element satisfies the condition in . + /// No element satisfies the condition in . /// /// /// -or- /// /// - /// More than one element satisfies the condition in . + /// More than one element satisfies the condition in . /// /// /// -or- /// /// - /// contains no elements. + /// contains no elements. /// /// public static Task SingleAsync( @@ -734,10 +734,10 @@ public static Task SingleAsync( /// if the sequence contains no elements. /// /// - /// is . + /// is . /// /// - /// contains more than one element. + /// contains more than one element. /// public static Task SingleOrDefaultAsync( [NotNull] this IQueryable source, @@ -773,10 +773,10 @@ public static Task SingleOrDefaultAsync( /// , or ( ) if no such element is found. /// /// - /// or is . + /// or is . /// /// - /// More than one element satisfies the condition in . + /// More than one element satisfies the condition in . /// public static Task SingleOrDefaultAsync( [NotNull] this IQueryable source, @@ -815,7 +815,7 @@ public static Task SingleOrDefaultAsync( /// The task result contains the minimum value in the sequence. /// /// - /// is . + /// is . /// public static Task MinAsync( [NotNull] this IQueryable source, @@ -851,7 +851,7 @@ public static Task MinAsync( /// The task result contains the minimum value in the sequence. /// /// - /// or is . + /// or is . /// public static Task MinAsync( [NotNull] this IQueryable source, @@ -889,7 +889,7 @@ public static Task MinAsync( /// The task result contains the maximum value in the sequence. /// /// - /// is . + /// is . /// public static Task MaxAsync( [NotNull] this IQueryable source, @@ -925,7 +925,7 @@ public static Task MaxAsync( /// The task result contains the maximum value in the sequence. /// /// - /// or is . + /// or is . /// public static Task MaxAsync( [NotNull] this IQueryable source, @@ -960,7 +960,7 @@ public static Task MaxAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -989,7 +989,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1021,7 +1021,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1055,7 +1055,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1087,7 +1087,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1116,7 +1116,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1147,7 +1147,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1180,7 +1180,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1212,7 +1212,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1241,7 +1241,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1272,7 +1272,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1306,7 +1306,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1338,7 +1338,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1367,7 +1367,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1398,7 +1398,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1432,7 +1432,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1464,7 +1464,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1493,7 +1493,7 @@ public static Task SumAsync( /// The task result contains the sum of the values in the sequence. /// /// - /// is . + /// is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1524,7 +1524,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1558,7 +1558,7 @@ public static Task SumAsync( /// The task result contains the sum of the projected values.. /// /// - /// or is . + /// or is . /// public static Task SumAsync( [NotNull] this IQueryable source, @@ -1594,10 +1594,10 @@ public static Task SumAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1627,7 +1627,7 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1660,10 +1660,10 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1698,7 +1698,7 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1730,10 +1730,10 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1762,7 +1762,7 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1794,10 +1794,10 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1832,7 +1832,7 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1864,10 +1864,10 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1896,7 +1896,7 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1928,10 +1928,10 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1966,7 +1966,7 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -1998,10 +1998,10 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2031,7 +2031,7 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2064,10 +2064,10 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2102,7 +2102,7 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2134,10 +2134,10 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2166,7 +2166,7 @@ public static Task AverageAsync( /// The task result contains the average of the sequence of values. /// /// - /// is . + /// is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2199,10 +2199,10 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// /// - /// contains no elements. + /// contains no elements. /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2237,7 +2237,7 @@ public static Task AverageAsync( /// The task result contains the average of the projected values. /// /// - /// or is . + /// or is . /// public static Task AverageAsync( [NotNull] this IQueryable source, @@ -2274,10 +2274,11 @@ public static Task AverageAsync( /// /// /// A task that represents the asynchronous operation. - /// The task result contains if the input sequence contains the specified value; otherwise, . + /// The task result contains if the input sequence contains the specified value; otherwise, + /// . /// /// - /// is . + /// is . /// public static Task ContainsAsync( [NotNull] this IQueryable source, @@ -2319,7 +2320,7 @@ public static Task ContainsAsync( /// The task result contains a that contains elements from the input sequence. /// /// - /// is . + /// is . /// public static async Task> ToListAsync( [NotNull] this IQueryable source, @@ -2355,7 +2356,7 @@ public static async Task> ToListAsync( /// The task result contains an array that contains elements from the input sequence. /// /// - /// is . + /// is . /// public static async Task ToArrayAsync( [NotNull] this IQueryable source, @@ -2422,7 +2423,7 @@ internal static readonly MethodInfo IncludeMethodInfo /// A new query with the related data included. /// /// - /// or is . + /// or is . /// public static IIncludableQueryable Include( [NotNull] this IQueryable source, @@ -2582,16 +2583,23 @@ public IncludableQueryable(IQueryable queryable) _queryable = queryable; } - public Expression Expression => _queryable.Expression; - public Type ElementType => _queryable.ElementType; - public IQueryProvider Provider => _queryable.Provider; + public Expression Expression + => _queryable.Expression; + + public Type ElementType + => _queryable.ElementType; + + public IQueryProvider Provider + => _queryable.Provider; public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => ((IAsyncEnumerable)_queryable).GetAsyncEnumerator(cancellationToken); - public IEnumerator GetEnumerator() => _queryable.GetEnumerator(); + public IEnumerator GetEnumerator() + => _queryable.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } internal static readonly MethodInfo StringIncludeMethodInfo @@ -2629,10 +2637,10 @@ internal static readonly MethodInfo StringIncludeMethodInfo /// A string of '.' separated navigation property names to be included. /// A new query with the related data included. /// - /// or is . + /// or is . /// - /// - /// is empty or whitespace. + /// + /// is empty or whitespace. /// public static IQueryable Include( [NotNull] this IQueryable source, @@ -2704,7 +2712,7 @@ internal static readonly MethodInfo IgnoreQueryFiltersMethodInfo /// A new query that will not apply any model-level entity query filters. /// /// - /// is . + /// is . /// public static IQueryable IgnoreQueryFilters( [NotNull] this IQueryable source) @@ -2756,7 +2764,7 @@ internal static readonly MethodInfo AsNoTrackingMethodInfo /// A new query where the result set will not be tracked by the context. /// /// - /// is . + /// is . /// public static IQueryable AsNoTracking( [NotNull] this IQueryable source) @@ -2804,7 +2812,7 @@ internal static readonly MethodInfo AsNoTrackingWithIdentityResolutionMethodInfo /// A new query where the result set will not be tracked by the context. /// /// - /// is . + /// is . /// public static IQueryable AsNoTrackingWithIdentityResolution( [NotNull] this IQueryable source) @@ -2844,7 +2852,7 @@ internal static readonly MethodInfo AsTrackingMethodInfo /// A new query where the result set will be tracked by the context. /// /// - /// is . + /// is . /// public static IQueryable AsTracking( [NotNull] this IQueryable source) @@ -2888,7 +2896,7 @@ source.Provider is EntityQueryProvider /// A new query where the result set will be tracked by the context. /// /// - /// is . + /// is . /// public static IQueryable AsTracking( [NotNull] this IQueryable source, @@ -2917,13 +2925,14 @@ internal static readonly MethodInfo TagWithMethodInfo /// A new query annotated with the given tag. /// /// - /// or is . + /// or is . /// /// - /// is empty or whitespace. + /// is empty or whitespace. /// public static IQueryable TagWith( - [NotNull] this IQueryable source, [NotNull] [NotParameterized] string tag) + [NotNull] this IQueryable source, + [NotNull] [NotParameterized] string tag) { Check.NotNull(source, nameof(source)); Check.NotEmpty(tag, nameof(tag)); @@ -2950,7 +2959,7 @@ source.Provider is EntityQueryProvider /// /// The source query. /// - /// is . + /// is . /// public static void Load([NotNull] this IQueryable source) { @@ -2973,10 +2982,11 @@ public static void Load([NotNull] this IQueryable source) /// /// A task that represents the asynchronous operation. /// - /// is . + /// is . /// public static async Task LoadAsync( - [NotNull] this IQueryable source, CancellationToken cancellationToken = default) + [NotNull] this IQueryable source, + CancellationToken cancellationToken = default) { Check.NotNull(source, nameof(source)); @@ -3019,7 +3029,7 @@ public static async Task LoadAsync( /// The task result contains a that contains selected keys and values. /// /// - /// or is . + /// or is . /// public static Task> ToDictionaryAsync( [NotNull] this IQueryable source, @@ -3057,7 +3067,7 @@ public static Task> ToDictionaryAsync( /// The task result contains a that contains selected keys and values. /// /// - /// or is . + /// or is . /// public static Task> ToDictionaryAsync( [NotNull] this IQueryable source, @@ -3098,7 +3108,7 @@ public static Task> ToDictionaryAsync( /// selected from the input sequence. /// /// - /// or or is . + /// or or is . /// public static Task> ToDictionaryAsync( [NotNull] this IQueryable source, @@ -3142,7 +3152,7 @@ public static Task> ToDictionaryAsync selected from the input sequence. /// /// - /// or or is . + /// or or is . /// public static async Task> ToDictionaryAsync( [NotNull] this IQueryable source, @@ -3187,7 +3197,7 @@ public static async Task> ToDictionaryAsync /// A task that represents the asynchronous operation. /// - /// or is . + /// or is . /// public static async Task ForEachAsync( [NotNull] this IQueryable source, @@ -3221,10 +3231,10 @@ public static async Task ForEachAsync( /// /// The query results. /// - /// is . + /// is . /// /// - /// is not a . + /// is not a . /// public static IAsyncEnumerable AsAsyncEnumerable( [NotNull] this IQueryable source) diff --git a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs index 4784e0dcf2e..d5bbd3d1436 100644 --- a/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs +++ b/src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs @@ -338,7 +338,8 @@ public static IServiceCollection AddDbContextPool( IServiceCollection serviceCollection, - Action optionsAction, int poolSize) + Action optionsAction, + int poolSize) where TContext : DbContext { if (poolSize <= 0) @@ -559,7 +560,7 @@ public static IServiceCollection AddDbContext /// /// Registers an in the to create instances - /// of given type. + /// of given type. /// /// /// Registering a factory instead of registering the context type directly allows for easy creation of new @@ -613,7 +614,7 @@ public static IServiceCollection AddDbContextFactory( /// /// /// Registers an in the to create instances - /// of given type. + /// of given type. /// /// /// Registering a factory instead of registering the context type directly allows for easy creation of new @@ -628,7 +629,7 @@ public static IServiceCollection AddDbContextFactory( /// overridden to configure a connection string and other options. /// /// - /// This overload allows a specific implementation of to be registered + /// This overload allows a specific implementation of to be registered /// instead of using the default factory shipped with EF Core. /// /// @@ -637,7 +638,7 @@ public static IServiceCollection AddDbContextFactory( /// /// /// The type of to be created by the factory. - /// The type of to register. + /// The type of to register. /// The to add services to. /// /// @@ -678,7 +679,7 @@ public static IServiceCollection AddDbContextFactory( /// /// /// Registers an in the to create instances - /// of given type. + /// of given type. /// /// /// Registering a factory instead of registering the context type directly allows for easy creation of new @@ -740,7 +741,7 @@ public static IServiceCollection AddDbContextFactory( /// /// /// Registers an in the to create instances - /// of given type. + /// of given type. /// /// /// Registering a factory instead of registering the context type directly allows for easy creation of new @@ -755,7 +756,7 @@ public static IServiceCollection AddDbContextFactory( /// overridden to configure a connection string and other options. /// /// - /// This overload allows a specific implementation of to be registered + /// This overload allows a specific implementation of to be registered /// instead of using the default factory shipped with EF Core. /// /// @@ -772,7 +773,7 @@ public static IServiceCollection AddDbContextFactory( /// /// /// The type of to be created by the factory. - /// The type of to register. + /// The type of to register. /// The to add services to. /// /// @@ -822,7 +823,7 @@ public static IServiceCollection AddDbContextFactory( /// /// /// Registers an in the to create instances - /// of given type where instances are pooled for reuse. + /// of given type where instances are pooled for reuse. /// /// /// Registering a factory instead of registering the context type directly allows for easy creation of new @@ -870,7 +871,7 @@ public static IServiceCollection AddPooledDbContextFactory( /// /// /// Registers an in the to create instances - /// of given type where instances are pooled for reuse. + /// of given type where instances are pooled for reuse. /// /// /// Registering a factory instead of registering the context type directly allows for easy creation of new diff --git a/src/EFCore/Extensions/EntityTypeExtensions.cs b/src/EFCore/Extensions/EntityTypeExtensions.cs index 658c2d15d6d..d54c422b1e0 100644 --- a/src/EFCore/Extensions/EntityTypeExtensions.cs +++ b/src/EFCore/Extensions/EntityTypeExtensions.cs @@ -130,7 +130,7 @@ public static bool IsAssignableFrom([NotNull] this IEntityType entityType, [NotN /// /// Returns the closest entity type that is a parent of both given entity types. If one of the given entities is - /// a parent of the other, that parent is returned. Returns if the two entity types aren't in the same hierarchy. + /// a parent of the other, that parent is returned. Returns if the two entity types aren't in the same hierarchy. /// /// An entity type. /// Another entity type. @@ -475,7 +475,8 @@ public static IEnumerable FindForeignKeys([NotNull] this IEntityTyp /// The properties to find the foreign keys on. /// The foreign keys. public static IEnumerable FindForeignKeys( - [NotNull] this IEntityType entityType, [NotNull] IReadOnlyList properties) + [NotNull] this IEntityType entityType, + [NotNull] IReadOnlyList properties) { Check.NotNull(entityType, nameof(entityType)); Check.NotEmpty(properties, nameof(properties)); @@ -673,7 +674,7 @@ public static IProperty FindDeclaredProperty([NotNull] this IEntityType entityTy /// /// - /// Gets the unnamed index defined on the given property. Returns if no such index is defined. + /// Gets the unnamed index defined on the given property. Returns if no such index is defined. /// /// /// Named indexes will not be returned even if the list of properties matches. @@ -710,7 +711,8 @@ public static ChangeTrackingStrategy GetChangeTrackingStrategy([NotNull] this IE /// If true, then provider values are used. /// The data. public static IEnumerable> GetSeedData( - [NotNull] this IEntityType entityType, bool providerValues = false) + [NotNull] this IEntityType entityType, + bool providerValues = false) => entityType.AsEntityType().GetSeedData(providerValues); /// @@ -762,7 +764,8 @@ public static bool GetIsDiscriminatorMappingComplete([NotNull] this IEntityType => (bool?)entityType[CoreAnnotationNames.DiscriminatorMappingComplete] ?? GetDefaultIsDiscriminatorMappingComplete(entityType); - private static bool GetDefaultIsDiscriminatorMappingComplete(IEntityType entityType) => true; + private static bool GetDefaultIsDiscriminatorMappingComplete(IEntityType entityType) + => true; /// /// Returns the discriminator value for this entity type. diff --git a/src/EFCore/Extensions/ForeignKeyExtensions.cs b/src/EFCore/Extensions/ForeignKeyExtensions.cs index 55d20168044..840212f126b 100644 --- a/src/EFCore/Extensions/ForeignKeyExtensions.cs +++ b/src/EFCore/Extensions/ForeignKeyExtensions.cs @@ -149,8 +149,7 @@ public static string ToDebugString( .Append(foreignKey.DeleteBehavior); } - if (!singleLine && - (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) + if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(foreignKey.AnnotationsToDebugString(indent + 2)); } diff --git a/src/EFCore/Extensions/IndexExtensions.cs b/src/EFCore/Extensions/IndexExtensions.cs index 294657802b4..fce38e621c5 100644 --- a/src/EFCore/Extensions/IndexExtensions.cs +++ b/src/EFCore/Extensions/IndexExtensions.cs @@ -69,8 +69,7 @@ public static string ToDebugString( ? p.DeclaringEntityType.DisplayName() + "." + p.Name : p.Name)); - builder.Append(" " + - index.Name ?? ""); + builder.Append(" " + index.Name ?? ""); if (index.IsUnique) { diff --git a/src/EFCore/Extensions/Internal/ExpressionExtensions.cs b/src/EFCore/Extensions/Internal/ExpressionExtensions.cs index fb35693710d..541de45367b 100644 --- a/src/EFCore/Extensions/Internal/ExpressionExtensions.cs +++ b/src/EFCore/Extensions/Internal/ExpressionExtensions.cs @@ -30,7 +30,8 @@ public static class ExpressionExtensions /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static Expression MakeHasDefaultValue( - [NotNull] this Expression currentValueExpression, [NotNull] IPropertyBase propertyBase) + [NotNull] this Expression currentValueExpression, + [NotNull] IPropertyBase propertyBase) { if (!currentValueExpression.Type.IsValueType) { @@ -66,11 +67,14 @@ public static Expression MakeHasDefaultValue( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static IReadOnlyList MatchMemberAccessList( - [NotNull] this LambdaExpression lambdaExpression, [NotNull] Func memberMatcher) + [NotNull] this LambdaExpression lambdaExpression, + [NotNull] Func memberMatcher) where TMemberInfo : MemberInfo { Check.DebugAssert(lambdaExpression.Body != null, "lambdaExpression.Body is null"); - Check.DebugAssert(lambdaExpression.Parameters.Count == 1, "lambdaExpression.Parameters.Count is " + lambdaExpression.Parameters.Count + ". Should be 1."); + Check.DebugAssert( + lambdaExpression.Parameters.Count == 1, + "lambdaExpression.Parameters.Count is " + lambdaExpression.Parameters.Count + ". Should be 1."); var parameterExpression = lambdaExpression.Parameters[0]; @@ -98,16 +102,18 @@ var memberInfos /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static TMemberInfo MatchSimpleMemberAccess( - [NotNull] this Expression parameterExpression, [NotNull] Expression memberAccessExpression) + [NotNull] this Expression parameterExpression, + [NotNull] Expression memberAccessExpression) where TMemberInfo : MemberInfo { var memberInfos = MatchMemberAccess(parameterExpression, memberAccessExpression); - return memberInfos?.Count == 1 ? memberInfos[0] as TMemberInfo : null; + return memberInfos?.Count == 1 ? memberInfos[0] : null; } private static IReadOnlyList MatchMemberAccess( - this Expression parameterExpression, Expression memberAccessExpression) + this Expression parameterExpression, + Expression memberAccessExpression) where TMemberInfo : MemberInfo { var memberInfos = new List(); @@ -224,34 +230,36 @@ public static Expression BuildPredicate( return predicate; static Expression GenerateEqualExpression( - Expression entityParameterExpression, Expression keyValuesConstantExpression, IProperty property, int i) + Expression entityParameterExpression, + Expression keyValuesConstantExpression, + IProperty property, + int i) => property.ClrType.IsValueType && property.ClrType.UnwrapNullableType() is Type nonNullableType && !(nonNullableType == typeof(bool) || nonNullableType.IsNumeric() || nonNullableType.IsEnum) - ? Expression.Call( - _objectEqualsMethodInfo, - Expression.Call( - EF.PropertyMethod.MakeGenericMethod(typeof(object)), - entityParameterExpression, - Expression.Constant(property.Name, typeof(string))), - Expression.Convert( + ? Expression.Call( + _objectEqualsMethodInfo, Expression.Call( - keyValuesConstantExpression, - ValueBuffer.GetValueMethod, - Expression.Constant(i)), - typeof(object))) - : (Expression)Expression.Equal( - Expression.Call( - EF.PropertyMethod.MakeGenericMethod(property.ClrType), - entityParameterExpression, - Expression.Constant(property.Name, typeof(string))), - Expression.Convert( + EF.PropertyMethod.MakeGenericMethod(typeof(object)), + entityParameterExpression, + Expression.Constant(property.Name, typeof(string))), + Expression.Convert( + Expression.Call( + keyValuesConstantExpression, + ValueBuffer.GetValueMethod, + Expression.Constant(i)), + typeof(object))) + : (Expression)Expression.Equal( Expression.Call( - keyValuesConstantExpression, - ValueBuffer.GetValueMethod, - Expression.Constant(i)), - property.ClrType)); + EF.PropertyMethod.MakeGenericMethod(property.ClrType), + entityParameterExpression, + Expression.Constant(property.Name, typeof(string))), + Expression.Convert( + Expression.Call( + keyValuesConstantExpression, + ValueBuffer.GetValueMethod, + Expression.Constant(i)), + property.ClrType)); } - } } diff --git a/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs b/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs index ebf622e6036..9b96d7a74bb 100644 --- a/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs +++ b/src/EFCore/Extensions/Internal/MethodInfoExtensions.cs @@ -24,7 +24,8 @@ public static class MethodInfoExtensions /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static bool MethodIsClosedFormOf( - [NotNull] this MethodInfo methodInfo, [NotNull] MethodInfo genericMethod) + [NotNull] this MethodInfo methodInfo, + [NotNull] MethodInfo genericMethod) => methodInfo.IsGenericMethod && Equals( methodInfo.GetGenericMethodDefinition(), diff --git a/src/EFCore/Extensions/Internal/TypeExtensions.cs b/src/EFCore/Extensions/Internal/TypeExtensions.cs index 81a3ed361c9..48112e7e26a 100644 --- a/src/EFCore/Extensions/Internal/TypeExtensions.cs +++ b/src/EFCore/Extensions/Internal/TypeExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; @@ -63,7 +62,8 @@ public static PropertyInfo FindIndexerProperty([NotNull] this Type type) return defaultPropertyAttribute == null ? null - : type.GetRuntimeProperties().FirstOrDefault(pi => pi.Name == defaultPropertyAttribute.MemberName && pi.IsIndexerProperty()); + : type.GetRuntimeProperties() + .FirstOrDefault(pi => pi.Name == defaultPropertyAttribute.MemberName && pi.IsIndexerProperty()); } } } diff --git a/src/EFCore/Extensions/KeyExtensions.cs b/src/EFCore/Extensions/KeyExtensions.cs index e73a6003e4c..7a48b94cf0b 100644 --- a/src/EFCore/Extensions/KeyExtensions.cs +++ b/src/EFCore/Extensions/KeyExtensions.cs @@ -99,14 +99,12 @@ public static string ToDebugString( builder.Append(" PK"); } - if (!singleLine && - (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) + if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(key.AnnotationsToDebugString(indent + 2)); } return builder.ToString(); } - } } diff --git a/src/EFCore/Extensions/ModelExtensions.cs b/src/EFCore/Extensions/ModelExtensions.cs index a82f4994604..90386515e27 100644 --- a/src/EFCore/Extensions/ModelExtensions.cs +++ b/src/EFCore/Extensions/ModelExtensions.cs @@ -172,7 +172,7 @@ public static string GetProductVersion([NotNull] this IModel model) /// The model to use. /// The MethodInfo to check for. public static bool IsIndexerMethod([NotNull] this IModel model, [NotNull] MethodInfo methodInfo) - => !methodInfo.IsStatic + => !methodInfo.IsStatic && methodInfo.IsSpecialName && model.AsModel().FindIndexerPropertyInfo(methodInfo.DeclaringType) is PropertyInfo indexerProperty && (methodInfo == indexerProperty.GetMethod || methodInfo == indexerProperty.SetMethod); diff --git a/src/EFCore/Extensions/MutableEntityTypeExtensions.cs b/src/EFCore/Extensions/MutableEntityTypeExtensions.cs index b56814b31b5..dea33f837d4 100644 --- a/src/EFCore/Extensions/MutableEntityTypeExtensions.cs +++ b/src/EFCore/Extensions/MutableEntityTypeExtensions.cs @@ -180,7 +180,8 @@ public static IMutableKey FindKey([NotNull] this IMutableEntityType entityType, /// The property to use as an alternate key. /// The newly created key. public static IMutableKey AddKey( - [NotNull] this IMutableEntityType entityType, [NotNull] IMutableProperty property) + [NotNull] this IMutableEntityType entityType, + [NotNull] IMutableProperty property) => Check.NotNull(entityType, nameof(entityType)).AddKey(new[] { property }); /// @@ -190,7 +191,8 @@ public static IMutableKey AddKey( /// The properties that make up the key. /// The key that was removed. public static IMutableKey RemoveKey( - [NotNull] this IMutableEntityType entityType, [NotNull] IReadOnlyList properties) + [NotNull] this IMutableEntityType entityType, + [NotNull] IReadOnlyList properties) => ((EntityType)entityType).RemoveKey(properties); /// @@ -231,7 +233,8 @@ public static IEnumerable GetDerivedForeignKeys([NotNull] th /// The property to find the foreign keys on. /// The foreign keys. public static IEnumerable FindForeignKeys( - [NotNull] this IMutableEntityType entityType, [NotNull] IProperty property) + [NotNull] this IMutableEntityType entityType, + [NotNull] IProperty property) => entityType.FindForeignKeys(new[] { property }); /// @@ -242,7 +245,8 @@ public static IEnumerable FindForeignKeys( /// The properties to find the foreign keys on. /// The foreign keys. public static IEnumerable FindForeignKeys( - [NotNull] this IMutableEntityType entityType, [NotNull] IReadOnlyList properties) + [NotNull] this IMutableEntityType entityType, + [NotNull] IReadOnlyList properties) => ((EntityType)entityType).FindForeignKeys(properties); /// @@ -355,7 +359,8 @@ public static IMutableForeignKey RemoveForeignKey( /// The navigation property on the entity class. /// The navigation property, or if none is found. public static IMutableNavigation FindNavigation( - [NotNull] this IMutableEntityType entityType, [NotNull] MemberInfo memberInfo) + [NotNull] this IMutableEntityType entityType, + [NotNull] MemberInfo memberInfo) => Check.NotNull(entityType, nameof(entityType)) .FindNavigation(Check.NotNull(memberInfo, nameof(memberInfo)).GetSimpleMemberName()); @@ -447,7 +452,8 @@ public static IMutableProperty FindDeclaredProperty([NotNull] this IMutableEntit /// The corresponding member on the entity class. /// The newly created property. public static IMutableProperty AddProperty( - [NotNull] this IMutableEntityType entityType, [NotNull] MemberInfo memberInfo) + [NotNull] this IMutableEntityType entityType, + [NotNull] MemberInfo memberInfo) => Check.NotNull(entityType, nameof(entityType)) .AddProperty(memberInfo.GetSimpleMemberName(), memberInfo.GetMemberType(), memberInfo); @@ -458,7 +464,8 @@ public static IMutableProperty AddProperty( /// The name of the property to add. /// The newly created property. public static IMutableProperty AddProperty( - [NotNull] this IMutableEntityType entityType, [NotNull] string name) + [NotNull] this IMutableEntityType entityType, + [NotNull] string name) => ((EntityType)entityType).AddProperty(name, ConfigurationSource.Explicit); /// @@ -469,7 +476,9 @@ public static IMutableProperty AddProperty( /// The type of value the property will hold. /// The newly created property. public static IMutableProperty AddProperty( - [NotNull] this IMutableEntityType entityType, [NotNull] string name, [NotNull] Type propertyType) + [NotNull] this IMutableEntityType entityType, + [NotNull] string name, + [NotNull] Type propertyType) => ((EntityType)entityType).AddProperty(name, propertyType, ConfigurationSource.Explicit, ConfigurationSource.Explicit); /// @@ -480,7 +489,9 @@ public static IMutableProperty AddProperty( /// The type of value the property will hold. /// The newly created property. public static IMutableProperty AddIndexerProperty( - [NotNull] this IMutableEntityType entityType, [NotNull] string name, [NotNull] Type propertyType) + [NotNull] this IMutableEntityType entityType, + [NotNull] string name, + [NotNull] Type propertyType) { Check.NotNull(entityType, nameof(entityType)); @@ -514,7 +525,8 @@ public static IMutableIndex FindIndex([NotNull] this IMutableEntityType entityTy /// The property to be indexed. /// The newly created index. public static IMutableIndex AddIndex( - [NotNull] this IMutableEntityType entityType, [NotNull] IMutableProperty property) + [NotNull] this IMutableEntityType entityType, + [NotNull] IMutableProperty property) => Check.NotNull(entityType, nameof(entityType)).AddIndex(new[] { property }); /// diff --git a/src/EFCore/Extensions/MutableForeignKeyExtensions.cs b/src/EFCore/Extensions/MutableForeignKeyExtensions.cs index f2f9da5113e..d4199385015 100644 --- a/src/EFCore/Extensions/MutableForeignKeyExtensions.cs +++ b/src/EFCore/Extensions/MutableForeignKeyExtensions.cs @@ -19,7 +19,8 @@ public static class MutableForeignKeyExtensions /// One of the entity types related by the foreign key. /// The entity type related to the given one. public static IMutableEntityType GetRelatedEntityType( - [NotNull] this IMutableForeignKey foreignKey, [NotNull] IMutableEntityType entityType) + [NotNull] this IMutableForeignKey foreignKey, + [NotNull] IMutableEntityType entityType) => (IMutableEntityType)((IForeignKey)foreignKey).GetRelatedEntityType(entityType); /// diff --git a/src/EFCore/Extensions/MutableModelExtensions.cs b/src/EFCore/Extensions/MutableModelExtensions.cs index 2398fd9b980..51e7383c44e 100644 --- a/src/EFCore/Extensions/MutableModelExtensions.cs +++ b/src/EFCore/Extensions/MutableModelExtensions.cs @@ -182,7 +182,8 @@ public static bool IsIgnored([NotNull] this IMutableModel model, [NotNull] Type /// The model to set the access mode for. /// The , or to clear the mode set. public static void SetPropertyAccessMode( - [NotNull] this IMutableModel model, PropertyAccessMode? propertyAccessMode) + [NotNull] this IMutableModel model, + PropertyAccessMode? propertyAccessMode) => Check.NotNull((Model)model, nameof(model)) .SetPropertyAccessMode(propertyAccessMode, ConfigurationSource.Explicit); @@ -193,7 +194,8 @@ public static void SetPropertyAccessMode( /// The model to set the default change tracking strategy for. /// The strategy to use. public static void SetChangeTrackingStrategy( - [NotNull] this IMutableModel model, ChangeTrackingStrategy? changeTrackingStrategy) + [NotNull] this IMutableModel model, + ChangeTrackingStrategy? changeTrackingStrategy) => Check.NotNull((Model)model, nameof(model)) .SetChangeTrackingStrategy(changeTrackingStrategy, ConfigurationSource.Explicit); @@ -259,6 +261,7 @@ public static void AddShared([NotNull] this IMutableModel model, [NotNull] Type /// /// The model to finalize. /// The finalized . - public static IModel FinalizeModel([NotNull] this IMutableModel model) => ((Model)model).FinalizeModel(); + public static IModel FinalizeModel([NotNull] this IMutableModel model) + => ((Model)model).FinalizeModel(); } } diff --git a/src/EFCore/Extensions/MutablePropertyBaseExtensions.cs b/src/EFCore/Extensions/MutablePropertyBaseExtensions.cs index eed6c182b2f..bbe913d6aef 100644 --- a/src/EFCore/Extensions/MutablePropertyBaseExtensions.cs +++ b/src/EFCore/Extensions/MutablePropertyBaseExtensions.cs @@ -20,7 +20,8 @@ public static class MutablePropertyBaseExtensions /// The property for which to set the access mode. /// The , or null to clear the mode set. public static void SetPropertyAccessMode( - [NotNull] this IMutablePropertyBase property, PropertyAccessMode? propertyAccessMode) + [NotNull] this IMutablePropertyBase property, + PropertyAccessMode? propertyAccessMode) => Check.NotNull(property, nameof(property)).AsPropertyBase() .SetPropertyAccessMode(propertyAccessMode, ConfigurationSource.Explicit); } diff --git a/src/EFCore/Extensions/MutablePropertyExtensions.cs b/src/EFCore/Extensions/MutablePropertyExtensions.cs index 5c31ef0b749..a93f39644d6 100644 --- a/src/EFCore/Extensions/MutablePropertyExtensions.cs +++ b/src/EFCore/Extensions/MutablePropertyExtensions.cs @@ -116,7 +116,8 @@ public static void SetScale([NotNull] this IMutableProperty property, int? scale /// /// The property to set the value for. /// - /// if the property accepts Unicode characters, if it does not, to clear the setting. + /// if the property accepts Unicode characters, if it does not, to + /// clear the setting. /// public static void SetIsUnicode([NotNull] this IMutableProperty property, bool? unicode) => property.AsProperty().SetIsUnicode(unicode, ConfigurationSource.Explicit); @@ -207,7 +208,7 @@ public static void SetProviderClrType([NotNull] this IMutableProperty property, public static CoreTypeMapping SetTypeMapping( [NotNull] this IMutableProperty property, [NotNull] CoreTypeMapping typeMapping) - => ((Property)property).SetTypeMapping(typeMapping, ConfigurationSource.Explicit); + => ((Property)property).SetTypeMapping(typeMapping, ConfigurationSource.Explicit); /// /// Sets the custom for this property. diff --git a/src/EFCore/Extensions/MutableTypeBaseExtensions.cs b/src/EFCore/Extensions/MutableTypeBaseExtensions.cs index 251464f8d07..e3b196b8770 100644 --- a/src/EFCore/Extensions/MutableTypeBaseExtensions.cs +++ b/src/EFCore/Extensions/MutableTypeBaseExtensions.cs @@ -26,7 +26,8 @@ public static class MutableTypeBaseExtensions /// The type for which to set the access mode. /// The , or to clear the mode set. public static void SetPropertyAccessMode( - [NotNull] this IMutableTypeBase entityType, PropertyAccessMode? propertyAccessMode) + [NotNull] this IMutableTypeBase entityType, + PropertyAccessMode? propertyAccessMode) => Check.NotNull(entityType, nameof(entityType)).AsTypeBase() .SetPropertyAccessMode(propertyAccessMode, ConfigurationSource.Explicit); @@ -42,7 +43,8 @@ public static void SetPropertyAccessMode( /// The type for which to set the access mode. /// The , or to clear the mode set. public static void SetNavigationAccessMode( - [NotNull] this IMutableTypeBase entityType, PropertyAccessMode? propertyAccessMode) + [NotNull] this IMutableTypeBase entityType, + PropertyAccessMode? propertyAccessMode) => Check.NotNull(entityType, nameof(entityType)).AsTypeBase() .SetNavigationAccessMode(propertyAccessMode, ConfigurationSource.Explicit); } diff --git a/src/EFCore/Extensions/NavigationExtensions.cs b/src/EFCore/Extensions/NavigationExtensions.cs index 5786b4c2845..18ce9dbf073 100644 --- a/src/EFCore/Extensions/NavigationExtensions.cs +++ b/src/EFCore/Extensions/NavigationExtensions.cs @@ -3,7 +3,6 @@ using System; using System.Diagnostics; -using System.Linq; using System.Text; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -25,8 +24,8 @@ public static class NavigationExtensions /// /// The navigation property to check. /// - /// if the given navigation property is the navigation property on the dependent entity - /// type that points to the principal entity, otherwise . + /// if the given navigation property is the navigation property on the dependent entity + /// type that points to the principal entity, otherwise . /// [DebuggerStepThrough] [Obsolete("Use INavigation.IsOnDependent")] @@ -38,7 +37,7 @@ public static bool IsDependentToPrincipal([NotNull] this INavigation navigation) /// /// The navigation property to check. /// - /// if this is a collection property, false if it is a reference property. + /// if this is a collection property, false if it is a reference property. /// [DebuggerStepThrough] [Obsolete("Use INavigation.IsCollection")] @@ -154,8 +153,7 @@ public static string ToDebugString( builder.Append(" ").Append(indexes.StoreGenerationIndex); } - if (!singleLine && - (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) + if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(navigation.AnnotationsToDebugString(indent + 2)); } diff --git a/src/EFCore/Extensions/PropertyBaseExtensions.cs b/src/EFCore/Extensions/PropertyBaseExtensions.cs index 7427a33b53e..fc63eb113cc 100644 --- a/src/EFCore/Extensions/PropertyBaseExtensions.cs +++ b/src/EFCore/Extensions/PropertyBaseExtensions.cs @@ -51,7 +51,7 @@ public static MemberInfo GetMemberInfo( /// /// - /// Gets a for comparing values in tracked entries. + /// Gets a for comparing values in tracked entries. /// /// /// The property. diff --git a/src/EFCore/Extensions/PropertyExtensions.cs b/src/EFCore/Extensions/PropertyExtensions.cs index 50e8e27ab7e..2111bf748a8 100644 --- a/src/EFCore/Extensions/PropertyExtensions.cs +++ b/src/EFCore/Extensions/PropertyExtensions.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; @@ -47,7 +46,7 @@ public static CoreTypeMapping GetTypeMapping([NotNull] this IProperty property) /// Returns the for the given property. /// /// The property. - /// The type mapping, or if none was found. + /// The type mapping, or if none was found. public static CoreTypeMapping FindTypeMapping([NotNull] this IProperty property) => ((Property)property).TypeMapping; @@ -56,7 +55,7 @@ public static CoreTypeMapping FindTypeMapping([NotNull] this IProperty property) /// if the given property is part of a foreign key. /// /// The foreign key property. - /// The first associated principal property, or if none exists. + /// The first associated principal property, or if none exists. public static IProperty FindFirstPrincipal([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); @@ -121,7 +120,7 @@ private static void AddPrincipals(IProperty property, List visited) /// Gets a value indicating whether this property is used as a foreign key (or part of a composite foreign key). /// /// The property to check. - /// if the property is used as a foreign key, otherwise . + /// if the property is used as a foreign key, otherwise . public static bool IsForeignKey([NotNull] this IProperty property) => Check.NotNull((Property)property, nameof(property)).ForeignKeys != null; @@ -129,7 +128,7 @@ public static bool IsForeignKey([NotNull] this IProperty property) /// Gets a value indicating whether this property is used as an index (or part of a composite index). /// /// The property to check. - /// if the property is used as an index, otherwise . + /// if the property is used as an index, otherwise . public static bool IsIndex([NotNull] this IProperty property) => Check.NotNull((Property)property, nameof(property)).Indexes != null; @@ -137,7 +136,7 @@ public static bool IsIndex([NotNull] this IProperty property) /// Gets a value indicating whether this property is used as a unique index (or part of a unique composite index). /// /// The property to check. - /// if the property is used as an unique index, otherwise . + /// if the property is used as an unique index, otherwise . public static bool IsUniqueIndex([NotNull] this IProperty property) => Check.NotNull(property, nameof(property)).AsProperty().Indexes?.Any(e => e.IsUnique) == true; @@ -145,7 +144,7 @@ public static bool IsUniqueIndex([NotNull] this IProperty property) /// Gets a value indicating whether this property is used as the primary key (or part of a composite primary key). /// /// The property to check. - /// if the property is used as the primary key, otherwise . + /// if the property is used as the primary key, otherwise . public static bool IsPrimaryKey([NotNull] this IProperty property) => FindContainingPrimaryKey(property) != null; @@ -154,7 +153,7 @@ public static bool IsPrimaryKey([NotNull] this IProperty property) /// (or part of a composite primary or alternate key). /// /// The property to check. - /// if the property is used as a key, otherwise . + /// if the property is used as a key, otherwise . public static bool IsKey([NotNull] this IProperty property) => Check.NotNull((Property)property, nameof(property)).Keys != null; @@ -181,7 +180,7 @@ public static IEnumerable GetContainingIndexes([NotNull] this IProperty /// is included). /// /// The property to get primary key for. - /// The primary that use this property, or if it is not part of the primary key. + /// The primary that use this property, or if it is not part of the primary key. public static IKey FindContainingPrimaryKey([NotNull] this IProperty property) => Check.NotNull((Property)property, nameof(property)).PrimaryKey; @@ -199,7 +198,7 @@ public static IEnumerable GetContainingKeys([NotNull] this IProperty prope /// then this is the maximum number of characters. /// /// The property to get the maximum length of. - /// The maximum length, or if none if defined. + /// The maximum length, or if none if defined. public static int? GetMaxLength([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); @@ -213,7 +212,7 @@ public static IEnumerable GetContainingKeys([NotNull] this IProperty prope /// then this is the maximum number of digits. /// /// The property to get the precision of. - /// The precision, or if none is defined. + /// The precision, or if none is defined. public static int? GetPrecision([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); @@ -227,7 +226,7 @@ public static IEnumerable GetContainingKeys([NotNull] this IProperty prope /// then this is the maximum number of decimal places. /// /// The property to get the scale of. - /// The scale, or if none is defined. + /// The scale, or if none is defined. public static int? GetScale([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); @@ -239,7 +238,7 @@ public static IEnumerable GetContainingKeys([NotNull] this IProperty prope /// Gets a value indicating whether or not the property can persist Unicode characters. /// /// The property to get the Unicode setting for. - /// The Unicode setting, or if none is defined. + /// The Unicode setting, or if none is defined. public static bool? IsUnicode([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); @@ -296,7 +295,7 @@ public static PropertySaveBehavior GetAfterSaveBehavior([NotNull] this IProperty /// Gets the factory that has been set to generate values for this property, if any. /// /// The property to get the value generator factory for. - /// The factory, or if no factory has been set. + /// The factory, or if no factory has been set. public static Func GetValueGeneratorFactory([NotNull] this IProperty property) => (Func) Check.NotNull(property, nameof(property))[CoreAnnotationNames.ValueGeneratorFactory]; @@ -305,7 +304,7 @@ public static Func GetValueGeneratorFact /// Gets the custom set for this property. /// /// The property. - /// The converter, or if none has been set. + /// The converter, or if none has been set. public static ValueConverter GetValueConverter([NotNull] this IProperty property) => (ValueConverter)Check.NotNull(property, nameof(property))[CoreAnnotationNames.ValueConverter]; @@ -313,15 +312,15 @@ public static ValueConverter GetValueConverter([NotNull] this IProperty property /// Gets the type that the property value will be converted to before being sent to the database provider. /// /// The property. - /// The provider type, or if none has been set. + /// The provider type, or if none has been set. public static Type GetProviderClrType([NotNull] this IProperty property) => (Type)Check.NotNull(property, nameof(property))[CoreAnnotationNames.ProviderClrType]; /// - /// Gets the for this property, or if none is set. + /// Gets the for this property, or if none is set. /// /// The property. - /// The comparer, or if none has been set. + /// The comparer, or if none has been set. public static ValueComparer GetValueComparer([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); @@ -331,10 +330,10 @@ public static ValueComparer GetValueComparer([NotNull] this IProperty property) } /// - /// Gets the to use with keys for this property, or if none is set. + /// Gets the to use with keys for this property, or if none is set. /// /// The property. - /// The comparer, or if none has been set. + /// The comparer, or if none has been set. public static ValueComparer GetKeyValueComparer([NotNull] this IProperty property) { Check.NotNull(property, nameof(property)); @@ -344,10 +343,10 @@ public static ValueComparer GetKeyValueComparer([NotNull] this IProperty propert } /// - /// Gets the to use for structural copies for this property, or if none is set. + /// Gets the to use for structural copies for this property, or if none is set. /// /// The property. - /// The comparer, or if none has been set. + /// The comparer, or if none has been set. [Obsolete("Use GetKeyValueComparer. A separate structural comparer is no longer supported.")] public static ValueComparer GetStructuralValueComparer([NotNull] this IProperty property) => property.GetKeyValueComparer(); @@ -389,7 +388,7 @@ public int GetHashCode(TNullableKey obj) /// when throwing exceptions about keys, indexes, etc. that use the properties. /// /// The properties to format. - /// If true, then type names are included in the string. The default is . + /// If true, then type names are included in the string. The default is . /// The string representation. public static string Format([NotNull] this IEnumerable properties, bool includeTypes = false) => "{" @@ -521,8 +520,7 @@ public static string ToDebugString( } } - if (!singleLine && - (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) + if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(property.AnnotationsToDebugString(indent + 2)); } diff --git a/src/EFCore/Extensions/ServicePropertyExtensions.cs b/src/EFCore/Extensions/ServicePropertyExtensions.cs index a76062deb50..a0d82a1006d 100644 --- a/src/EFCore/Extensions/ServicePropertyExtensions.cs +++ b/src/EFCore/Extensions/ServicePropertyExtensions.cs @@ -56,8 +56,7 @@ public static string ToDebugString( builder.Append(serviceProperty.ClrType?.ShortDisplayName()).Append(")"); - if (!singleLine && - (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) + if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(serviceProperty.AnnotationsToDebugString(indent + 2)); } diff --git a/src/EFCore/Extensions/SkipNavigationExtensions.cs b/src/EFCore/Extensions/SkipNavigationExtensions.cs index 332b9036cc6..21babb46d9a 100644 --- a/src/EFCore/Extensions/SkipNavigationExtensions.cs +++ b/src/EFCore/Extensions/SkipNavigationExtensions.cs @@ -90,8 +90,7 @@ public static string ToDebugString( builder.Append(" ").Append(indexes.StoreGenerationIndex); } - if (!singleLine && - (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) + if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0) { builder.Append(navigation.AnnotationsToDebugString(indent + 2)); } diff --git a/src/EFCore/Infrastructure/Annotatable.cs b/src/EFCore/Infrastructure/Annotatable.cs index e907b6f52ae..84fb08adec4 100644 --- a/src/EFCore/Infrastructure/Annotatable.cs +++ b/src/EFCore/Infrastructure/Annotatable.cs @@ -28,8 +28,8 @@ public class Annotatable : IMutableAnnotatable /// /// Gets all annotations on the current object. /// - public virtual IEnumerable GetAnnotations() => - _annotations?.Values ?? Enumerable.Empty(); + public virtual IEnumerable GetAnnotations() + => _annotations?.Values ?? Enumerable.Empty(); /// /// Adds an annotation to this object. Throws if an annotation with the specified name already exists. @@ -200,18 +200,22 @@ protected virtual Annotation CreateAnnotation([NotNull] string name, [CanBeNull] /// [DebuggerStepThrough] - IEnumerable IAnnotatable.GetAnnotations() => GetAnnotations(); + IEnumerable IAnnotatable.GetAnnotations() + => GetAnnotations(); /// [DebuggerStepThrough] - IAnnotation IAnnotatable.FindAnnotation(string name) => FindAnnotation(name); + IAnnotation IAnnotatable.FindAnnotation(string name) + => FindAnnotation(name); /// [DebuggerStepThrough] - IAnnotation IMutableAnnotatable.AddAnnotation(string name, object value) => AddAnnotation(name, value); + IAnnotation IMutableAnnotatable.AddAnnotation(string name, object value) + => AddAnnotation(name, value); /// [DebuggerStepThrough] - IAnnotation IMutableAnnotatable.RemoveAnnotation(string name) => RemoveAnnotation(name); + IAnnotation IMutableAnnotatable.RemoveAnnotation(string name) + => RemoveAnnotation(name); } } diff --git a/src/EFCore/Infrastructure/AnnotatableBuilder.cs b/src/EFCore/Infrastructure/AnnotatableBuilder.cs index 06c6c9e0f05..9a30771925e 100644 --- a/src/EFCore/Infrastructure/AnnotatableBuilder.cs +++ b/src/EFCore/Infrastructure/AnnotatableBuilder.cs @@ -24,7 +24,7 @@ public abstract class AnnotatableBuilder : IConvention where TModelBuilder : IConventionModelBuilder { /// - /// Creates a new instance of + /// Creates a new instance of /// protected AnnotatableBuilder([NotNull] TMetadata metadata, [NotNull] TModelBuilder modelBuilder) { @@ -51,11 +51,16 @@ protected AnnotatableBuilder([NotNull] TMetadata metadata, [NotNull] TModelBuild /// The configuration source of the annotation to be set. /// The same builder so that multiple calls can be chained. public virtual AnnotatableBuilder HasAnnotation( - [NotNull] string name, [CanBeNull] object value, ConfigurationSource configurationSource) + [NotNull] string name, + [CanBeNull] object value, + ConfigurationSource configurationSource) => HasAnnotation(name, value, configurationSource, canOverrideSameSource: true); private AnnotatableBuilder HasAnnotation( - string name, object value, ConfigurationSource configurationSource, bool canOverrideSameSource) + string name, + object value, + ConfigurationSource configurationSource, + bool canOverrideSameSource) { var existingAnnotation = Metadata.FindAnnotation(name); if (existingAnnotation != null) @@ -91,7 +96,9 @@ private AnnotatableBuilder HasAnnotation( /// The configuration source of the annotation to be set. /// The same builder so that multiple calls can be chained. public virtual AnnotatableBuilder HasNonNullAnnotation( - [NotNull] string name, [CanBeNull] object value, ConfigurationSource configurationSource) + [NotNull] string name, + [CanBeNull] object value, + ConfigurationSource configurationSource) => value == null ? RemoveAnnotation(name, configurationSource) : HasAnnotation(name, value, configurationSource, canOverrideSameSource: true); @@ -111,7 +118,10 @@ public virtual bool CanSetAnnotation([NotNull] string name, [CanBeNull] object v } private static bool CanSetAnnotationValue( - ConventionAnnotation annotation, object value, ConfigurationSource configurationSource, bool canOverrideSameSource) + ConventionAnnotation annotation, + object value, + ConfigurationSource configurationSource, + bool canOverrideSameSource) { if (Equals(annotation.Value, value)) { @@ -130,7 +140,9 @@ private static bool CanSetAnnotationValue( /// The name of the annotation to remove. /// The configuration source of the annotation to be set. /// The same builder so that multiple calls can be chained. - public virtual AnnotatableBuilder RemoveAnnotation([NotNull] string name, ConfigurationSource configurationSource) + public virtual AnnotatableBuilder RemoveAnnotation( + [NotNull] string name, + ConfigurationSource configurationSource) { if (!CanRemoveAnnotation(name, configurationSource)) { @@ -202,7 +214,9 @@ IConventionAnnotatableBuilder IConventionAnnotatableBuilder.HasAnnotation(string /// [DebuggerStepThrough] IConventionAnnotatableBuilder IConventionAnnotatableBuilder.HasNonNullAnnotation( - string name, object value, bool fromDataAnnotation) + string name, + object value, + bool fromDataAnnotation) => HasNonNullAnnotation(name, value, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// diff --git a/src/EFCore/Infrastructure/ConcurrencyDetectorCriticalSectionDisposer.cs b/src/EFCore/Infrastructure/ConcurrencyDetectorCriticalSectionDisposer.cs index d0f12680162..e6bd044067d 100644 --- a/src/EFCore/Infrastructure/ConcurrencyDetectorCriticalSectionDisposer.cs +++ b/src/EFCore/Infrastructure/ConcurrencyDetectorCriticalSectionDisposer.cs @@ -24,6 +24,7 @@ public ConcurrencyDetectorCriticalSectionDisposer([NotNull] IConcurrencyDetector => _concurrencyDetector = concurrencyDetector; /// - public void Dispose() => _concurrencyDetector.ExitCriticalSection(); + public void Dispose() + => _concurrencyDetector.ExitCriticalSection(); } } diff --git a/src/EFCore/Infrastructure/ConventionAnnotatable.cs b/src/EFCore/Infrastructure/ConventionAnnotatable.cs index 7fdc7271806..ce6e05595d8 100644 --- a/src/EFCore/Infrastructure/ConventionAnnotatable.cs +++ b/src/EFCore/Infrastructure/ConventionAnnotatable.cs @@ -21,13 +21,13 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure /// not used in application code. /// /// - public abstract class ConventionAnnotatable : Annotatable, IConventionAnnotatable { /// /// Gets all annotations on the current object. /// - public new virtual IEnumerable GetAnnotations() => base.GetAnnotations().Cast(); + public new virtual IEnumerable GetAnnotations() + => base.GetAnnotations().Cast(); /// /// Adds a annotation with given key and value to this object using given configuration source. @@ -38,7 +38,9 @@ public abstract class ConventionAnnotatable : Annotatable, IConventionAnnotatabl /// The configuration source of the annotation to be added. /// The added annotation. public virtual ConventionAnnotation AddAnnotation( - [NotNull] string name, [CanBeNull] object value, ConfigurationSource configurationSource) + [NotNull] string name, + [CanBeNull] object value, + ConfigurationSource configurationSource) => (ConventionAnnotation)base.AddAnnotation(name, CreateAnnotation(name, value, configurationSource)); /// @@ -49,7 +51,9 @@ public virtual ConventionAnnotation AddAnnotation( /// The value to be stored in the annotation. /// The configuration source of the annotation to be set. public virtual ConventionAnnotation SetAnnotation( - [NotNull] string name, [CanBeNull] object value, ConfigurationSource configurationSource) + [NotNull] string name, + [CanBeNull] object value, + ConfigurationSource configurationSource) { var oldAnnotation = FindAnnotation(name); if (oldAnnotation != null) @@ -112,15 +116,19 @@ protected override Annotation CreateAnnotation(string name, object value) => CreateAnnotation(name, value, ConfigurationSource.Explicit); private static ConventionAnnotation CreateAnnotation( - string name, object value, ConfigurationSource configurationSource) + string name, + object value, + ConfigurationSource configurationSource) => new ConventionAnnotation(name, value, configurationSource); /// - IConventionAnnotatableBuilder IConventionAnnotatable.Builder => throw new NotImplementedException(); + IConventionAnnotatableBuilder IConventionAnnotatable.Builder + => throw new NotImplementedException(); /// [DebuggerStepThrough] - IEnumerable IConventionAnnotatable.GetAnnotations() => GetAnnotations(); + IEnumerable IConventionAnnotatable.GetAnnotations() + => GetAnnotations(); /// [DebuggerStepThrough] @@ -134,10 +142,12 @@ IConventionAnnotation IConventionAnnotatable.AddAnnotation(string name, object v /// [DebuggerStepThrough] - IConventionAnnotation IConventionAnnotatable.FindAnnotation(string name) => FindAnnotation(name); + IConventionAnnotation IConventionAnnotatable.FindAnnotation(string name) + => FindAnnotation(name); /// [DebuggerStepThrough] - IConventionAnnotation IConventionAnnotatable.RemoveAnnotation(string name) => RemoveAnnotation(name); + IConventionAnnotation IConventionAnnotatable.RemoveAnnotation(string name) + => RemoveAnnotation(name); } } diff --git a/src/EFCore/Infrastructure/CoreOptionsExtension.cs b/src/EFCore/Infrastructure/CoreOptionsExtension.cs index 2f80ef6cd50..d6ec52cfff5 100644 --- a/src/EFCore/Infrastructure/CoreOptionsExtension.cs +++ b/src/EFCore/Infrastructure/CoreOptionsExtension.cs @@ -8,7 +8,6 @@ using System.Text; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Caching.Memory; @@ -94,7 +93,8 @@ public virtual DbContextOptionsExtensionInfo Info /// Override this method in a derived class to ensure that any clone created is also of that class. /// /// A clone of this instance, which can be modified before being returned as immutable. - protected virtual CoreOptionsExtension Clone() => new CoreOptionsExtension(this); + protected virtual CoreOptionsExtension Clone() + => new CoreOptionsExtension(this); /// /// Creates a new instance with all options the same as for this instance, but with the given option changed. @@ -323,62 +323,74 @@ public virtual CoreOptionsExtension WithInterceptors([NotNull] IEnumerable /// The option set from the method. /// - public virtual bool IsSensitiveDataLoggingEnabled => _sensitiveDataLoggingEnabled; + public virtual bool IsSensitiveDataLoggingEnabled + => _sensitiveDataLoggingEnabled; /// /// The option set from the method. /// - public virtual bool DetailedErrorsEnabled => _detailedErrorsEnabled; + public virtual bool DetailedErrorsEnabled + => _detailedErrorsEnabled; /// /// The option set from the method. /// - public virtual IModel Model => _model; + public virtual IModel Model + => _model; /// /// The option set from the method. /// - public virtual ILoggerFactory LoggerFactory => _loggerFactory; + public virtual ILoggerFactory LoggerFactory + => _loggerFactory; /// /// The option set from the method. /// - public virtual IDbContextLogger DbContextLogger => _contextLogger; + public virtual IDbContextLogger DbContextLogger + => _contextLogger; /// /// The option set from the method. /// - public virtual IMemoryCache MemoryCache => _memoryCache; + public virtual IMemoryCache MemoryCache + => _memoryCache; /// /// The option set from the method. /// - public virtual IServiceProvider InternalServiceProvider => _internalServiceProvider; + public virtual IServiceProvider InternalServiceProvider + => _internalServiceProvider; /// /// The option set from the method. /// - public virtual IServiceProvider ApplicationServiceProvider => _applicationServiceProvider; + public virtual IServiceProvider ApplicationServiceProvider + => _applicationServiceProvider; /// /// The options set from the method. /// - public virtual WarningsConfiguration WarningsConfiguration => _warningsConfiguration; + public virtual WarningsConfiguration WarningsConfiguration + => _warningsConfiguration; /// /// The option set from the method. /// - public virtual QueryTrackingBehavior QueryTrackingBehavior => _queryTrackingBehavior; + public virtual QueryTrackingBehavior QueryTrackingBehavior + => _queryTrackingBehavior; /// /// The option set from the method. /// - public virtual bool ServiceProviderCachingEnabled => _serviceProviderCachingEnabled; + public virtual bool ServiceProviderCachingEnabled + => _serviceProviderCachingEnabled; /// /// The options set from the method. /// - public virtual IReadOnlyDictionary<(Type, Type), Type> ReplacedServices => (IReadOnlyDictionary<(Type, Type), Type>)_replacedServices; + public virtual IReadOnlyDictionary<(Type, Type), Type> ReplacedServices + => (IReadOnlyDictionary<(Type, Type), Type>)_replacedServices; /// /// The option set from the @@ -386,12 +398,14 @@ public virtual CoreOptionsExtension WithInterceptors([NotNull] IEnumerable /// method. /// - public virtual int? MaxPoolSize => _maxPoolSize; + public virtual int? MaxPoolSize + => _maxPoolSize; /// /// The options set from the method. /// - public virtual IEnumerable Interceptors => _interceptors; + public virtual IEnumerable Interceptors + => _interceptors; /// /// Adds the services required to make the selected options work. This is used when there @@ -462,7 +476,8 @@ public ExtensionInfo(CoreOptionsExtension extension) private new CoreOptionsExtension Extension => (CoreOptionsExtension)base.Extension; - public override bool IsDatabaseProvider => false; + public override bool IsDatabaseProvider + => false; public override string LogFragment { diff --git a/src/EFCore/Infrastructure/DatabaseFacade.cs b/src/EFCore/Infrastructure/DatabaseFacade.cs index 4821639a00d..647111d6d34 100644 --- a/src/EFCore/Infrastructure/DatabaseFacade.cs +++ b/src/EFCore/Infrastructure/DatabaseFacade.cs @@ -52,8 +52,9 @@ private IDatabaseFacadeDependencies Dependencies /// are applied. /// /// - /// if the database is created, false if it already existed. - public virtual bool EnsureCreated() => Dependencies.DatabaseCreator.EnsureCreated(); + /// if the database is created, false if it already existed. + public virtual bool EnsureCreated() + => Dependencies.DatabaseCreator.EnsureCreated(); /// /// @@ -70,7 +71,7 @@ private IDatabaseFacadeDependencies Dependencies /// /// A to observe while waiting for the task to complete. /// - /// A task that represents the asynchronous save operation. The task result contains if the database is created, + /// A task that represents the asynchronous save operation. The task result contains if the database is created, /// false if it already existed. /// public virtual Task EnsureCreatedAsync(CancellationToken cancellationToken = default) @@ -86,8 +87,9 @@ public virtual Task EnsureCreatedAsync(CancellationToken cancellationToken /// the model for this context. /// /// - /// if the database is deleted, false if it did not exist. - public virtual bool EnsureDeleted() => Dependencies.DatabaseCreator.EnsureDeleted(); + /// if the database is deleted, false if it did not exist. + public virtual bool EnsureDeleted() + => Dependencies.DatabaseCreator.EnsureDeleted(); /// /// @@ -101,7 +103,7 @@ public virtual Task EnsureCreatedAsync(CancellationToken cancellationToken /// /// A to observe while waiting for the task to complete. /// - /// A task that represents the asynchronous save operation. The task result contains if the database is deleted, + /// A task that represents the asynchronous save operation. The task result contains if the database is deleted, /// false if it did not exist. /// public virtual Task EnsureDeletedAsync(CancellationToken cancellationToken = default) @@ -272,7 +274,8 @@ public virtual string ProviderName /// not directly exposed in the public API surface. /// /// - IServiceProvider IInfrastructure.Instance => ((IInfrastructure)_context).Instance; + IServiceProvider IInfrastructure.Instance + => ((IInfrastructure)_context).Instance; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -301,22 +304,25 @@ DbContext IDatabaseFacadeDependenciesAccessor.Context /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs b/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs index 0b47c7108da..80e62f4abfd 100644 --- a/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs +++ b/src/EFCore/Infrastructure/DbContextOptionsExtensionInfo.cs @@ -31,7 +31,7 @@ protected DbContextOptionsExtensionInfo([NotNull] IDbContextOptionsExtension ext public virtual IDbContextOptionsExtension Extension { get; } /// - /// if the extension is a database provider; otherwise. + /// if the extension is a database provider; otherwise. /// public abstract bool IsDatabaseProvider { get; } diff --git a/src/EFCore/Infrastructure/DbSetProperty.cs b/src/EFCore/Infrastructure/DbSetProperty.cs index 13cc4d38d56..1e4cbeef676 100644 --- a/src/EFCore/Infrastructure/DbSetProperty.cs +++ b/src/EFCore/Infrastructure/DbSetProperty.cs @@ -8,12 +8,12 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure { /// - /// A struct representing facets of property defined on DbContext derived type. + /// A struct representing facets of property defined on DbContext derived type. /// public readonly struct DbSetProperty { /// - /// Initializes new with given values. + /// Initializes new with given values. /// /// The name of DbSet. /// The entity clr type of DbSet. diff --git a/src/EFCore/Infrastructure/DebugView.cs b/src/EFCore/Infrastructure/DebugView.cs index 0410ee8499e..bc91b524201 100644 --- a/src/EFCore/Infrastructure/DebugView.cs +++ b/src/EFCore/Infrastructure/DebugView.cs @@ -35,11 +35,13 @@ public DebugView( /// /// The long-form, detailed debug string. /// - public virtual string LongView => _toLongDebugString(); + public virtual string LongView + => _toLongDebugString(); /// /// The short-form, less-detailed debug string. /// - public virtual string ShortView => _toShortDebugString(); + public virtual string ShortView + => _toShortDebugString(); } } diff --git a/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs b/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs index 190f81c3956..1832d42d444 100644 --- a/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs +++ b/src/EFCore/Infrastructure/EntityFrameworkEventSource.cs @@ -28,6 +28,7 @@ public sealed class EntityFrameworkEventSource : EventSource private PollingCounter _totalExecutionStrategyOperationFailuresCounter; private IncrementingPollingCounter _executionStrategyOperationFailuresPerSecondCounter; private PollingCounter _totalOptimisticConcurrencyFailuresCounter; + private IncrementingPollingCounter _optimisticConcurrencyFailuresPerSecondCounter; // ReSharper restore NotAccessedField.Local @@ -36,47 +37,58 @@ public sealed class EntityFrameworkEventSource : EventSource /// public static readonly EntityFrameworkEventSource Log = new EntityFrameworkEventSource(); - private EntityFrameworkEventSource() : base("Microsoft.EntityFrameworkCore") {} + private EntityFrameworkEventSource() + : base("Microsoft.EntityFrameworkCore") + { + } /// /// Indicates that a new instance is being initialized. /// - public void DbContextInitializing() => Interlocked.Increment(ref _activeDbContexts); + public void DbContextInitializing() + => Interlocked.Increment(ref _activeDbContexts); /// /// Indicates that a instance is being disposed. /// - public void DbContextDisposing() => Interlocked.Decrement(ref _activeDbContexts); + public void DbContextDisposing() + => Interlocked.Decrement(ref _activeDbContexts); /// /// Indicates that a query is about to begin execution. /// - public void QueryExecuting() => Interlocked.Increment(ref _totalQueries); + public void QueryExecuting() + => Interlocked.Increment(ref _totalQueries); /// /// Indicates that changes are about to be saved. /// - public void SavingChanges() => Interlocked.Increment(ref _totalSaveChanges); + public void SavingChanges() + => Interlocked.Increment(ref _totalSaveChanges); /// /// Indicates a hit in the compiled query cache, signifying that query compilation will not need to occur. /// - public void CompiledQueryCacheHit() => Interlocked.Increment(ref _compiledQueryCacheInfo.Hits); + public void CompiledQueryCacheHit() + => Interlocked.Increment(ref _compiledQueryCacheInfo.Hits); /// /// Indicates a miss in the compiled query cache, signifying that query compilation will need to occur. /// - public void CompiledQueryCacheMiss() => Interlocked.Increment(ref _compiledQueryCacheInfo.Misses); + public void CompiledQueryCacheMiss() + => Interlocked.Increment(ref _compiledQueryCacheInfo.Misses); /// /// Indicates that an operation executed by an failed (and may be retried). /// - public void ExecutionStrategyOperationFailure() => Interlocked.Increment(ref _totalExecutionStrategyOperationFailures); + public void ExecutionStrategyOperationFailure() + => Interlocked.Increment(ref _totalExecutionStrategyOperationFailures); /// /// Indicates that an optimistic concurrency failure has occurred. /// - public void OptimisticConcurrencyFailure() => Interlocked.Increment(ref _totalOptimisticConcurrencyFailures); + public void OptimisticConcurrencyFailure() + => Interlocked.Increment(ref _totalOptimisticConcurrencyFailures); /// protected override void OnEventCommand(EventCommandEventArgs command) @@ -94,19 +106,12 @@ protected override void OnEventCommand(EventCommandEventArgs command) DisplayName = "Active DbContexts" }; - _totalQueriesCounter ??= new PollingCounter("total-queries", this, () => _totalQueries) - { - DisplayName = "Queries (Total)" - }; + _totalQueriesCounter ??= new PollingCounter("total-queries", this, () => _totalQueries) { DisplayName = "Queries (Total)" }; _queriesPerSecondCounter ??= new IncrementingPollingCounter( "queries-per-second", this, - () => _totalQueries) - { - DisplayName = "Queries", - DisplayRateTimeScale = TimeSpan.FromSeconds(1) - }; + () => _totalQueries) { DisplayName = "Queries", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _totalSaveChangesCounter ??= new PollingCounter("total-save-changes", this, () => _totalSaveChanges) { @@ -116,52 +121,37 @@ protected override void OnEventCommand(EventCommandEventArgs command) _saveChangesPerSecondCounter ??= new IncrementingPollingCounter( "save-changes-per-second", this, - () => _totalSaveChanges) - { - DisplayName = "SaveChanges", - DisplayRateTimeScale = TimeSpan.FromSeconds(1) - }; + () => _totalSaveChanges) { DisplayName = "SaveChanges", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _compiledQueryCacheHitRateCounter ??= new PollingCounter( "compiled-query-cache-hit-rate", this, - () => _compiledQueryCacheInfo.CalculateAndReset()) - { - DisplayName = "Query Cache Hit Rate", DisplayUnits = "%" - }; + () => _compiledQueryCacheInfo.CalculateAndReset()) { DisplayName = "Query Cache Hit Rate", DisplayUnits = "%" }; _totalExecutionStrategyOperationFailuresCounter ??= new PollingCounter( "total-execution-strategy-operation-failures", this, - () => _totalExecutionStrategyOperationFailures) - { - DisplayName = "Execution Strategy Operation Failures (Total)" - }; + () => _totalExecutionStrategyOperationFailures) { DisplayName = "Execution Strategy Operation Failures (Total)" }; _executionStrategyOperationFailuresPerSecondCounter ??= new IncrementingPollingCounter( "execution-strategy-operation-failures-per-second", this, () => _totalExecutionStrategyOperationFailures) { - DisplayName = "Execution Strategy Operation Failures", - DisplayRateTimeScale = TimeSpan.FromSeconds(1) + DisplayName = "Execution Strategy Operation Failures", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _totalOptimisticConcurrencyFailuresCounter ??= new PollingCounter( "total-optimistic-concurrency-failures", this, - () => _totalOptimisticConcurrencyFailures) - { - DisplayName = "Optimistic Concurrency Failures (Total)" - }; + () => _totalOptimisticConcurrencyFailures) { DisplayName = "Optimistic Concurrency Failures (Total)" }; _optimisticConcurrencyFailuresPerSecondCounter ??= new IncrementingPollingCounter( "optimistic-concurrency-failures-per-second", this, () => _totalOptimisticConcurrencyFailures) { - DisplayName = "Optimistic Concurrency Failures", - DisplayRateTimeScale = TimeSpan.FromSeconds(1) + DisplayName = "Optimistic Concurrency Failures", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; } } @@ -171,6 +161,7 @@ private struct CacheInfo { [FieldOffset(0)] internal int Hits; + [FieldOffset(4)] internal int Misses; @@ -178,7 +169,7 @@ private struct CacheInfo private long _all; /// - /// Returns the atomically-calculated hit rate and atomically resets and to 0. + /// Returns the atomically-calculated hit rate and atomically resets and to 0. /// internal double CalculateAndReset() { diff --git a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs index e7655dd3557..9ca79f1ce88 100644 --- a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs +++ b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs @@ -133,9 +133,16 @@ public static readonly IDictionary CoreServices { typeof(IQueryCompilationContextFactory), new ServiceCharacteristics(ServiceLifetime.Scoped) }, { typeof(IDbContextLogger), new ServiceCharacteristics(ServiceLifetime.Scoped) }, { typeof(ILazyLoader), new ServiceCharacteristics(ServiceLifetime.Transient) }, - { typeof(IParameterBindingFactory), new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) }, - { typeof(ITypeMappingSourcePlugin), new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) }, - { typeof(IEvaluatableExpressionFilterPlugin), new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) }, + { + typeof(IParameterBindingFactory), new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) + }, + { + typeof(ITypeMappingSourcePlugin), new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) + }, + { + typeof(IEvaluatableExpressionFilterPlugin), + new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) + }, { typeof(ISingletonOptions), new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) }, { typeof(IConventionSetPlugin), new ServiceCharacteristics(ServiceLifetime.Scoped, multipleRegistrations: true) }, { typeof(IResettableService), new ServiceCharacteristics(ServiceLifetime.Scoped, multipleRegistrations: true) }, @@ -226,7 +233,7 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices() TryAdd(); TryAdd(); TryAdd(); - TryAdd(); + TryAdd(); TryAdd(); TryAdd(); TryAdd(); diff --git a/src/EFCore/Infrastructure/ExpressionExtensions.cs b/src/EFCore/Infrastructure/ExpressionExtensions.cs index 82c41f8c910..f0ab055fa2d 100644 --- a/src/EFCore/Infrastructure/ExpressionExtensions.cs +++ b/src/EFCore/Infrastructure/ExpressionExtensions.cs @@ -92,7 +92,7 @@ private static readonly Type _assignBinaryExpressionType /// The method-call expression for /// The extracted entity access expression. /// The accessed property name. - /// if the method-call was for ; otherwise. + /// if the method-call was for ; otherwise. public static bool TryGetEFPropertyArguments( [NotNull] this MethodCallExpression methodCallExpression, out Expression entityExpression, @@ -118,7 +118,7 @@ public static bool TryGetEFPropertyArguments( /// The model to use. /// The extracted entity access expression. /// The accessed property name. - /// if the method-call was for indexer; otherwise. + /// if the method-call was for indexer; otherwise. public static bool TryGetIndexerArguments( [NotNull] this MethodCallExpression methodCallExpression, [NotNull] IModel model, @@ -303,7 +303,8 @@ public static Expression CreateValueBufferReadValueExpression( /// /// - /// MethodInfo which is used to generate an tree representing reading a value from a + /// MethodInfo which is used to generate an tree representing reading a value from a + /// /// /// /// This method is typically used by database providers (and other extensions). It is generally @@ -317,7 +318,9 @@ public static readonly MethodInfo ValueBufferTryReadValueMethod [MethodImpl(MethodImplOptions.AggressiveInlining)] private static TValue ValueBufferTryReadValue( #pragma warning disable IDE0060 // Remove unused parameter - in ValueBuffer valueBuffer, int index, IPropertyBase property) + in ValueBuffer valueBuffer, + int index, + IPropertyBase property) #pragma warning restore IDE0060 // Remove unused parameter => (TValue)valueBuffer[index]; @@ -343,8 +346,7 @@ public static Expression CreateKeyValuesExpression( : Expression.NewArrayInit( typeof(object), properties - .Select(p => Expression.Convert(target.CreateEFPropertyExpression(p, makeNullable), typeof(object))) - .Cast()); + .Select(p => Expression.Convert(target.CreateEFPropertyExpression(p, makeNullable), typeof(object)))); /// /// diff --git a/src/EFCore/Infrastructure/IConcurrencyDetector.cs b/src/EFCore/Infrastructure/IConcurrencyDetector.cs index 95c87514cf9..d200baa4bea 100644 --- a/src/EFCore/Infrastructure/IConcurrencyDetector.cs +++ b/src/EFCore/Infrastructure/IConcurrencyDetector.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Infrastructure diff --git a/src/EFCore/Infrastructure/IndentedStringBuilder.cs b/src/EFCore/Infrastructure/IndentedStringBuilder.cs index ccd30cc0707..5b2861d0257 100644 --- a/src/EFCore/Infrastructure/IndentedStringBuilder.cs +++ b/src/EFCore/Infrastructure/IndentedStringBuilder.cs @@ -28,7 +28,8 @@ public class IndentedStringBuilder /// /// The current length of the built string. /// - public virtual int Length => _stringBuilder.Length; + public virtual int Length + => _stringBuilder.Length; /// /// Appends the current indent and then the given string to the string being built. @@ -159,13 +160,15 @@ public virtual IndentedStringBuilder DecrementIndent() /// Creates a scoped indenter that will increment the indent, then decrement it when disposed. /// /// An indenter. - public virtual IDisposable Indent() => new Indenter(this); + public virtual IDisposable Indent() + => new Indenter(this); /// /// Returns the built string. /// /// The built string. - public override string ToString() => _stringBuilder.ToString(); + public override string ToString() + => _stringBuilder.ToString(); private void DoIndent() { @@ -188,7 +191,8 @@ public Indenter(IndentedStringBuilder stringBuilder) _stringBuilder.IncrementIndent(); } - public void Dispose() => _stringBuilder.DecrementIndent(); + public void Dispose() + => _stringBuilder.DecrementIndent(); } } } diff --git a/src/EFCore/Infrastructure/Internal/InfrastructureExtensions.cs b/src/EFCore/Infrastructure/Internal/InfrastructureExtensions.cs index 2c61ad842fa..e8a2be2e7b9 100644 --- a/src/EFCore/Infrastructure/Internal/InfrastructureExtensions.cs +++ b/src/EFCore/Infrastructure/Internal/InfrastructureExtensions.cs @@ -5,7 +5,6 @@ using System.Linq; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.Extensions.DependencyInjection; // ReSharper disable once CheckNamespace diff --git a/src/EFCore/Infrastructure/MethodInfoExtensions.cs b/src/EFCore/Infrastructure/MethodInfoExtensions.cs index de1d561665b..aa93eb2daa1 100644 --- a/src/EFCore/Infrastructure/MethodInfoExtensions.cs +++ b/src/EFCore/Infrastructure/MethodInfoExtensions.cs @@ -20,10 +20,10 @@ public static class MethodInfoExtensions private static readonly string _efTypeName = typeof(EF).FullName; /// - /// Returns if the given method is . + /// Returns if the given method is . /// /// The method. - /// if the method is ; otherwise. + /// if the method is ; otherwise. public static bool IsEFPropertyMethod([CanBeNull] this MethodInfo methodInfo) => Equals(methodInfo, EF.PropertyMethod) // fallback to string comparison because MethodInfo.Equals is not diff --git a/src/EFCore/Infrastructure/ModelCacheKey.cs b/src/EFCore/Infrastructure/ModelCacheKey.cs index 6e720fab7a8..d5d8d5d43e9 100644 --- a/src/EFCore/Infrastructure/ModelCacheKey.cs +++ b/src/EFCore/Infrastructure/ModelCacheKey.cs @@ -39,9 +39,10 @@ public ModelCacheKey([NotNull] DbContext context) /// The key to compare this key to. /// /// - /// if the key is for the same context type, otherwise . + /// if the key is for the same context type, otherwise . /// - protected virtual bool Equals([NotNull] ModelCacheKey other) => _dbContextType == other._dbContextType; + protected virtual bool Equals([NotNull] ModelCacheKey other) + => _dbContextType == other._dbContextType; /// /// Determines if this key is equivalent to a given object (i.e. if they are keys for the same context type). @@ -50,9 +51,11 @@ public ModelCacheKey([NotNull] DbContext context) /// The object to compare this key to. /// /// - /// if the object is a and is for the same context type, otherwise . + /// if the object is a and is for the same context type, otherwise + /// . /// - public override bool Equals(object obj) => (obj is ModelCacheKey otherAsKey) && Equals(otherAsKey); + public override bool Equals(object obj) + => (obj is ModelCacheKey otherAsKey) && Equals(otherAsKey); /// /// Gets the hash code for the key. @@ -60,6 +63,7 @@ public ModelCacheKey([NotNull] DbContext context) /// /// The hash code for the key. /// - public override int GetHashCode() => _dbContextType?.GetHashCode() ?? 0; + public override int GetHashCode() + => _dbContextType?.GetHashCode() ?? 0; } } diff --git a/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs b/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs index 694f2028735..65f148fde77 100644 --- a/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs +++ b/src/EFCore/Infrastructure/ModelCacheKeyFactory.cs @@ -41,6 +41,7 @@ public ModelCacheKeyFactory([NotNull] ModelCacheKeyFactoryDependencies dependenc /// The context to get the model cache key for. /// /// The created key. - public virtual object Create(DbContext context) => new ModelCacheKey(context); + public virtual object Create(DbContext context) + => new ModelCacheKey(context); } } diff --git a/src/EFCore/Infrastructure/ModelValidator.cs b/src/EFCore/Infrastructure/ModelValidator.cs index 415669c088a..4175ae52c7f 100644 --- a/src/EFCore/Infrastructure/ModelValidator.cs +++ b/src/EFCore/Infrastructure/ModelValidator.cs @@ -84,7 +84,8 @@ public virtual void Validate(IModel model, IDiagnosticsLogger The model. /// The logger to use. protected virtual void ValidateRelationships( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -113,20 +114,23 @@ protected virtual void ValidateRelationships( { if (!skipNavigation.IsCollection) { - throw new InvalidOperationException(CoreStrings.SkipNavigationNonCollection( - skipNavigation.Name, skipNavigation.DeclaringEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.SkipNavigationNonCollection( + skipNavigation.Name, skipNavigation.DeclaringEntityType.DisplayName())); } if (skipNavigation.ForeignKey == null) { - throw new InvalidOperationException(CoreStrings.SkipNavigationNoForeignKey( - skipNavigation.Name, skipNavigation.DeclaringEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.SkipNavigationNoForeignKey( + skipNavigation.Name, skipNavigation.DeclaringEntityType.DisplayName())); } if (skipNavigation.Inverse == null) { - throw new InvalidOperationException(CoreStrings.SkipNavigationNoInverse( - skipNavigation.Name, skipNavigation.DeclaringEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.SkipNavigationNoInverse( + skipNavigation.Name, skipNavigation.DeclaringEntityType.DisplayName())); } } } @@ -138,7 +142,8 @@ protected virtual void ValidateRelationships( /// The model. /// The logger to use. protected virtual void ValidatePropertyMapping( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -184,6 +189,7 @@ protected virtual void ValidatePropertyMapping( { clrProperties.ExceptWith(_dictionaryProperties); } + clrProperties.RemoveWhere(p => entityType.FindIgnoredConfigurationSource(p) != null); if (clrProperties.Count <= 0) @@ -214,7 +220,7 @@ protected virtual void ValidatePropertyMapping( var targetType = FindCandidateNavigationPropertyType(actualProperty); if ((targetType == null // Not a navigation - || targetSequenceType == null) // Not a collection navigation + || targetSequenceType == null) // Not a collection navigation && actualProperty.FindSetterProperty() == null) // No setter property { continue; @@ -288,7 +294,8 @@ private Type FindCandidateNavigationPropertyType(PropertyInfo propertyInfo) /// The model. /// The logger to use. protected virtual void ValidateIgnoredMembers( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -367,7 +374,8 @@ protected virtual void ValidateIgnoredMembers( /// The model to validate. /// The logger to use. protected virtual void ValidateNoShadowEntities( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -385,7 +393,8 @@ protected virtual void ValidateNoShadowEntities( /// The model to validate. /// The logger to use. protected virtual void ValidateNoShadowKeys( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -426,7 +435,8 @@ protected virtual void ValidateNoShadowKeys( /// The model to validate. /// The logger to use. protected virtual void ValidateNoMutableKeys( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -449,7 +459,8 @@ protected virtual void ValidateNoMutableKeys( /// The model to validate. /// The logger to use. protected virtual void ValidateNoCycles( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -505,7 +516,8 @@ protected virtual void ValidateNoCycles( /// The model to validate. /// The logger to use. protected virtual void ValidateNonNullPrimaryKeys( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -526,7 +538,8 @@ var entityTypeWithNullPk /// The model to validate. /// The logger to use. protected virtual void ValidateClrInheritance( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -597,7 +610,8 @@ private void ValidateClrInheritance( /// The logger to use. [Obsolete("Use ValidateInheritanceMapping")] protected virtual void ValidateDiscriminatorValues( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { foreach (var rootEntityType in model.GetRootEntityTypes()) { @@ -611,7 +625,8 @@ protected virtual void ValidateDiscriminatorValues( /// The model to validate. /// The logger to use. protected virtual void ValidateInheritanceMapping( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { #pragma warning disable CS0618 // Type or member is obsolete ValidateDiscriminatorValues(model, logger); @@ -668,7 +683,8 @@ protected virtual void ValidateDiscriminatorValues([NotNull] IEntityType rootEnt /// The model to validate. /// The logger to use. protected virtual void ValidateChangeTrackingStrategy( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -691,7 +707,8 @@ protected virtual void ValidateChangeTrackingStrategy( /// The model to validate. /// The logger to use. protected virtual void ValidateOwnership( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -761,7 +778,8 @@ private bool Contains(IForeignKey inheritedFk, IForeignKey derivedFk) /// The model to validate. /// The logger to use. protected virtual void ValidateForeignKeys( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -812,7 +830,8 @@ protected virtual void ValidateForeignKeys( /// The model to validate. /// The logger to use. protected virtual void ValidateDefiningNavigations( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -863,7 +882,8 @@ protected virtual void ValidateDefiningNavigations( /// The model to validate. /// The logger to use. protected virtual void ValidateFieldMapping( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -924,7 +944,8 @@ protected virtual void ValidateFieldMapping( /// The model to validate. /// The logger to use. protected virtual void ValidateTypeMappings( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); Check.NotNull(logger, nameof(logger)); @@ -962,7 +983,8 @@ protected virtual void ValidateTypeMappings( /// The model to validate. /// The logger to use. protected virtual void ValidateQueryFilters( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); @@ -984,15 +1006,17 @@ protected virtual void ValidateQueryFilters( } var requiredNavigationWithQueryFilter = entityType.GetNavigations() - .Where(n => !n.IsCollection - && n.ForeignKey.IsRequired - && n.IsOnDependent - && n.ForeignKey.PrincipalEntityType.GetQueryFilter() != null - && n.ForeignKey.DeclaringEntityType.GetQueryFilter() == null).FirstOrDefault(); + .Where( + n => !n.IsCollection + && n.ForeignKey.IsRequired + && n.IsOnDependent + && n.ForeignKey.PrincipalEntityType.GetQueryFilter() != null + && n.ForeignKey.DeclaringEntityType.GetQueryFilter() == null).FirstOrDefault(); if (requiredNavigationWithQueryFilter != null) { - logger.PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning(requiredNavigationWithQueryFilter.ForeignKey); + logger.PossibleIncorrectRequiredNavigationWithQueryFilterInteractionWarning( + requiredNavigationWithQueryFilter.ForeignKey); } } } @@ -1133,7 +1157,8 @@ protected virtual void ValidateData([NotNull] IModel model, [NotNull] IDiagnosti /// The model to validate. /// The logger to use. protected virtual void LogShadowProperties( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); diff --git a/src/EFCore/Infrastructure/NavigationBaseExtensions.cs b/src/EFCore/Infrastructure/NavigationBaseExtensions.cs index 390f828ea78..d80a68559fe 100644 --- a/src/EFCore/Infrastructure/NavigationBaseExtensions.cs +++ b/src/EFCore/Infrastructure/NavigationBaseExtensions.cs @@ -20,7 +20,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure public static class NavigationBaseExtensions { /// - /// Calls for a to mark it as loaded + /// Calls for a to mark it as loaded /// when a no-tracking query has eagerly loaded this relationship. /// /// The navigation loaded. diff --git a/src/EFCore/Infrastructure/ServiceCharacteristics.cs b/src/EFCore/Infrastructure/ServiceCharacteristics.cs index 1539e4ef4f0..8d96ebeadb9 100644 --- a/src/EFCore/Infrastructure/ServiceCharacteristics.cs +++ b/src/EFCore/Infrastructure/ServiceCharacteristics.cs @@ -14,7 +14,10 @@ public readonly struct ServiceCharacteristics /// Creates a new struct. /// /// The service lifetime. - /// if multiple registrations of the service is allowed; otherwise. + /// + /// if multiple registrations of the service is allowed; + /// otherwise. + /// public ServiceCharacteristics(ServiceLifetime lifetime, bool multipleRegistrations = false) { Lifetime = lifetime; @@ -27,7 +30,7 @@ public ServiceCharacteristics(ServiceLifetime lifetime, bool multipleRegistratio public ServiceLifetime Lifetime { get; } /// - /// if multiple registrations of the service is allowed; otherwise. + /// if multiple registrations of the service is allowed; otherwise. /// public bool MultipleRegistrations { get; } } diff --git a/src/EFCore/Infrastructure/ServiceCollectionMap.cs b/src/EFCore/Infrastructure/ServiceCollectionMap.cs index 5704c02b8b9..8d07f30b62c 100644 --- a/src/EFCore/Infrastructure/ServiceCollectionMap.cs +++ b/src/EFCore/Infrastructure/ServiceCollectionMap.cs @@ -40,7 +40,8 @@ public ServiceCollectionMap([NotNull] IServiceCollection serviceCollection) /// /// The underlying . /// - public virtual IServiceCollection ServiceCollection => _map.ServiceCollection; + public virtual IServiceCollection ServiceCollection + => _map.ServiceCollection; /// /// Adds a service implemented by the given concrete @@ -508,6 +509,7 @@ private static Type TryGetImplementationType(ServiceDescriptor descriptor) // Generic arg on Func may be object, but this is the best we can do and matches logic in D.I. container ?? descriptor.ImplementationFactory?.GetType().GenericTypeArguments[1]; - IInternalServiceCollectionMap IInfrastructure.Instance => _map; + IInternalServiceCollectionMap IInfrastructure.Instance + => _map; } } diff --git a/src/EFCore/Infrastructure/Uniquifier.cs b/src/EFCore/Infrastructure/Uniquifier.cs index 5b2b32b76e4..6a22796937c 100644 --- a/src/EFCore/Infrastructure/Uniquifier.cs +++ b/src/EFCore/Infrastructure/Uniquifier.cs @@ -22,7 +22,9 @@ public static class Uniquifier /// The maximum length of the identifier. /// A unique identifier. public static string Uniquify( - [NotNull] string currentIdentifier, [NotNull] IReadOnlyDictionary otherIdentifiers, int maxLength) + [NotNull] string currentIdentifier, + [NotNull] IReadOnlyDictionary otherIdentifiers, + int maxLength) { var finalIdentifier = Truncate(currentIdentifier, maxLength); var suffix = 1; diff --git a/src/EFCore/Internal/DbContextLease.cs b/src/EFCore/Internal/DbContextLease.cs index 5b21eef175d..060d955bc65 100644 --- a/src/EFCore/Internal/DbContextLease.cs +++ b/src/EFCore/Internal/DbContextLease.cs @@ -56,7 +56,8 @@ public DbContextLease([NotNull] IDbContextPool contextPool, bool standalone) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public bool IsActive => _contextPool != null; + public bool IsActive + => _contextPool != null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Internal/DbContextServices.cs b/src/EFCore/Internal/DbContextServices.cs index d4cfce1a18d..a71efc96200 100644 --- a/src/EFCore/Internal/DbContextServices.cs +++ b/src/EFCore/Internal/DbContextServices.cs @@ -98,7 +98,8 @@ private IModel CreateModel() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ICurrentDbContext CurrentContext => _currentContext; + public virtual ICurrentDbContext CurrentContext + => _currentContext; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -119,7 +120,8 @@ private CoreOptionsExtension CoreOptions /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IDbContextOptions ContextOptions => _contextOptions; + public virtual IDbContextOptions ContextOptions + => _contextOptions; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -127,6 +129,7 @@ private CoreOptionsExtension CoreOptions /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IServiceProvider InternalServiceProvider => _scopedProvider; + public virtual IServiceProvider InternalServiceProvider + => _scopedProvider; } } diff --git a/src/EFCore/Internal/DbSetSource.cs b/src/EFCore/Internal/DbSetSource.cs index 044d4457852..b575c6f4b4c 100644 --- a/src/EFCore/Internal/DbSetSource.cs +++ b/src/EFCore/Internal/DbSetSource.cs @@ -51,7 +51,7 @@ public virtual object Create(DbContext context, string name, Type type) private object CreateCore(DbContext context, Type type, string name, MethodInfo createMethod) => _cache.GetOrAdd( (type, name), - t => (Func)createMethod + t => (Func)createMethod .MakeGenericMethod(t.Type) .Invoke(null, null))(context, name); diff --git a/src/EFCore/Internal/EntityFinder.cs b/src/EFCore/Internal/EntityFinder.cs index 923238b7dd1..e53fea3efad 100644 --- a/src/EFCore/Internal/EntityFinder.cs +++ b/src/EFCore/Internal/EntityFinder.cs @@ -206,7 +206,8 @@ public virtual object[] GetDatabaseValues(InternalEntityEntry entry) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual Task GetDatabaseValuesAsync( - InternalEntityEntry entry, CancellationToken cancellationToken = default) + InternalEntityEntry entry, + CancellationToken cancellationToken = default) => GetDatabaseValuesQuery(entry)?.FirstOrDefaultAsync(cancellationToken); private IQueryable GetDatabaseValuesQuery(InternalEntityEntry entry) @@ -343,7 +344,8 @@ private static readonly MethodInfo _selectMethod = typeof(EntityFinder).GetTypeInfo().GetDeclaredMethods(nameof(Select)).Single(mi => mi.IsGenericMethodDefinition); private static IQueryable Select( - [NotNull] IQueryable source, [NotNull] string propertyName) + [NotNull] IQueryable source, + [NotNull] string propertyName) where TResult : class where TSource : class { @@ -358,7 +360,8 @@ private static readonly MethodInfo _selectManyMethod = typeof(EntityFinder).GetTypeInfo().GetDeclaredMethods(nameof(SelectMany)).Single(mi => mi.IsGenericMethodDefinition); private static IQueryable SelectMany( - [NotNull] IQueryable source, [NotNull] string propertyName) + [NotNull] IQueryable source, + [NotNull] string propertyName) where TResult : class where TSource : class { diff --git a/src/EFCore/Internal/EntityFinderSource.cs b/src/EFCore/Internal/EntityFinderSource.cs index 6483747f988..ad3efe58b28 100644 --- a/src/EFCore/Internal/EntityFinderSource.cs +++ b/src/EFCore/Internal/EntityFinderSource.cs @@ -39,7 +39,10 @@ private readonly ConcurrentDictionary public virtual IEntityFinder Create( - IStateManager stateManager, IDbSetSource setSource, IDbSetCache setCache, IEntityType type) + IStateManager stateManager, + IDbSetSource setSource, + IDbSetCache setCache, + IEntityType type) => _cache.GetOrAdd( type.ClrType, t => (Func) diff --git a/src/EFCore/Internal/IDbContextPoolable.cs b/src/EFCore/Internal/IDbContextPoolable.cs index 98396504f6d..6d1007ed480 100644 --- a/src/EFCore/Internal/IDbContextPoolable.cs +++ b/src/EFCore/Internal/IDbContextPoolable.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Infrastructure; namespace Microsoft.EntityFrameworkCore.Internal diff --git a/src/EFCore/Internal/IEntityFinder.cs b/src/EFCore/Internal/IEntityFinder.cs index c0d3ae252de..bff3505f272 100644 --- a/src/EFCore/Internal/IEntityFinder.cs +++ b/src/EFCore/Internal/IEntityFinder.cs @@ -76,6 +76,7 @@ Task LoadAsync( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// Task GetDatabaseValuesAsync( - [NotNull] InternalEntityEntry entry, CancellationToken cancellationToken = default); + [NotNull] InternalEntityEntry entry, + CancellationToken cancellationToken = default); } } diff --git a/src/EFCore/Internal/InternalDbSet.cs b/src/EFCore/Internal/InternalDbSet.cs index 38406bbde6c..eb4cd5b44d8 100644 --- a/src/EFCore/Internal/InternalDbSet.cs +++ b/src/EFCore/Internal/InternalDbSet.cs @@ -445,7 +445,8 @@ private IEntityFinder Finder /// 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. /// - IEnumerator IEnumerable.GetEnumerator() => EntityQueryable.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => EntityQueryable.GetEnumerator(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -453,7 +454,8 @@ private IEntityFinder Finder /// 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. /// - IEnumerator IEnumerable.GetEnumerator() => EntityQueryable.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => EntityQueryable.GetEnumerator(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -470,7 +472,8 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(Cancellat /// 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. /// - Type IQueryable.ElementType => EntityQueryable.ElementType; + Type IQueryable.ElementType + => EntityQueryable.ElementType; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -478,7 +481,8 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(Cancellat /// 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. /// - Expression IQueryable.Expression => EntityQueryable.Expression; + Expression IQueryable.Expression + => EntityQueryable.Expression; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -486,7 +490,8 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(Cancellat /// 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. /// - IQueryProvider IQueryable.Provider => EntityQueryable.Provider; + IQueryProvider IQueryable.Provider + => EntityQueryable.Provider; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -503,7 +508,8 @@ IServiceProvider IInfrastructure.Instance /// 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. /// - void IResettableService.ResetState() => _localView = null; + void IResettableService.ResetState() + => _localView = null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Internal/LazyLoader.cs b/src/EFCore/Internal/LazyLoader.cs index 39fcec616b4..6f2d99c5475 100644 --- a/src/EFCore/Internal/LazyLoader.cs +++ b/src/EFCore/Internal/LazyLoader.cs @@ -169,6 +169,7 @@ private bool ShouldLoad(object entity, string navigationName, out NavigationEntr /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual void Dispose() => _disposed = true; + public virtual void Dispose() + => _disposed = true; } } diff --git a/src/EFCore/Internal/ManyToManyLoader.cs b/src/EFCore/Internal/ManyToManyLoader.cs index 76d1417ef3f..f09dd716729 100644 --- a/src/EFCore/Internal/ManyToManyLoader.cs +++ b/src/EFCore/Internal/ManyToManyLoader.cs @@ -181,7 +181,8 @@ private static Expression>> BuildInclud } private static Expression> BuildWhereLambda( - IReadOnlyList keyProperties, ValueBuffer keyValues) + IReadOnlyList keyProperties, + ValueBuffer keyValues) { var entityParameter = Expression.Parameter(typeof(TSourceEntity), "e"); diff --git a/src/EFCore/Internal/ScopedDbContextLease.cs b/src/EFCore/Internal/ScopedDbContextLease.cs index 8fc7bab7548..769a82627c7 100644 --- a/src/EFCore/Internal/ScopedDbContextLease.cs +++ b/src/EFCore/Internal/ScopedDbContextLease.cs @@ -33,7 +33,8 @@ public ScopedDbContextLease([NotNull] IDbContextPool contextPool) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public TContext Context => (TContext)_lease.Context; + public TContext Context + => (TContext)_lease.Context; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Builders/CollectionCollectionBuilder.cs b/src/EFCore/Metadata/Builders/CollectionCollectionBuilder.cs index 47719064390..7cb1c592aec 100644 --- a/src/EFCore/Metadata/Builders/CollectionCollectionBuilder.cs +++ b/src/EFCore/Metadata/Builders/CollectionCollectionBuilder.cs @@ -81,7 +81,8 @@ public CollectionCollectionBuilder( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - protected virtual InternalModelBuilder ModelBuilder => LeftEntityType.AsEntityType().Model.Builder; + protected virtual InternalModelBuilder ModelBuilder + => LeftEntityType.AsEntityType().Model.Builder; /// /// Configures the join entity type implementing the many-to-many relationship. @@ -93,7 +94,8 @@ public virtual EntityTypeBuilder UsingEntity( { Check.DebugAssert(LeftNavigation.JoinEntityType != null, "LeftNavigation.JoinEntityType is null"); Check.DebugAssert(RightNavigation.JoinEntityType != null, "RightNavigation.JoinEntityType is null"); - Check.DebugAssert(LeftNavigation.JoinEntityType == RightNavigation.JoinEntityType, + Check.DebugAssert( + LeftNavigation.JoinEntityType == RightNavigation.JoinEntityType, "LeftNavigation.JoinEntityType != RightNavigation.JoinEntityType"); var joinEntityTypeBuilder = new EntityTypeBuilder(LeftNavigation.JoinEntityType); @@ -200,7 +202,8 @@ public virtual EntityTypeBuilder UsingEntity( throw new InvalidOperationException(CoreStrings.TypeNotMarkedAsShared(joinEntityType.DisplayName())); } - newJoinEntityType = ModelBuilder.SharedTypeEntity(joinEntityName, joinEntityType, ConfigurationSource.Explicit).Metadata; + newJoinEntityType = ModelBuilder.SharedTypeEntity(joinEntityName, joinEntityType, ConfigurationSource.Explicit) + .Metadata; } } @@ -292,17 +295,20 @@ protected virtual void Using([NotNull] IMutableForeignKey rightForeignKey, [NotN /// [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/CollectionCollectionBuilder`.cs b/src/EFCore/Metadata/Builders/CollectionCollectionBuilder`.cs index 5b2c84d3b34..f16ba850548 100644 --- a/src/EFCore/Metadata/Builders/CollectionCollectionBuilder`.cs +++ b/src/EFCore/Metadata/Builders/CollectionCollectionBuilder`.cs @@ -51,7 +51,8 @@ public CollectionCollectionBuilder( { Check.DebugAssert(LeftNavigation.JoinEntityType != null, "LeftNavigation.JoinEntityType is null"); Check.DebugAssert(RightNavigation.JoinEntityType != null, "RightNavigation.JoinEntityType is null"); - Check.DebugAssert(LeftNavigation.JoinEntityType == RightNavigation.JoinEntityType, + Check.DebugAssert( + LeftNavigation.JoinEntityType == RightNavigation.JoinEntityType, "LeftNavigation.JoinEntityType != RightNavigation.JoinEntityType"); var joinEntityTypeBuilder = new EntityTypeBuilder(LeftNavigation.JoinEntityType); @@ -156,7 +157,8 @@ public virtual EntityTypeBuilder UsingEntity( throw new InvalidOperationException(CoreStrings.TypeNotMarkedAsShared(typeof(TJoinEntity).DisplayName())); } - joinEntityType = ModelBuilder.SharedTypeEntity(joinEntityName, typeof(TJoinEntity), ConfigurationSource.Explicit).Metadata; + joinEntityType = ModelBuilder.SharedTypeEntity(joinEntityName, typeof(TJoinEntity), ConfigurationSource.Explicit) + .Metadata; } } diff --git a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs index 471054ee51d..780a4f05962 100644 --- a/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs +++ b/src/EFCore/Metadata/Builders/CollectionNavigationBuilder.cs @@ -102,7 +102,8 @@ public CollectionNavigationBuilder( /// not directly exposed in the public API surface. /// /// - IConventionForeignKeyBuilder IInfrastructure.Instance => Builder; + IConventionForeignKeyBuilder IInfrastructure.Instance + => Builder; /// /// @@ -159,13 +160,15 @@ private InternalForeignKeyBuilder WithOneBuilder(MemberIdentity reference) throw new InvalidOperationException( CoreStrings.ConflictingRelationshipNavigation( SkipNavigation.DeclaringEntityType.DisplayName() + "." + SkipNavigation.Name, - RelatedEntityType.DisplayName() + (reference.Name == null - ? "" - : "." + reference.Name), + RelatedEntityType.DisplayName() + + (reference.Name == null + ? "" + : "." + reference.Name), SkipNavigation.DeclaringEntityType.DisplayName() + "." + SkipNavigation.Name, - SkipNavigation.TargetEntityType.DisplayName() + (SkipNavigation.Inverse == null - ? "" - : "." + SkipNavigation.Inverse.Name))); + SkipNavigation.TargetEntityType.DisplayName() + + (SkipNavigation.Inverse == null + ? "" + : "." + SkipNavigation.Inverse.Name))); } var navigationName = SkipNavigation.Name; @@ -327,7 +330,9 @@ protected virtual IMutableSkipNavigation WithRightManyNavigation([NotNull] strin /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - protected virtual IMutableSkipNavigation WithRightManyNavigation([NotNull] MemberInfo navigationMemberInfo, [NotNull] string inverseName) + protected virtual IMutableSkipNavigation WithRightManyNavigation( + [NotNull] MemberInfo navigationMemberInfo, + [NotNull] string inverseName) => WithRightManyNavigation(MemberIdentity.Create(navigationMemberInfo), inverseName); private IMutableSkipNavigation WithRightManyNavigation(MemberIdentity navigationMember, [NotNull] string inverseName) @@ -372,16 +377,18 @@ private IMutableSkipNavigation WithRightManyNavigation(MemberIdentity navigation /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -389,7 +396,8 @@ private IMutableSkipNavigation WithRightManyNavigation(MemberIdentity navigation /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/DataBuilder.cs b/src/EFCore/Metadata/Builders/DataBuilder.cs index 65afe16eef1..76fd5b152ba 100644 --- a/src/EFCore/Metadata/Builders/DataBuilder.cs +++ b/src/EFCore/Metadata/Builders/DataBuilder.cs @@ -29,22 +29,25 @@ public DataBuilder() /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/DiscriminatorBuilder.cs b/src/EFCore/Metadata/Builders/DiscriminatorBuilder.cs index dd574a17e93..784d50b7e5b 100644 --- a/src/EFCore/Metadata/Builders/DiscriminatorBuilder.cs +++ b/src/EFCore/Metadata/Builders/DiscriminatorBuilder.cs @@ -58,7 +58,8 @@ private DiscriminatorBuilder IsComplete(bool complete, ConfigurationSource confi return null; } - EntityTypeBuilder.Metadata.SetDiscriminatorMappingComplete(complete, configurationSource == ConfigurationSource.DataAnnotation); + EntityTypeBuilder.Metadata.SetDiscriminatorMappingComplete( + complete, configurationSource == ConfigurationSource.DataAnnotation); } return this; @@ -110,7 +111,9 @@ public virtual DiscriminatorBuilder HasValue([NotNull] string entityTypeName, [C } private DiscriminatorBuilder HasValue( - InternalEntityTypeBuilder entityTypeBuilder, object value, ConfigurationSource configurationSource) + InternalEntityTypeBuilder entityTypeBuilder, + object value, + ConfigurationSource configurationSource) { if (entityTypeBuilder == null) { @@ -120,9 +123,9 @@ private DiscriminatorBuilder HasValue( var baseEntityTypeBuilder = EntityTypeBuilder; if (!baseEntityTypeBuilder.Metadata.IsAssignableFrom(entityTypeBuilder.Metadata) && ((baseEntityTypeBuilder.Metadata.ClrType != null - && entityTypeBuilder.Metadata.ClrType != null - && !baseEntityTypeBuilder.Metadata.ClrType.IsAssignableFrom(entityTypeBuilder.Metadata.ClrType)) - || entityTypeBuilder.HasBaseType(baseEntityTypeBuilder.Metadata, configurationSource) == null)) + && entityTypeBuilder.Metadata.ClrType != null + && !baseEntityTypeBuilder.Metadata.ClrType.IsAssignableFrom(entityTypeBuilder.Metadata.ClrType)) + || entityTypeBuilder.HasBaseType(baseEntityTypeBuilder.Metadata, configurationSource) == null)) { throw new InvalidOperationException( CoreStrings.DiscriminatorEntityTypeNotDerived( @@ -164,7 +167,9 @@ IConventionDiscriminatorBuilder IConventionDiscriminatorBuilder.HasValue(object /// IConventionDiscriminatorBuilder IConventionDiscriminatorBuilder.HasValue( - IConventionEntityType entityType, object value, bool fromDataAnnotation) + IConventionEntityType entityType, + object value, + bool fromDataAnnotation) => HasValue( (InternalEntityTypeBuilder)entityType.Builder, value, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -193,16 +198,18 @@ bool IConventionDiscriminatorBuilder.CanSetValue(IConventionEntityType entityTyp /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -210,7 +217,8 @@ bool IConventionDiscriminatorBuilder.CanSetValue(IConventionEntityType entityTyp /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs b/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs index c58466e7a02..a3c89d81add 100644 --- a/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs +++ b/src/EFCore/Metadata/Builders/EntityTypeBuilder.cs @@ -44,12 +44,14 @@ public EntityTypeBuilder([NotNull] IMutableEntityType entityType) /// /// Gets the internal builder being used to configure the entity type. /// - IConventionEntityTypeBuilder IInfrastructure.Instance => Builder; + IConventionEntityTypeBuilder IInfrastructure.Instance + => Builder; /// /// The entity type being configured. /// - public virtual IMutableEntityType Metadata => Builder.Metadata; + public virtual IMutableEntityType Metadata + => Builder.Metadata; /// /// Adds or updates an annotation on the entity type. If an annotation with the key specified in @@ -840,14 +842,14 @@ protected virtual ForeignKey HasOneBuilder( if (navigationId.MemberInfo != null) { foreignKey = Builder.HasRelationship( - relatedEntityType, navigationId.MemberInfo, ConfigurationSource.Explicit, - targetIsPrincipal: Builder.Metadata == relatedEntityType ? true : (bool?)null).Metadata; + relatedEntityType, navigationId.MemberInfo, ConfigurationSource.Explicit, + targetIsPrincipal: Builder.Metadata == relatedEntityType ? true : (bool?)null).Metadata; } else { foreignKey = Builder.HasRelationship( - relatedEntityType, navigationId.Name, ConfigurationSource.Explicit, - targetIsPrincipal: Builder.Metadata == relatedEntityType ? true : (bool?)null).Metadata; + relatedEntityType, navigationId.Name, ConfigurationSource.Explicit, + targetIsPrincipal: Builder.Metadata == relatedEntityType ? true : (bool?)null).Metadata; } return foreignKey; @@ -879,7 +881,8 @@ public virtual CollectionNavigationBuilder HasMany( Check.NotEmpty(relatedTypeName, nameof(relatedTypeName)); Check.NullButNotEmpty(navigationName, nameof(navigationName)); - return HasMany(navigationName, + return HasMany( + navigationName, FindRelatedEntityType(relatedTypeName, navigationName)); } @@ -956,7 +959,8 @@ public virtual CollectionNavigationBuilder HasMany( Check.NotNull(relatedType, nameof(relatedType)); Check.NullButNotEmpty(navigationName, nameof(navigationName)); - return HasMany(navigationName, + return HasMany( + navigationName, FindRelatedEntityType(relatedType, navigationName)); } @@ -1129,16 +1133,18 @@ public virtual EntityTypeBuilder HasNoDiscriminator() /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -1146,7 +1152,8 @@ public virtual EntityTypeBuilder HasNoDiscriminator() /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs b/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs index 28c1f7a8c94..c3724d5fe48 100644 --- a/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs +++ b/src/EFCore/Metadata/Builders/EntityTypeBuilder`.cs @@ -159,8 +159,8 @@ public virtual PropertyBuilder Property([NotNull] Expressi .Metadata); /// - /// Returns an object that can be used to configure an existing navigation property of the entity type. - /// It is an error for the navigation property not to exist. + /// Returns an object that can be used to configure an existing navigation property of the entity type. + /// It is an error for the navigation property not to exist. /// /// The target entity type. /// @@ -176,8 +176,8 @@ public virtual NavigationBuilder Navigation( Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); /// - /// Returns an object that can be used to configure an existing navigation property of the entity type. - /// It is an error for the navigation property not to exist. + /// Returns an object that can be used to configure an existing navigation property of the entity type. + /// It is an error for the navigation property not to exist. /// /// The target entity type. /// @@ -476,8 +476,9 @@ public virtual EntityTypeBuilder OwnsOne( Check.NotEmpty(navigationName, nameof(navigationName)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsOneBuilder( - new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), new MemberIdentity(navigationName))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), new MemberIdentity(navigationName))); return this; } @@ -604,8 +605,9 @@ public virtual EntityTypeBuilder OwnsOne( Check.NotEmpty(navigationName, nameof(navigationName)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsOneBuilder( - new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationName))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationName))); return this; } @@ -641,8 +643,10 @@ public virtual EntityTypeBuilder OwnsOne( Check.NotNull(navigationExpression, nameof(navigationExpression)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsOneBuilder( - new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), + new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } @@ -681,13 +685,15 @@ public virtual EntityTypeBuilder OwnsOne( Check.NotNull(navigationExpression, nameof(navigationExpression)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsOneBuilder( - new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } private OwnedNavigationBuilder OwnsOneBuilder( - TypeIdentity ownedType, MemberIdentity navigation) + TypeIdentity ownedType, + MemberIdentity navigation) where TRelatedEntity : class { InternalForeignKeyBuilder relationship; @@ -854,8 +860,9 @@ public virtual EntityTypeBuilder OwnsMany( Check.NotEmpty(navigationName, nameof(navigationName)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsManyBuilder( - new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), new MemberIdentity(navigationName))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), new MemberIdentity(navigationName))); return this; } @@ -982,8 +989,9 @@ public virtual EntityTypeBuilder OwnsMany( Check.NotEmpty(navigationName, nameof(navigationName)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsManyBuilder( - new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationName))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationName))); return this; } @@ -1019,8 +1027,10 @@ public virtual EntityTypeBuilder OwnsMany( Check.NotNull(navigationExpression, nameof(navigationExpression)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsManyBuilder( - new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(typeof(TRelatedEntity), (Model)Metadata.Model), + new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } @@ -1059,13 +1069,15 @@ public virtual EntityTypeBuilder OwnsMany( Check.NotNull(navigationExpression, nameof(navigationExpression)); Check.NotNull(buildAction, nameof(buildAction)); - buildAction(OwnsManyBuilder( - new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(ownedTypeName, typeof(TRelatedEntity)), new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } private OwnedNavigationBuilder OwnsManyBuilder( - TypeIdentity ownedType, MemberIdentity navigation) + TypeIdentity ownedType, + MemberIdentity navigation) where TRelatedEntity : class { InternalForeignKeyBuilder relationship; @@ -1372,6 +1384,7 @@ public virtual DiscriminatorBuilder HasDiscriminator HasNoDiscriminator() => (EntityTypeBuilder)base.HasNoDiscriminator(); - private InternalEntityTypeBuilder Builder => (InternalEntityTypeBuilder)this.GetInfrastructure(); + private InternalEntityTypeBuilder Builder + => (InternalEntityTypeBuilder)this.GetInfrastructure(); } } diff --git a/src/EFCore/Metadata/Builders/IConventionAnnotatableBuilder.cs b/src/EFCore/Metadata/Builders/IConventionAnnotatableBuilder.cs index 4a071d9684c..c54a55dbbea 100644 --- a/src/EFCore/Metadata/Builders/IConventionAnnotatableBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionAnnotatableBuilder.cs @@ -52,7 +52,9 @@ public interface IConventionAnnotatableBuilder /// otherwise. /// IConventionAnnotatableBuilder HasNonNullAnnotation( - [NotNull] string name, [CanBeNull] object value, bool fromDataAnnotation = false); + [NotNull] string name, + [CanBeNull] object value, + bool fromDataAnnotation = false); /// /// Sets or removes the annotation stored under the given name. @@ -66,7 +68,9 @@ IConventionAnnotatableBuilder HasNonNullAnnotation( /// [Obsolete("Use HasNonNullAnnotation")] IConventionAnnotatableBuilder SetOrRemoveAnnotation( - [NotNull] string name, [CanBeNull] object value, bool fromDataAnnotation = false) + [NotNull] string name, + [CanBeNull] object value, + bool fromDataAnnotation = false) => HasNonNullAnnotation(name, value, fromDataAnnotation); /// diff --git a/src/EFCore/Metadata/Builders/IConventionDiscriminatorBuilder.cs b/src/EFCore/Metadata/Builders/IConventionDiscriminatorBuilder.cs index 24fd237c11b..562979ef77d 100644 --- a/src/EFCore/Metadata/Builders/IConventionDiscriminatorBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionDiscriminatorBuilder.cs @@ -42,7 +42,9 @@ public interface IConventionDiscriminatorBuilder /// Indicates whether the configuration was specified using a data annotation. /// The same builder so that multiple calls can be chained. IConventionDiscriminatorBuilder HasValue( - [NotNull] IConventionEntityType entityType, [CanBeNull] object value, bool fromDataAnnotation = false); + [NotNull] IConventionEntityType entityType, + [CanBeNull] object value, + bool fromDataAnnotation = false); /// /// Returns a value indicating whether the discriminator value can be set from this configuration source. diff --git a/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs b/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs index 5b5ef5c30f3..65c792651c8 100644 --- a/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionEntityTypeBuilder.cs @@ -35,7 +35,8 @@ public interface IConventionEntityTypeBuilder : IConventionAnnotatableBuilder /// otherwise. /// IConventionEntityTypeBuilder HasBaseType( - [CanBeNull] IConventionEntityType baseEntityType, bool fromDataAnnotation = false); + [CanBeNull] IConventionEntityType baseEntityType, + bool fromDataAnnotation = false); /// /// Returns a value indicating whether the given type can be set as the base type of this entity type. @@ -94,7 +95,8 @@ IConventionPropertyBuilder Property( /// Indicates whether the configuration was specified using a data annotation. /// A list of properties if they exist on the entity type, otherwise. IReadOnlyList GetOrCreateProperties( - [CanBeNull] IReadOnlyList propertyNames, bool fromDataAnnotation = false); + [CanBeNull] IReadOnlyList propertyNames, + bool fromDataAnnotation = false); /// /// Returns the existing properties matching the given members or creates them. @@ -103,7 +105,8 @@ IReadOnlyList GetOrCreateProperties( /// Indicates whether the configuration was specified using a data annotation. /// A list of properties if they exist on the entity type, otherwise. IReadOnlyList GetOrCreateProperties( - [CanBeNull] IEnumerable memberInfos, bool fromDataAnnotation = false); + [CanBeNull] IEnumerable memberInfos, + bool fromDataAnnotation = false); /// /// Removes properties in the given list if they are not part of any metadata object. @@ -118,7 +121,8 @@ IReadOnlyList GetOrCreateProperties( /// Indicates whether the configuration was specified using a data annotation. [Obsolete("Use RemoveUnusedImplicitProperties")] IConventionEntityTypeBuilder RemoveUnusedShadowProperties( - [NotNull] IReadOnlyList properties, bool fromDataAnnotation = false) + [NotNull] IReadOnlyList properties, + bool fromDataAnnotation = false) => RemoveUnusedImplicitProperties(properties); /// @@ -132,7 +136,8 @@ IConventionEntityTypeBuilder RemoveUnusedShadowProperties( /// otherwise. /// IConventionServicePropertyBuilder ServiceProperty( - [NotNull] MemberInfo memberInfo, bool fromDataAnnotation = false); + [NotNull] MemberInfo memberInfo, + bool fromDataAnnotation = false); /// /// Indicates whether the given member name is ignored for the given configuration source. @@ -259,7 +264,8 @@ IConventionServicePropertyBuilder ServiceProperty( /// otherwise. /// IConventionIndexBuilder HasIndex( - [NotNull] IReadOnlyList propertyNames, bool fromDataAnnotation = false); + [NotNull] IReadOnlyList propertyNames, + bool fromDataAnnotation = false); /// /// Configures an index on the specified property names. @@ -290,7 +296,8 @@ IConventionIndexBuilder HasIndex( /// otherwise. /// IConventionIndexBuilder HasIndex( - [NotNull] IReadOnlyList properties, bool fromDataAnnotation = false); + [NotNull] IReadOnlyList properties, + bool fromDataAnnotation = false); /// /// Configures an index on the specified properties, with the specified name. @@ -346,7 +353,8 @@ IConventionIndexBuilder HasIndex( /// Indicates whether the configuration was specified using a data annotation. /// An object that can be used to configure the relationship. IConventionForeignKeyBuilder HasRelationship( - [NotNull] IConventionEntityType targetEntityType, bool fromDataAnnotation = false); + [NotNull] IConventionEntityType targetEntityType, + bool fromDataAnnotation = false); /// /// Configures a relationship between this and the target entity type with the target as the principal end. @@ -749,7 +757,8 @@ IConventionSkipNavigationBuilder HasSkipNavigation( /// otherwise. /// IConventionEntityTypeBuilder HasChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, bool fromDataAnnotation = false); + ChangeTrackingStrategy? changeTrackingStrategy, + bool fromDataAnnotation = false); /// /// Returns a value indicating whether the given change tracking strategy can be set from the current configuration source. @@ -776,7 +785,8 @@ IConventionEntityTypeBuilder HasChangeTrackingStrategy( /// otherwise. /// IConventionEntityTypeBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation = false); + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation = false); /// /// Returns a value indicating whether the given can be set from the current configuration source. diff --git a/src/EFCore/Metadata/Builders/IConventionForeignKeyBuilder.cs b/src/EFCore/Metadata/Builders/IConventionForeignKeyBuilder.cs index afa97f40348..7699aabc49c 100644 --- a/src/EFCore/Metadata/Builders/IConventionForeignKeyBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionForeignKeyBuilder.cs @@ -79,7 +79,8 @@ bool CanInvert( /// otherwise. /// IConventionForeignKeyBuilder HasForeignKey( - [CanBeNull] IReadOnlyList propertyNames, bool fromDataAnnotation = false); + [CanBeNull] IReadOnlyList propertyNames, + bool fromDataAnnotation = false); /// /// Configures the properties to use as the foreign key for this relationship. @@ -91,7 +92,8 @@ IConventionForeignKeyBuilder HasForeignKey( /// otherwise. /// IConventionForeignKeyBuilder HasForeignKey( - [CanBeNull] IReadOnlyList properties, bool fromDataAnnotation = false); + [CanBeNull] IReadOnlyList properties, + bool fromDataAnnotation = false); /// /// Returns a value indicating whether the given properties can be set as the foreign key for this relationship @@ -121,7 +123,8 @@ IConventionForeignKeyBuilder HasForeignKey( /// otherwise. /// IConventionForeignKeyBuilder HasPrincipalKey( - [CanBeNull] IReadOnlyList propertyNames, bool fromDataAnnotation = false); + [CanBeNull] IReadOnlyList propertyNames, + bool fromDataAnnotation = false); /// /// Configures the properties that this relationship targets. @@ -133,7 +136,8 @@ IConventionForeignKeyBuilder HasPrincipalKey( /// otherwise. /// IConventionForeignKeyBuilder HasPrincipalKey( - [CanBeNull] IReadOnlyList properties, bool fromDataAnnotation = false); + [CanBeNull] IReadOnlyList properties, + bool fromDataAnnotation = false); /// /// Returns a value indicating whether the given properties can be set as the target for this relationship diff --git a/src/EFCore/Metadata/Builders/IConventionModelBuilder.cs b/src/EFCore/Metadata/Builders/IConventionModelBuilder.cs index 7b02a065076..aff274c68b5 100644 --- a/src/EFCore/Metadata/Builders/IConventionModelBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionModelBuilder.cs @@ -63,7 +63,11 @@ public interface IConventionModelBuilder : IConventionAnnotatableBuilder /// An object that can be used to configure the entity type if the entity type was added or already part of the model, /// otherwise. /// - IConventionEntityTypeBuilder SharedTypeEntity([NotNull] string name, [NotNull] Type type, bool? shouldBeOwned = false, bool fromDataAnnotation = false); + IConventionEntityTypeBuilder SharedTypeEntity( + [NotNull] string name, + [NotNull] Type type, + bool? shouldBeOwned = false, + bool fromDataAnnotation = false); /// /// Returns an object that can be used to configure a given entity type in the model. diff --git a/src/EFCore/Metadata/Builders/IConventionPropertyBuilder.cs b/src/EFCore/Metadata/Builders/IConventionPropertyBuilder.cs index 83f990f5aaf..557f1708f34 100644 --- a/src/EFCore/Metadata/Builders/IConventionPropertyBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionPropertyBuilder.cs @@ -276,7 +276,8 @@ IConventionPropertyBuilder HasValueGenerator( /// if the can be configured for this property. /// bool CanSetValueGenerator( - [CanBeNull] Func factory, bool fromDataAnnotation = false); + [CanBeNull] Func factory, + bool fromDataAnnotation = false); /// /// Configures the property so that the property value is converted to and from the database diff --git a/src/EFCore/Metadata/Builders/IConventionServicePropertyBuilder.cs b/src/EFCore/Metadata/Builders/IConventionServicePropertyBuilder.cs index 5894004a12b..7ccc88b686d 100644 --- a/src/EFCore/Metadata/Builders/IConventionServicePropertyBuilder.cs +++ b/src/EFCore/Metadata/Builders/IConventionServicePropertyBuilder.cs @@ -53,7 +53,9 @@ public interface IConventionServicePropertyBuilder : IConventionPropertyBaseBuil /// The same builder instance if the configuration was applied, /// otherwise. /// - new IConventionServicePropertyBuilder UsePropertyAccessMode(PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation = false); + new IConventionServicePropertyBuilder UsePropertyAccessMode( + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation = false); /// /// Sets the for this property. @@ -65,7 +67,8 @@ public interface IConventionServicePropertyBuilder : IConventionPropertyBaseBuil /// otherwise. /// IConventionServicePropertyBuilder HasParameterBinding( - [CanBeNull] ServiceParameterBinding parameterBinding, bool fromDataAnnotation = false); + [CanBeNull] ServiceParameterBinding parameterBinding, + bool fromDataAnnotation = false); /// /// Returns a value indicating whether the can be set for this property. diff --git a/src/EFCore/Metadata/Builders/IndexBuilder.cs b/src/EFCore/Metadata/Builders/IndexBuilder.cs index ab92e068f62..4785b569748 100644 --- a/src/EFCore/Metadata/Builders/IndexBuilder.cs +++ b/src/EFCore/Metadata/Builders/IndexBuilder.cs @@ -35,14 +35,16 @@ public IndexBuilder([NotNull] IMutableIndex index) /// /// The internal builder being used to configure the index. /// - IConventionIndexBuilder IInfrastructure.Instance => Builder; + IConventionIndexBuilder IInfrastructure.Instance + => Builder; private InternalIndexBuilder Builder { get; } /// /// The index being configured. /// - public virtual IMutableIndex Metadata => Builder.Metadata; + public virtual IMutableIndex Metadata + => Builder.Metadata; /// /// Adds or updates an annotation on the index. If an annotation with the key specified in @@ -81,16 +83,18 @@ public virtual IndexBuilder IsUnique(bool unique = true) /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -98,7 +102,8 @@ public virtual IndexBuilder IsUnique(bool unique = true) /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/InvertibleRelationshipBuilderBase.cs b/src/EFCore/Metadata/Builders/InvertibleRelationshipBuilderBase.cs index be05f7da803..55a8fac55c5 100644 --- a/src/EFCore/Metadata/Builders/InvertibleRelationshipBuilderBase.cs +++ b/src/EFCore/Metadata/Builders/InvertibleRelationshipBuilderBase.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Metadata.Builders { @@ -122,7 +121,8 @@ IConventionForeignKeyBuilder IInfrastructure.Insta /// /// The foreign key that represents this relationship. /// - public virtual IMutableForeignKey Metadata => Builder.Metadata; + public virtual IMutableForeignKey Metadata + => Builder.Metadata; #region Hidden System.Object members @@ -131,22 +131,25 @@ IConventionForeignKeyBuilder IInfrastructure.Insta /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/KeyBuilder.cs b/src/EFCore/Metadata/Builders/KeyBuilder.cs index d79440ccecd..2736c4d6046 100644 --- a/src/EFCore/Metadata/Builders/KeyBuilder.cs +++ b/src/EFCore/Metadata/Builders/KeyBuilder.cs @@ -37,14 +37,16 @@ public KeyBuilder([NotNull] IMutableKey key) /// /// The internal builder being used to configure the key. /// - IConventionKeyBuilder IInfrastructure.Instance => Builder; + IConventionKeyBuilder IInfrastructure.Instance + => Builder; private InternalKeyBuilder Builder { get; } /// /// The key being configured. /// - public virtual IMutableKey Metadata => Builder.Metadata; + public virtual IMutableKey Metadata + => Builder.Metadata; /// /// Adds or updates an annotation on the key. If an annotation with the key specified in @@ -71,16 +73,18 @@ public virtual KeyBuilder HasAnnotation([NotNull] string annotation, [NotNull] o /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -88,7 +92,8 @@ public virtual KeyBuilder HasAnnotation([NotNull] string annotation, [NotNull] o /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/NavigationBuilder.cs b/src/EFCore/Metadata/Builders/NavigationBuilder.cs index bbaeae7a079..1d10d03f3e8 100644 --- a/src/EFCore/Metadata/Builders/NavigationBuilder.cs +++ b/src/EFCore/Metadata/Builders/NavigationBuilder.cs @@ -37,18 +37,19 @@ public NavigationBuilder([NotNull] IMutableNavigationBase navigationOrSkipNaviga InternalSkipNavigationBuilder = (navigationOrSkipNavigation as SkipNavigation)?.Builder; Metadata = navigationOrSkipNavigation; - Check.DebugAssert(InternalNavigationBuilder != null || InternalSkipNavigationBuilder != null, + Check.DebugAssert( + InternalNavigationBuilder != null || InternalSkipNavigationBuilder != null, "Expected either a Navigation or SkipNavigation"); } private InternalNavigationBuilder InternalNavigationBuilder { get; set; } - private InternalSkipNavigationBuilder InternalSkipNavigationBuilder { get; set; } + private InternalSkipNavigationBuilder InternalSkipNavigationBuilder { get; } /// /// The navigation being configured. /// - public virtual IMutableNavigationBase Metadata { get; private set; } + public virtual IMutableNavigationBase Metadata { get; } /// /// Adds or updates an annotation on the navigation property. If an annotation @@ -169,12 +170,14 @@ public virtual NavigationBuilder IsRequired(bool required = true) /// /// The internal builder being used to configure the skip navigation. /// - IConventionSkipNavigationBuilder IInfrastructure.Instance => InternalSkipNavigationBuilder; + IConventionSkipNavigationBuilder IInfrastructure.Instance + => InternalSkipNavigationBuilder; /// /// The internal builder being used to configure the navigation. /// - IConventionNavigationBuilder IInfrastructure.Instance => InternalNavigationBuilder; + IConventionNavigationBuilder IInfrastructure.Instance + => InternalNavigationBuilder; #region Hidden System.Object members @@ -183,16 +186,18 @@ public virtual NavigationBuilder IsRequired(bool required = true) /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -200,7 +205,8 @@ public virtual NavigationBuilder IsRequired(bool required = true) /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/NavigationBuilder`.cs b/src/EFCore/Metadata/Builders/NavigationBuilder`.cs index a0eddcd5a72..f37bc01fc78 100644 --- a/src/EFCore/Metadata/Builders/NavigationBuilder`.cs +++ b/src/EFCore/Metadata/Builders/NavigationBuilder`.cs @@ -94,16 +94,18 @@ public NavigationBuilder([NotNull] IMutableNavigationBase navigationOrSkipNaviga /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -111,7 +113,8 @@ public NavigationBuilder([NotNull] IMutableNavigationBase navigationOrSkipNaviga /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/OwnedEntityTypeBuilder.cs b/src/EFCore/Metadata/Builders/OwnedEntityTypeBuilder.cs index 400857cd88d..6e1a3a0f6d3 100644 --- a/src/EFCore/Metadata/Builders/OwnedEntityTypeBuilder.cs +++ b/src/EFCore/Metadata/Builders/OwnedEntityTypeBuilder.cs @@ -32,22 +32,25 @@ public OwnedEntityTypeBuilder() /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs index 944ae7fead4..f2e852294ab 100644 --- a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs +++ b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder.cs @@ -89,17 +89,20 @@ protected virtual T UpdateBuilder([NotNull] Func configure) /// /// Gets the internal builder being used to configure the owned entity type. /// - IConventionEntityTypeBuilder IInfrastructure.Instance => DependentEntityType.Builder; + IConventionEntityTypeBuilder IInfrastructure.Instance + => DependentEntityType.Builder; /// /// The foreign key that represents this ownership. /// - public virtual IMutableForeignKey Metadata => Builder.Metadata; + public virtual IMutableForeignKey Metadata + => Builder.Metadata; /// /// The owned entity type being configured. /// - public virtual IMutableEntityType OwnedEntityType => DependentEntityType; + public virtual IMutableEntityType OwnedEntityType + => DependentEntityType; /// /// Adds or updates an annotation on the owned entity type. If an annotation with the key specified in diff --git a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs index d61b139ca4d..83c5e506655 100644 --- a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs +++ b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs @@ -40,7 +40,8 @@ public OwnedNavigationBuilder([NotNull] IMutableForeignKey ownership) /// The value to be stored in the annotation. /// The same builder instance so that multiple configuration calls can be chained. public new virtual OwnedNavigationBuilder HasAnnotation( - [NotNull] string annotation, [NotNull] object value) + [NotNull] string annotation, + [NotNull] object value) => (OwnedNavigationBuilder)base.HasAnnotation(annotation, value); /// @@ -114,8 +115,9 @@ public virtual PropertyBuilder Property( public virtual NavigationBuilder Navigation( [NotNull] Expression> navigationExpression) where TNavigation : class - => new NavigationBuilder(DependentEntityType.Builder.Navigation( - Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); + => new NavigationBuilder( + DependentEntityType.Builder.Navigation( + Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); /// /// @@ -133,8 +135,9 @@ public virtual NavigationBuilder Navigation Navigation( [NotNull] Expression>> navigationExpression) where TNavigation : class - => new NavigationBuilder(DependentEntityType.Builder.Navigation( - Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); + => new NavigationBuilder( + DependentEntityType.Builder.Navigation( + Check.NotNull(navigationExpression, nameof(navigationExpression)).GetMemberAccess())); /// /// Excludes the given property from the entity type. This method is typically used to remove properties @@ -404,12 +407,13 @@ public virtual OwnedNavigationBuilder OwnsOne( - new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), new MemberIdentity(navigationName))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), + new MemberIdentity(navigationName))); return this; } - /// /// /// Configures a relationship where the target entity is owned by (or part of) this entity. @@ -537,8 +541,9 @@ public virtual OwnedNavigationBuilder OwnsOne( - new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), new MemberIdentity(navigationName))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), new MemberIdentity(navigationName))); return this; } @@ -575,9 +580,10 @@ public virtual OwnedNavigationBuilder OwnsOne( - new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), - new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), + new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } @@ -617,14 +623,16 @@ public virtual OwnedNavigationBuilder OwnsOne( - new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), - new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsOneBuilder( + new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), + new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } private OwnedNavigationBuilder OwnsOneBuilder( - TypeIdentity ownedType, MemberIdentity navigation) + TypeIdentity ownedType, + MemberIdentity navigation) where TNewDependentEntity : class { InternalForeignKeyBuilder relationship; @@ -793,12 +801,14 @@ public virtual OwnedNavigationBuilder OwnsMany( - new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), - new MemberIdentity(navigationName))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), + new MemberIdentity(navigationName))); return this; } } + /// /// /// Configures a relationship where the target entity is owned by (or part of) this entity. @@ -924,8 +934,9 @@ public virtual OwnedNavigationBuilder OwnsMany( - new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), new MemberIdentity(navigationName))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), new MemberIdentity(navigationName))); return this; } } @@ -964,9 +975,10 @@ public virtual OwnedNavigationBuilder OwnsMany( - new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), - new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(typeof(TNewDependentEntity), (Model)Metadata.DeclaringEntityType.Model), + new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } } @@ -1008,15 +1020,17 @@ public virtual OwnedNavigationBuilder OwnsMany( - new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), - new MemberIdentity(navigationExpression.GetMemberAccess()))); + buildAction( + OwnsManyBuilder( + new TypeIdentity(ownedTypeName, typeof(TNewDependentEntity)), + new MemberIdentity(navigationExpression.GetMemberAccess()))); return this; } } private OwnedNavigationBuilder OwnsManyBuilder( - TypeIdentity ownedType, MemberIdentity navigation) + TypeIdentity ownedType, + MemberIdentity navigation) where TNewRelatedEntity : class { InternalForeignKeyBuilder relationship; diff --git a/src/EFCore/Metadata/Builders/OwnershipBuilder`.cs b/src/EFCore/Metadata/Builders/OwnershipBuilder`.cs index 75c86ea0d29..a7e5e10e9ce 100644 --- a/src/EFCore/Metadata/Builders/OwnershipBuilder`.cs +++ b/src/EFCore/Metadata/Builders/OwnershipBuilder`.cs @@ -60,7 +60,8 @@ protected OwnershipBuilder( /// The value to be stored in the annotation. /// The same builder instance so that multiple configuration calls can be chained. public new virtual OwnershipBuilder HasAnnotation( - [NotNull] string annotation, [NotNull] object value) + [NotNull] string annotation, + [NotNull] object value) => (OwnershipBuilder)base.HasAnnotation(annotation, value); /// diff --git a/src/EFCore/Metadata/Builders/PropertyBuilder.cs b/src/EFCore/Metadata/Builders/PropertyBuilder.cs index 594397e7fda..d964b62e24b 100644 --- a/src/EFCore/Metadata/Builders/PropertyBuilder.cs +++ b/src/EFCore/Metadata/Builders/PropertyBuilder.cs @@ -41,14 +41,16 @@ public PropertyBuilder([NotNull] IMutableProperty property) /// /// The internal builder being used to configure the property. /// - IConventionPropertyBuilder IInfrastructure.Instance => Builder; + IConventionPropertyBuilder IInfrastructure.Instance + => Builder; private InternalPropertyBuilder Builder { get; } /// /// The property being configured. /// - public virtual IMutableProperty Metadata => Builder.Metadata; + public virtual IMutableProperty Metadata + => Builder.Metadata; /// /// Adds or updates an annotation on the property. If an annotation with the key specified in @@ -447,16 +449,18 @@ public virtual PropertyBuilder HasConversion([CanBeNull] ValueConverter converte /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -464,7 +468,8 @@ public virtual PropertyBuilder HasConversion([CanBeNull] ValueConverter converte /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs b/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs index 67f958f114e..3780fb8fbd6 100644 --- a/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs +++ b/src/EFCore/Metadata/Builders/ReferenceNavigationBuilder.cs @@ -113,7 +113,8 @@ public ReferenceNavigationBuilder( /// /// Gets the internal builder being used to configure the relationship. /// - IConventionForeignKeyBuilder IInfrastructure.Instance => Builder; + IConventionForeignKeyBuilder IInfrastructure.Instance + => Builder; /// /// @@ -308,16 +309,18 @@ private InternalForeignKeyBuilder WithOneBuilder(MemberIdentity reference) /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -325,7 +328,8 @@ private InternalForeignKeyBuilder WithOneBuilder(MemberIdentity reference) /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs b/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs index 5a5e786c1aa..73aca88aad8 100644 --- a/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs +++ b/src/EFCore/Metadata/Builders/ReferenceReferenceBuilder`.cs @@ -61,7 +61,8 @@ protected ReferenceReferenceBuilder( /// The value to be stored in the annotation. /// The same builder instance so that multiple configuration calls can be chained. public new virtual ReferenceReferenceBuilder HasAnnotation( - [NotNull] string annotation, [NotNull] object value) + [NotNull] string annotation, + [NotNull] object value) => (ReferenceReferenceBuilder)base.HasAnnotation(annotation, value); /// diff --git a/src/EFCore/Metadata/Builders/RelationshipBuilderBase.cs b/src/EFCore/Metadata/Builders/RelationshipBuilderBase.cs index 982e9b21c05..7471da6a206 100644 --- a/src/EFCore/Metadata/Builders/RelationshipBuilderBase.cs +++ b/src/EFCore/Metadata/Builders/RelationshipBuilderBase.cs @@ -110,12 +110,14 @@ protected RelationshipBuilderBase( /// /// The foreign key that represents this relationship. /// - public virtual IMutableForeignKey Metadata => Builder.Metadata; + public virtual IMutableForeignKey Metadata + => Builder.Metadata; /// /// Gets the internal builder being used to configure this relationship. /// - IConventionForeignKeyBuilder IInfrastructure.Instance => Builder; + IConventionForeignKeyBuilder IInfrastructure.Instance + => Builder; #region Hidden System.Object members @@ -124,16 +126,18 @@ protected RelationshipBuilderBase( /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectEqualsIsObjectEquals - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. @@ -141,7 +145,8 @@ protected RelationshipBuilderBase( /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Metadata/ConstructorBinding.cs b/src/EFCore/Metadata/ConstructorBinding.cs index ad600ec9060..d989f794e0c 100644 --- a/src/EFCore/Metadata/ConstructorBinding.cs +++ b/src/EFCore/Metadata/ConstructorBinding.cs @@ -50,6 +50,7 @@ public override Expression CreateConstructorExpression(ParameterBindingInfo bind /// /// The type that will be created from the expression tree created for this binding. /// - public override Type RuntimeType => Constructor.DeclaringType; + public override Type RuntimeType + => Constructor.DeclaringType; } } diff --git a/src/EFCore/Metadata/Conventions/BackingFieldAttributeConvention.cs b/src/EFCore/Metadata/Conventions/BackingFieldAttributeConvention.cs index c4ad656f438..b7964d098e5 100644 --- a/src/EFCore/Metadata/Conventions/BackingFieldAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/BackingFieldAttributeConvention.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { /// /// A convention that configures a property as having a backing field - /// based on the attribute. + /// based on the attribute. /// public class BackingFieldAttributeConvention : PropertyAttributeConventionBase { diff --git a/src/EFCore/Metadata/Conventions/BackingFieldConvention.cs b/src/EFCore/Metadata/Conventions/BackingFieldConvention.cs index 56736df6059..8ddf424f55a 100644 --- a/src/EFCore/Metadata/Conventions/BackingFieldConvention.cs +++ b/src/EFCore/Metadata/Conventions/BackingFieldConvention.cs @@ -60,7 +60,7 @@ public virtual void ProcessPropertyAdded( DiscoverField(propertyBuilder); } - /// + /// public virtual void ProcessNavigationAdded( IConventionNavigationBuilder navigationBuilder, IConventionContext context) @@ -135,13 +135,15 @@ private FieldInfo GetFieldToSet(IConventionPropertyBase propertyBase) type = type.BaseType; entityType = baseTypes.FirstOrDefault(et => et.ClrType == type); - } return null; } - private static FieldInfo TryMatchFieldName(IConventionPropertyBase propertyBase, IConventionEntityType entityType, Type entityClrType) + private static FieldInfo TryMatchFieldName( + IConventionPropertyBase propertyBase, + IConventionEntityType entityType, + Type entityClrType) { var propertyName = propertyBase.Name; diff --git a/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs index cf9fa1d13f9..dea03c6c502 100644 --- a/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/BaseTypeDiscoveryConvention.cs @@ -29,7 +29,8 @@ public BaseTypeDiscoveryConvention([NotNull] ProviderConventionSetBuilderDepende /// The builder for the entity type. /// Additional information associated with convention execution. public virtual void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) { var entityType = entityTypeBuilder.Metadata; var clrType = entityType.ClrType; diff --git a/src/EFCore/Metadata/Conventions/CascadeDeleteConvention.cs b/src/EFCore/Metadata/Conventions/CascadeDeleteConvention.cs index e59a9e1a7f4..e1a4ecf5b65 100644 --- a/src/EFCore/Metadata/Conventions/CascadeDeleteConvention.cs +++ b/src/EFCore/Metadata/Conventions/CascadeDeleteConvention.cs @@ -33,7 +33,8 @@ public CascadeDeleteConvention([NotNull] ProviderConventionSetBuilderDependencie /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyAdded( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var newRelationshipBuilder = relationshipBuilder.OnDelete(GetTargetDeleteBehavior(relationshipBuilder.Metadata)); if (newRelationshipBuilder != null) @@ -48,7 +49,8 @@ public virtual void ProcessForeignKeyAdded( /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyRequirednessChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var newRelationshipBuilder = relationshipBuilder.OnDelete(GetTargetDeleteBehavior(relationshipBuilder.Metadata)); context.StopProcessingIfChanged(newRelationshipBuilder?.Metadata.IsRequired); diff --git a/src/EFCore/Metadata/Conventions/ChangeTrackingStrategyConvention.cs b/src/EFCore/Metadata/Conventions/ChangeTrackingStrategyConvention.cs index 1843c5e525f..0a4ae96eefe 100644 --- a/src/EFCore/Metadata/Conventions/ChangeTrackingStrategyConvention.cs +++ b/src/EFCore/Metadata/Conventions/ChangeTrackingStrategyConvention.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Internal; @@ -30,7 +29,9 @@ public ChangeTrackingStrategyConvention([NotNull] ProviderConventionSetBuilderDe protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) { diff --git a/src/EFCore/Metadata/Conventions/ConstructorBindingConvention.cs b/src/EFCore/Metadata/Conventions/ConstructorBindingConvention.cs index f74884605b3..555ecd947ac 100644 --- a/src/EFCore/Metadata/Conventions/ConstructorBindingConvention.cs +++ b/src/EFCore/Metadata/Conventions/ConstructorBindingConvention.cs @@ -40,7 +40,9 @@ public ConstructorBindingConvention([NotNull] ProviderConventionSetBuilderDepend protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) { @@ -144,7 +146,6 @@ public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, CoreAnnotationNames.ConstructorBinding, foundBindings[0]); - if (foundServiceOnlyBindings.Count == 1) { entityType.Builder.HasAnnotation( diff --git a/src/EFCore/Metadata/Conventions/DbSetFindingConvention.cs b/src/EFCore/Metadata/Conventions/DbSetFindingConvention.cs index b129c564138..c355376ad1b 100644 --- a/src/EFCore/Metadata/Conventions/DbSetFindingConvention.cs +++ b/src/EFCore/Metadata/Conventions/DbSetFindingConvention.cs @@ -33,7 +33,8 @@ public DbSetFindingConvention([NotNull] ProviderConventionSetBuilderDependencies /// The builder for the model. /// Additional information associated with convention execution. public virtual void ProcessModelInitialized( - IConventionModelBuilder modelBuilder, IConventionContext context) + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var setInfo in Dependencies.SetFinder.FindSets(Dependencies.ContextType)) { diff --git a/src/EFCore/Metadata/Conventions/DerivedTypeDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/DerivedTypeDiscoveryConvention.cs index 4418cc82cc7..24261c47c78 100644 --- a/src/EFCore/Metadata/Conventions/DerivedTypeDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/DerivedTypeDiscoveryConvention.cs @@ -30,7 +30,8 @@ public DerivedTypeDiscoveryConvention([NotNull] ProviderConventionSetBuilderDepe /// The builder for the entity type. /// Additional information associated with convention execution. public virtual void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) { var entityType = entityTypeBuilder.Metadata; var clrType = entityType.ClrType; diff --git a/src/EFCore/Metadata/Conventions/DiscriminatorConvention.cs b/src/EFCore/Metadata/Conventions/DiscriminatorConvention.cs index 12076f2c2cb..6db0ae61344 100644 --- a/src/EFCore/Metadata/Conventions/DiscriminatorConvention.cs +++ b/src/EFCore/Metadata/Conventions/DiscriminatorConvention.cs @@ -112,7 +112,8 @@ public virtual void ProcessEntityTypeRemoved( /// The entity types to configure. /// The discriminator builder. protected virtual void SetDefaultDiscriminatorValues( - [NotNull] IEnumerable entityTypes, [NotNull] IConventionDiscriminatorBuilder discriminatorBuilder) + [NotNull] IEnumerable entityTypes, + [NotNull] IConventionDiscriminatorBuilder discriminatorBuilder) { foreach (var entityType in entityTypes) { diff --git a/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs index 3550b3447c6..45440db5d01 100644 --- a/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/ForeignKeyAttributeConvention.cs @@ -46,7 +46,8 @@ public ForeignKeyAttributeConvention([NotNull] ProviderConventionSetBuilderDepen /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyAdded( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { Check.NotNull(relationshipBuilder, nameof(relationshipBuilder)); @@ -63,7 +64,8 @@ public virtual void ProcessForeignKeyAdded( /// The builder for the navigation. /// Additional information associated with convention execution. public virtual void ProcessNavigationAdded( - IConventionNavigationBuilder navigationBuilder, IConventionContext context) + IConventionNavigationBuilder navigationBuilder, + IConventionContext context) { Check.NotNull(navigationBuilder, nameof(navigationBuilder)); @@ -80,7 +82,8 @@ public virtual void ProcessNavigationAdded( } private IConventionForeignKeyBuilder UpdateRelationshipBuilder( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var foreignKey = relationshipBuilder.Metadata; @@ -375,8 +378,8 @@ private Type FindCandidateNavigationPropertyType([NotNull] PropertyInfo property private bool IsNavigationToSharedType(IConventionModel model, PropertyInfo propertyInfo) => model.IsShared(propertyInfo.PropertyType) - || (propertyInfo.PropertyType.TryGetSequenceType() is Type elementType - && model.IsShared(elementType)); + || (propertyInfo.PropertyType.TryGetSequenceType() is Type elementType + && model.IsShared(elementType)); private static IReadOnlyList FindCandidateDependentPropertiesThroughNavigation( IConventionForeignKeyBuilder relationshipBuilder, @@ -424,7 +427,9 @@ private static IReadOnlyList FindCandidateDependentPropertiesThroughNavi } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) { diff --git a/src/EFCore/Metadata/Conventions/ForeignKeyIndexConvention.cs b/src/EFCore/Metadata/Conventions/ForeignKeyIndexConvention.cs index 8294b599d25..57ecf7b16f8 100644 --- a/src/EFCore/Metadata/Conventions/ForeignKeyIndexConvention.cs +++ b/src/EFCore/Metadata/Conventions/ForeignKeyIndexConvention.cs @@ -48,7 +48,8 @@ public ForeignKeyIndexConvention([NotNull] ProviderConventionSetBuilderDependenc /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyAdded( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var foreignKey = relationshipBuilder.Metadata; CreateIndex(foreignKey.Properties, foreignKey.IsUnique, foreignKey.DeclaringEntityType.Builder); @@ -61,7 +62,8 @@ public virtual void ProcessForeignKeyAdded( /// The removed foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionForeignKey foreignKey, + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionForeignKey foreignKey, IConventionContext context) { OnForeignKeyRemoved(foreignKey.DeclaringEntityType, foreignKey.Properties); @@ -92,7 +94,8 @@ public virtual void ProcessForeignKeyPropertiesChanged( } private static void OnForeignKeyRemoved( - IConventionEntityType declaringType, IReadOnlyList foreignKeyProperties) + IConventionEntityType declaringType, + IReadOnlyList foreignKeyProperties) { var index = declaringType.FindIndex(foreignKeyProperties); if (index == null) @@ -138,7 +141,9 @@ public virtual void ProcessKeyAdded(IConventionKeyBuilder keyBuilder, IConventio /// The key. /// Additional information associated with convention execution. public virtual void ProcessKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey key, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionKey key, + IConventionContext context) { foreach (var otherForeignKey in key.DeclaringEntityType.GetDerivedTypesInclusive() .SelectMany(t => t.GetDeclaredForeignKeys()) @@ -238,7 +243,8 @@ public virtual void ProcessIndexRemoved( /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyUniquenessChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var foreignKey = relationshipBuilder.Metadata; var index = foreignKey.DeclaringEntityType.FindIndex(foreignKey.Properties); @@ -280,7 +286,8 @@ public virtual void ProcessForeignKeyUniquenessChanged( /// The builder for the index. /// Additional information associated with convention execution. public virtual void ProcessIndexUniquenessChanged( - IConventionIndexBuilder indexBuilder, IConventionContext context) + IConventionIndexBuilder indexBuilder, + IConventionContext context) { var index = indexBuilder.Metadata; if (index.IsUnique) @@ -305,14 +312,16 @@ public virtual void ProcessIndexUniquenessChanged( } /// - /// Creates an . + /// Creates an . /// /// The properties that constitute the index. /// Whether the index to create should be unique. /// The builder for the entity type. /// The created index. protected virtual IConventionIndex CreateIndex( - [NotNull] IReadOnlyList properties, bool unique, [NotNull] IConventionEntityTypeBuilder entityTypeBuilder) + [NotNull] IReadOnlyList properties, + bool unique, + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder) { foreach (var key in entityTypeBuilder.Metadata.GetKeys()) { @@ -359,7 +368,9 @@ private static void RemoveIndex(IConventionIndex index) => index.DeclaringEntityType.Builder.HasNoIndex(index); /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { var definition = CoreResources.LogRedundantIndexRemoved(Dependencies.Logger); if (!Dependencies.Logger.ShouldLog(definition) diff --git a/src/EFCore/Metadata/Conventions/ForeignKeyPropertyDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/ForeignKeyPropertyDiscoveryConvention.cs index 65437509dda..85b22dbd282 100644 --- a/src/EFCore/Metadata/Conventions/ForeignKeyPropertyDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/ForeignKeyPropertyDiscoveryConvention.cs @@ -73,7 +73,8 @@ public ForeignKeyPropertyDiscoveryConvention([NotNull] ProviderConventionSetBuil /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyAdded( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var newRelationshipBuilder = ProcessForeignKey(relationshipBuilder, context); @@ -81,7 +82,8 @@ public virtual void ProcessForeignKeyAdded( } private IConventionForeignKeyBuilder ProcessForeignKey( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var shouldBeRequired = true; foreach (var property in relationshipBuilder.Metadata.Properties) @@ -122,7 +124,8 @@ private IConventionForeignKeyBuilder ProcessForeignKey( } private IConventionForeignKeyBuilder DiscoverProperties( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var foreignKey = relationshipBuilder.Metadata; if (!ConfigurationSource.Convention.Overrides(foreignKey.GetPropertiesConfigurationSource())) @@ -306,7 +309,9 @@ private IConventionForeignKeyBuilder DiscoverProperties( } private IReadOnlyList FindCandidateForeignKeyProperties( - IConventionForeignKey foreignKey, bool onDependent, bool matchPk = false) + IConventionForeignKey foreignKey, + bool onDependent, + bool matchPk = false) { IReadOnlyList match; var navigation = onDependent @@ -423,16 +428,16 @@ private bool TryFindMatchingProperties( var dependentNavigationSpec = onDependent ? foreignKey.DependentToPrincipal?.Name : foreignKey.PrincipalToDependent?.Name; - dependentNavigationSpec = dependentEntityType.DisplayName() + - (string.IsNullOrEmpty(dependentNavigationSpec) + dependentNavigationSpec = dependentEntityType.DisplayName() + + (string.IsNullOrEmpty(dependentNavigationSpec) ? string.Empty : "." + dependentNavigationSpec); var principalNavigationSpec = onDependent ? foreignKey.PrincipalToDependent?.Name : foreignKey.DependentToPrincipal?.Name; - principalNavigationSpec = principalEntityType.DisplayName() + - (string.IsNullOrEmpty(principalNavigationSpec) + principalNavigationSpec = principalEntityType.DisplayName() + + (string.IsNullOrEmpty(principalNavigationSpec) ? string.Empty : "." + principalNavigationSpec); @@ -478,7 +483,7 @@ private static IConventionProperty TryGetProperty(IConventionEntityType entityTy foreach (var property in entityType.GetProperties()) { if ((!(property.IsShadowProperty() || entityType.IsPropertyBag && property.IsIndexerProperty()) - || !ConfigurationSource.Convention.Overrides(property.GetConfigurationSource())) + || !ConfigurationSource.Convention.Overrides(property.GetConfigurationSource())) && property.Name.Length == prefix.Length + suffix.Length && property.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && property.Name.EndsWith(suffix, StringComparison.OrdinalIgnoreCase)) @@ -506,7 +511,8 @@ public virtual void ProcessNavigationAdded( /// The builder for the property. /// Additional information associated with convention execution. public virtual void ProcessPropertyAdded( - IConventionPropertyBuilder propertyBuilder, IConventionContext context) + IConventionPropertyBuilder propertyBuilder, + IConventionContext context) { Process(propertyBuilder, context); if (propertyBuilder.Metadata.Builder == null) @@ -536,7 +542,9 @@ private void Process(IConventionPropertyBuilder propertyBuilder, IConventionCont /// The name of the ignored member. /// Additional information associated with convention execution. public virtual void ProcessEntityTypeMemberIgnored( - IConventionEntityTypeBuilder entityTypeBuilder, string name, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + string name, + IConventionContext context) { Process(entityTypeBuilder.Metadata, context); } @@ -606,7 +614,8 @@ public virtual void ProcessPropertyNullabilityChanged( /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyUniquenessChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var newRelationshipBuilder = DiscoverProperties(relationshipBuilder, context); context.StopProcessingIfChanged(newRelationshipBuilder.Metadata.IsUnique); @@ -618,7 +627,8 @@ public virtual void ProcessForeignKeyUniquenessChanged( /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyRequirednessChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var isRequired = relationshipBuilder.Metadata.IsRequired; using var batch = context.DelayConventions(); @@ -693,7 +703,9 @@ public virtual void ProcessKeyAdded(IConventionKeyBuilder keyBuilder, IConventio /// public virtual void ProcessKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey key, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionKey key, + IConventionContext context) { var foreignKeys = key.DeclaringEntityType.GetDerivedTypesInclusive() .SelectMany(t => t.GetDeclaredForeignKeys()).ToList(); @@ -745,7 +757,9 @@ public virtual void ProcessEntityTypePrimaryKeyChanged( } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) { @@ -805,8 +819,8 @@ public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, private static string GetPropertyBaseName(IConventionForeignKey foreignKey) => foreignKey.DependentToPrincipal?.Name - ?? foreignKey.GetReferencingSkipNavigations().FirstOrDefault()?.Inverse?.Name - ?? foreignKey.PrincipalEntityType.ShortName(); + ?? foreignKey.GetReferencingSkipNavigations().FirstOrDefault()?.Inverse?.Name + ?? foreignKey.PrincipalEntityType.ShortName(); private static bool HasUniquifiedProperties(IConventionForeignKey foreignKey) { diff --git a/src/EFCore/Metadata/Conventions/IModelFinalizingConvention.cs b/src/EFCore/Metadata/Conventions/IModelFinalizingConvention.cs index 4683e3d3b64..78dc987f849 100644 --- a/src/EFCore/Metadata/Conventions/IModelFinalizingConvention.cs +++ b/src/EFCore/Metadata/Conventions/IModelFinalizingConvention.cs @@ -17,6 +17,7 @@ public interface IModelFinalizingConvention : IConvention /// The builder for the model. /// Additional information associated with convention execution. void ProcessModelFinalizing( - [NotNull] IConventionModelBuilder modelBuilder, [NotNull] IConventionContext context); + [NotNull] IConventionModelBuilder modelBuilder, + [NotNull] IConventionContext context); } } diff --git a/src/EFCore/Metadata/Conventions/IModelInitializedConvention.cs b/src/EFCore/Metadata/Conventions/IModelInitializedConvention.cs index 84dc6404fcd..b849aedde7a 100644 --- a/src/EFCore/Metadata/Conventions/IModelInitializedConvention.cs +++ b/src/EFCore/Metadata/Conventions/IModelInitializedConvention.cs @@ -17,6 +17,7 @@ public interface IModelInitializedConvention : IConvention /// The builder for the model. /// Additional information associated with convention execution. void ProcessModelInitialized( - [NotNull] IConventionModelBuilder modelBuilder, [NotNull] IConventionContext context); + [NotNull] IConventionModelBuilder modelBuilder, + [NotNull] IConventionContext context); } } diff --git a/src/EFCore/Metadata/Conventions/IndexAttributeConvention.cs b/src/EFCore/Metadata/Conventions/IndexAttributeConvention.cs index c6a9493b584..92a8dd45f15 100644 --- a/src/EFCore/Metadata/Conventions/IndexAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/IndexAttributeConvention.cs @@ -31,13 +31,13 @@ public IndexAttributeConvention([NotNull] ProviderConventionSetBuilderDependenci /// protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; } - /// + /// public virtual void ProcessEntityTypeAdded( IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) => CheckIndexAttributesAndEnsureIndex(entityTypeBuilder.Metadata, false); - /// + /// public virtual void ProcessEntityTypeBaseTypeChanged( IConventionEntityTypeBuilder entityTypeBuilder, IConventionEntityType newBaseType, @@ -52,7 +52,7 @@ public virtual void ProcessEntityTypeBaseTypeChanged( CheckIndexAttributesAndEnsureIndex(entityTypeBuilder.Metadata, false); } - /// + /// public virtual void ProcessModelFinalizing( IConventionModelBuilder modelBuilder, IConventionContext context) diff --git a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs index deb67b167cd..05069b18aab 100644 --- a/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs +++ b/src/EFCore/Metadata/Conventions/Infrastructure/ProviderConventionSetBuilderDependencies.cs @@ -141,7 +141,8 @@ public ProviderConventionSetBuilderDependencies( /// /// The current context instance. /// - public Type ContextType => _currentContext.Context.GetType(); + public Type ContextType + => _currentContext.Context.GetType(); /// /// The model validator. diff --git a/src/EFCore/Metadata/Conventions/Internal/ConventionBatchExtensions.cs b/src/EFCore/Metadata/Conventions/Internal/ConventionBatchExtensions.cs index 469de08086d..484fb505b59 100644 --- a/src/EFCore/Metadata/Conventions/Internal/ConventionBatchExtensions.cs +++ b/src/EFCore/Metadata/Conventions/Internal/ConventionBatchExtensions.cs @@ -23,7 +23,8 @@ public static class ConventionBatchExtensions /// [DebuggerStepThrough] public static InternalForeignKeyBuilder Run( - [NotNull] this IConventionBatch batch, [NotNull] InternalForeignKeyBuilder relationshipBuilder) + [NotNull] this IConventionBatch batch, + [NotNull] InternalForeignKeyBuilder relationshipBuilder) => (InternalForeignKeyBuilder)batch.Run(relationshipBuilder.Metadata)?.Builder; } } diff --git a/src/EFCore/Metadata/Conventions/Internal/ConventionContext.cs b/src/EFCore/Metadata/Conventions/Internal/ConventionContext.cs index 7d11e37ef2a..6fff3e69a8e 100644 --- a/src/EFCore/Metadata/Conventions/Internal/ConventionContext.cs +++ b/src/EFCore/Metadata/Conventions/Internal/ConventionContext.cs @@ -34,7 +34,8 @@ public ConventionContext([NotNull] ConventionDispatcher dispatcher) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual TMetadata Result => _result; + public virtual TMetadata Result + => _result; /// /// Calling this will prevent further processing of the associated event by other conventions. @@ -88,7 +89,8 @@ public virtual void StopProcessingIfChanged(TMetadata result) /// /// /// An object that should be disposed to execute the delayed conventions. - public virtual IConventionBatch DelayConventions() => _dispatcher.DelayConventions(); + public virtual IConventionBatch DelayConventions() + => _dispatcher.DelayConventions(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -96,7 +98,8 @@ public virtual void StopProcessingIfChanged(TMetadata result) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual bool ShouldStopProcessing() => _stopProcessing; + public virtual bool ShouldStopProcessing() + => _stopProcessing; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ConventionScope.cs b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ConventionScope.cs index bc58cdd57d3..9391c3dd9b5 100644 --- a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ConventionScope.cs +++ b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ConventionScope.cs @@ -13,8 +13,11 @@ public partial class ConventionDispatcher { private abstract class ConventionScope : ConventionNode { - public virtual ConventionScope Parent => null; - public virtual IReadOnlyList Children => null; + public virtual ConventionScope Parent + => null; + + public virtual IReadOnlyList Children + => null; public int GetLeafCount() { @@ -64,9 +67,13 @@ public abstract IConventionEntityType OnEntityTypeBaseTypeChanged( [CanBeNull] IConventionEntityType previousBaseType); public abstract string OnEntityTypeIgnored( - [NotNull] IConventionModelBuilder modelBuilder, [NotNull] string name, [CanBeNull] Type type); + [NotNull] IConventionModelBuilder modelBuilder, + [NotNull] string name, + [CanBeNull] Type type); - public abstract string OnEntityTypeMemberIgnored([NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] string name); + public abstract string OnEntityTypeMemberIgnored( + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, + [NotNull] string name); public abstract IConventionKey OnEntityTypePrimaryKeyChanged( [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, @@ -74,7 +81,8 @@ public abstract IConventionKey OnEntityTypePrimaryKeyChanged( [CanBeNull] IConventionKey previousPrimaryKey); public abstract IConventionEntityType OnEntityTypeRemoved( - [NotNull] IConventionModelBuilder modelBuilder, [NotNull] IConventionEntityType entityType); + [NotNull] IConventionModelBuilder modelBuilder, + [NotNull] IConventionEntityType entityType); public abstract IConventionForeignKeyBuilder OnForeignKeyAdded([NotNull] IConventionForeignKeyBuilder relationshipBuilder); @@ -82,7 +90,7 @@ public abstract IConventionAnnotation OnForeignKeyAnnotationChanged( [NotNull] IConventionForeignKeyBuilder relationshipBuilder, [NotNull] string name, [CanBeNull] IConventionAnnotation annotation, - [CanBeNull]IConventionAnnotation oldAnnotation); + [CanBeNull] IConventionAnnotation oldAnnotation); public abstract bool? OnForeignKeyOwnershipChanged( [NotNull] IConventionForeignKeyBuilder relationshipBuilder); @@ -96,7 +104,8 @@ public abstract IReadOnlyList OnForeignKeyPropertiesChanged [NotNull] IConventionKey oldPrincipalKey); public abstract IConventionForeignKey OnForeignKeyRemoved( - [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionForeignKey foreignKey); + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, + [NotNull] IConventionForeignKey foreignKey); public abstract bool? OnForeignKeyRequirednessChanged( [NotNull] IConventionForeignKeyBuilder relationshipBuilder); @@ -116,7 +125,8 @@ public abstract IConventionAnnotation OnIndexAnnotationChanged( [CanBeNull] IConventionAnnotation oldAnnotation); public abstract IConventionIndex OnIndexRemoved( - [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionIndex index); + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, + [NotNull] IConventionIndex index); public abstract bool? OnIndexUniquenessChanged([NotNull] IConventionIndexBuilder indexBuilder); public abstract IConventionKeyBuilder OnKeyAdded([NotNull] IConventionKeyBuilder keyBuilder); @@ -127,7 +137,9 @@ public abstract IConventionAnnotation OnKeyAnnotationChanged( [CanBeNull] IConventionAnnotation annotation, [CanBeNull] IConventionAnnotation oldAnnotation); - public abstract IConventionKey OnKeyRemoved([NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionKey key); + public abstract IConventionKey OnKeyRemoved( + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, + [NotNull] IConventionKey key); public abstract IConventionAnnotation OnModelAnnotationChanged( [NotNull] IConventionModelBuilder modelBuilder, @@ -182,11 +194,15 @@ public abstract IConventionAnnotation OnPropertyAnnotationChanged( [CanBeNull] IConventionAnnotation oldAnnotation); public abstract FieldInfo OnPropertyFieldChanged( - [NotNull] IConventionPropertyBuilder propertyBuilder, FieldInfo newFieldInfo, [CanBeNull] FieldInfo oldFieldInfo); + [NotNull] IConventionPropertyBuilder propertyBuilder, + FieldInfo newFieldInfo, + [CanBeNull] FieldInfo oldFieldInfo); public abstract bool? OnPropertyNullabilityChanged([NotNull] IConventionPropertyBuilder propertyBuilder); - public abstract IConventionProperty OnPropertyRemoved([NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionProperty property); + public abstract IConventionProperty OnPropertyRemoved( + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, + [NotNull] IConventionProperty property); } } } diff --git a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.DelayedConventionScope.cs b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.DelayedConventionScope.cs index 7492a741d52..ca2e28810d3 100644 --- a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.DelayedConventionScope.cs +++ b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.DelayedConventionScope.cs @@ -30,7 +30,6 @@ public override IReadOnlyList Children get => _children; } - private void Add(ConventionNode node) { if (_children == null) @@ -67,7 +66,8 @@ public override string OnEntityTypeIgnored(IConventionModelBuilder modelBuilder, } public override IConventionEntityType OnEntityTypeRemoved( - IConventionModelBuilder modelBuilder, IConventionEntityType entityType) + IConventionModelBuilder modelBuilder, + IConventionEntityType entityType) { Add(new OnEntityTypeRemovedNode(modelBuilder, entityType)); return entityType; @@ -115,7 +115,8 @@ public override IConventionForeignKeyBuilder OnForeignKeyAdded(IConventionForeig } public override IConventionForeignKey OnForeignKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionForeignKey foreignKey) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionForeignKey foreignKey) { Add(new OnForeignKeyRemovedNode(entityTypeBuilder, foreignKey)); return foreignKey; @@ -138,7 +139,8 @@ public override IConventionKeyBuilder OnKeyAdded(IConventionKeyBuilder keyBuilde } public override IConventionKey OnKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey key) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionKey key) { Add(new OnKeyRemovedNode(entityTypeBuilder, key)); return key; @@ -170,7 +172,8 @@ public override IConventionIndexBuilder OnIndexAdded(IConventionIndexBuilder ind } public override IConventionIndex OnIndexRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionIndex index) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionIndex index) { Add(new OnIndexRemovedNode(entityTypeBuilder, index)); return index; @@ -319,7 +322,9 @@ public override IConventionPropertyBuilder OnPropertyAdded(IConventionPropertyBu } public override FieldInfo OnPropertyFieldChanged( - IConventionPropertyBuilder propertyBuilder, FieldInfo newFieldInfo, FieldInfo oldFieldInfo) + IConventionPropertyBuilder propertyBuilder, + FieldInfo newFieldInfo, + FieldInfo oldFieldInfo) { Add(new OnPropertyFieldChangedNode(propertyBuilder, newFieldInfo, oldFieldInfo)); return newFieldInfo; @@ -824,7 +829,9 @@ public override void Run(ConventionDispatcher dispatcher) private sealed class OnEntityTypePrimaryKeyChangedNode : ConventionNode { public OnEntityTypePrimaryKeyChangedNode( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey newPrimaryKey, IConventionKey previousPrimaryKey) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionKey newPrimaryKey, + IConventionKey previousPrimaryKey) { EntityTypeBuilder = entityTypeBuilder; NewPrimaryKey = newPrimaryKey; @@ -884,7 +891,10 @@ public override void Run(ConventionDispatcher dispatcher) private sealed class OnIndexAnnotationChangedNode : ConventionNode { public OnIndexAnnotationChangedNode( - IConventionIndexBuilder indexBuilder, string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + IConventionIndexBuilder indexBuilder, + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) { IndexBuilder = indexBuilder; Name = name; diff --git a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ImmediateConventionScope.cs b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ImmediateConventionScope.cs index e8b2bc47d5c..098537497aa 100644 --- a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ImmediateConventionScope.cs +++ b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.ImmediateConventionScope.cs @@ -195,7 +195,8 @@ public override string OnEntityTypeIgnored(IConventionModelBuilder modelBuilder, } public override IConventionEntityType OnEntityTypeRemoved( - IConventionModelBuilder modelBuilder, IConventionEntityType entityType) + IConventionModelBuilder modelBuilder, + IConventionEntityType entityType) { using (_dispatcher.DelayConventions()) { @@ -283,7 +284,9 @@ public override IConventionEntityType OnEntityTypeBaseTypeChanged( } public override IConventionKey OnEntityTypePrimaryKeyChanged( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey newPrimaryKey, IConventionKey previousPrimaryKey) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionKey newPrimaryKey, + IConventionKey previousPrimaryKey) { if (entityTypeBuilder.Metadata.Builder == null) { @@ -388,7 +391,8 @@ public override IConventionForeignKeyBuilder OnForeignKeyAdded(IConventionForeig } public override IConventionForeignKey OnForeignKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionForeignKey foreignKey) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionForeignKey foreignKey) { if (entityTypeBuilder.Metadata.Builder == null) { @@ -878,7 +882,8 @@ public override IConventionSkipNavigation OnSkipNavigationRemoved( _skipNavigationConventionContext.ResetState(navigation); foreach (var skipNavigationConvention in _conventionSet.SkipNavigationRemovedConventions) { - skipNavigationConvention.ProcessSkipNavigationRemoved(entityTypeBuilder, navigation, _skipNavigationConventionContext); + skipNavigationConvention.ProcessSkipNavigationRemoved( + entityTypeBuilder, navigation, _skipNavigationConventionContext); if (_skipNavigationConventionContext.ShouldStopProcessing()) { return _skipNavigationConventionContext.Result; @@ -1152,7 +1157,9 @@ public override IConventionPropertyBuilder OnPropertyAdded(IConventionPropertyBu } public override FieldInfo OnPropertyFieldChanged( - IConventionPropertyBuilder propertyBuilder, FieldInfo newFieldInfo, FieldInfo oldFieldInfo) + IConventionPropertyBuilder propertyBuilder, + FieldInfo newFieldInfo, + FieldInfo oldFieldInfo) { if (propertyBuilder.Metadata.Builder == null || propertyBuilder.Metadata.DeclaringEntityType.Builder == null) diff --git a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs index d9de87480d0..2075907fa7f 100644 --- a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs +++ b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs @@ -112,7 +112,9 @@ public virtual IConventionEntityTypeBuilder OnEntityTypeAdded([NotNull] IConvent /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual string OnEntityTypeIgnored( - [NotNull] IConventionModelBuilder modelBuilder, [NotNull] string name, [CanBeNull] Type type) + [NotNull] IConventionModelBuilder modelBuilder, + [NotNull] string name, + [CanBeNull] Type type) => _scope.OnEntityTypeIgnored(modelBuilder, name, type); /// @@ -122,7 +124,8 @@ public virtual string OnEntityTypeIgnored( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IConventionEntityType OnEntityTypeRemoved( - [NotNull] IConventionModelBuilder modelBuilder, [NotNull] IConventionEntityType type) + [NotNull] IConventionModelBuilder modelBuilder, + [NotNull] IConventionEntityType type) => _scope.OnEntityTypeRemoved(modelBuilder, type); /// @@ -188,7 +191,8 @@ public virtual IConventionForeignKeyBuilder OnForeignKeyAdded([NotNull] IConvent /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IConventionForeignKey OnForeignKeyRemoved( - [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionForeignKey foreignKey) + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, + [NotNull] IConventionForeignKey foreignKey) => _scope.OnForeignKeyRemoved(entityTypeBuilder, foreignKey); /// @@ -471,7 +475,8 @@ public virtual IConventionIndexBuilder OnIndexAdded([NotNull] IConventionIndexBu /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IConventionIndex OnIndexRemoved( - [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, [NotNull] IConventionIndex index) + [NotNull] IConventionEntityTypeBuilder entityTypeBuilder, + [NotNull] IConventionIndex index) => _scope.OnIndexRemoved(entityTypeBuilder, index); /// @@ -543,7 +548,9 @@ public virtual IConventionProperty OnPropertyRemoved( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual FieldInfo OnPropertyFieldChanged( - [NotNull] IConventionPropertyBuilder propertyBuilder, [CanBeNull] FieldInfo newFieldInfo, [CanBeNull] FieldInfo oldFieldInfo) + [NotNull] IConventionPropertyBuilder propertyBuilder, + [CanBeNull] FieldInfo newFieldInfo, + [CanBeNull] FieldInfo oldFieldInfo) => _scope.OnPropertyFieldChanged(propertyBuilder, newFieldInfo, oldFieldInfo); /// @@ -576,7 +583,8 @@ public virtual IConventionAnnotation OnPropertyAnnotationChanged( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IConventionBatch DelayConventions() => new ConventionBatch(this); + public virtual IConventionBatch DelayConventions() + => new ConventionBatch(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -603,7 +611,7 @@ public virtual T Run([NotNull] Func func, [CanBeNull] ref IConventionForei [Conditional("DEBUG")] public virtual void AssertNoScope() { - Check.DebugAssert(_scope == _immediateConventionScope, "Expected no active convention scopes"); + Check.DebugAssert(_scope == _immediateConventionScope, "Expected no active convention scopes"); } private sealed class ConventionBatch : IConventionBatch diff --git a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs index 0df83d2a16e..272f5c26e17 100644 --- a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs @@ -50,7 +50,9 @@ public override void ProcessEntityTypeAdded( => Process(entityTypeBuilder, navigationMemberInfo, targetClrType, attribute); private void Process( - IConventionEntityTypeBuilder entityTypeBuilder, MemberInfo navigationMemberInfo, Type targetClrType, + IConventionEntityTypeBuilder entityTypeBuilder, + MemberInfo navigationMemberInfo, + Type targetClrType, InversePropertyAttribute attribute) { var entityType = (EntityType)entityTypeBuilder.Metadata; @@ -152,7 +154,8 @@ private IConventionForeignKeyBuilder ConfigureInverseNavigation( existingInverse.GetIdentifyingMemberInfo(), existingInverseType, referencingNavigationsWithAttribute)) { existingInverse.DeclaringEntityType.Builder.HasNoSkipNavigation(existingInverse, fromDataAnnotation: true); - inverseSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation(inverseSkipNavigation, fromDataAnnotation: true); + inverseSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation( + inverseSkipNavigation, fromDataAnnotation: true); } if (existingSkipNavigation.Builder != null) @@ -262,32 +265,30 @@ private IConventionForeignKeyBuilder ConfigureInverseNavigation( navigationMemberInfo, fromDataAnnotation: true); } - else + + var newForeignKeyBuilder = targetEntityTypeBuilder.HasRelationship( + entityType, + inverseNavigationPropertyInfo, + navigationMemberInfo, + fromDataAnnotation: true); + + if (newForeignKeyBuilder == null + && navigationMemberInfo is PropertyInfo navigationPropertyInfo) { - var newForeignKeyBuilder = targetEntityTypeBuilder.HasRelationship( - entityType, - inverseNavigationPropertyInfo, - navigationMemberInfo, - fromDataAnnotation: true); - - if (newForeignKeyBuilder == null - && navigationMemberInfo is PropertyInfo navigationPropertyInfo) + var navigationTargetType = navigationPropertyInfo.PropertyType.TryGetSequenceType(); + var inverseNavigationTargetType = inverseNavigationPropertyInfo.PropertyType.TryGetSequenceType(); + if (navigationTargetType != null + && inverseNavigationTargetType != null + && navigationTargetType.IsAssignableFrom(targetClrType) + && inverseNavigationTargetType.IsAssignableFrom(entityType.ClrType)) { - var navigationTargetType = navigationPropertyInfo.PropertyType.TryGetSequenceType(); - var inverseNavigationTargetType = inverseNavigationPropertyInfo.PropertyType.TryGetSequenceType(); - if (navigationTargetType != null - && inverseNavigationTargetType != null - && navigationTargetType.IsAssignableFrom(targetClrType) - && inverseNavigationTargetType.IsAssignableFrom(entityType.ClrType)) - { - entityTypeBuilder.HasSkipNavigation( - navigationPropertyInfo, targetEntityTypeBuilder.Metadata, - inverseNavigationPropertyInfo, collections: true, onDependent: false, fromDataAnnotation: true); - } + entityTypeBuilder.HasSkipNavigation( + navigationPropertyInfo, targetEntityTypeBuilder.Metadata, + inverseNavigationPropertyInfo, collections: true, onDependent: false, fromDataAnnotation: true); } - - return newForeignKeyBuilder; } + + return newForeignKeyBuilder; } /// @@ -323,7 +324,7 @@ public override void ProcessEntityTypeIgnored( } } - /// + /// public override void ProcessNavigationAdded( IConventionNavigationBuilder navigationBuilder, InversePropertyAttribute attribute, @@ -423,7 +424,9 @@ public override void ProcessEntityTypeMemberIgnored( } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { var model = modelBuilder.Metadata; foreach (var entityType in model.GetEntityTypes()) @@ -495,7 +498,9 @@ public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, /// if the given navigation has ambiguous inverse navigations with . /// public static bool IsAmbiguous( - [NotNull] IConventionEntityType entityType, [NotNull] MemberInfo navigation, [NotNull] IConventionEntityType targetEntityType) + [NotNull] IConventionEntityType entityType, + [NotNull] MemberInfo navigation, + [NotNull] IConventionEntityType targetEntityType) { if (!Attribute.IsDefined(navigation, typeof(InversePropertyAttribute))) { @@ -573,7 +578,10 @@ private static (MemberInfo, IConventionEntityType)? FindAmbiguousInverse( } private static List<(MemberInfo, IConventionEntityType)> AddInverseNavigation( - IConventionEntityType entityType, MemberInfo navigation, IConventionEntityType targetEntityType, MemberInfo inverseNavigation) + IConventionEntityType entityType, + MemberInfo navigation, + IConventionEntityType targetEntityType, + MemberInfo inverseNavigation) { var inverseNavigations = GetInverseNavigations(targetEntityType); if (inverseNavigations == null) diff --git a/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs index 8123ebbc685..5d95266e887 100644 --- a/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/KeyAttributeConvention.cs @@ -93,7 +93,9 @@ protected override void ProcessPropertyAdded( } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { var entityTypes = modelBuilder.Metadata.GetEntityTypes(); foreach (var entityType in entityTypes) diff --git a/src/EFCore/Metadata/Conventions/KeyDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/KeyDiscoveryConvention.cs index 7937efb6985..81cb0f61e2c 100644 --- a/src/EFCore/Metadata/Conventions/KeyDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/KeyDiscoveryConvention.cs @@ -199,14 +199,17 @@ public virtual void ProcessEntityTypeBaseTypeChanged( /// public virtual void ProcessPropertyAdded( - IConventionPropertyBuilder propertyBuilder, IConventionContext context) + IConventionPropertyBuilder propertyBuilder, + IConventionContext context) { TryConfigurePrimaryKey(propertyBuilder.Metadata.DeclaringEntityType.Builder); } /// public virtual void ProcessKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey key, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionKey key, + IConventionContext context) { if (entityTypeBuilder.Metadata.FindPrimaryKey() == null) { @@ -241,7 +244,6 @@ public virtual void ProcessForeignKeyPropertiesChanged( } } - /// public virtual void ProcessForeignKeyOwnershipChanged( IConventionForeignKeyBuilder relationshipBuilder, diff --git a/src/EFCore/Metadata/Conventions/ManyToManyJoinEntityTypeConvention.cs b/src/EFCore/Metadata/Conventions/ManyToManyJoinEntityTypeConvention.cs index 5b109fded6d..0ea590aeb5b 100644 --- a/src/EFCore/Metadata/Conventions/ManyToManyJoinEntityTypeConvention.cs +++ b/src/EFCore/Metadata/Conventions/ManyToManyJoinEntityTypeConvention.cs @@ -103,7 +103,8 @@ private void CreateJoinEntityType(IConventionSkipNavigationBuilder skipNavigatio return; } - Check.DebugAssert(inverseSkipNavigation.Inverse == skipNavigation, + Check.DebugAssert( + inverseSkipNavigation.Inverse == skipNavigation, "Inverse's inverse should be the original skip navigation"); var declaringEntityType = skipNavigation.DeclaringEntityType; diff --git a/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs b/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs index 97c7d53ad59..9eacfb6367a 100644 --- a/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs +++ b/src/EFCore/Metadata/Conventions/ModelCleanupConvention.cs @@ -32,7 +32,8 @@ public ModelCleanupConvention([NotNull] ProviderConventionSetBuilderDependencies /// public virtual void ProcessModelFinalizing( - IConventionModelBuilder modelBuilder, IConventionContext context) + IConventionModelBuilder modelBuilder, + IConventionContext context) { RemoveEntityTypesUnreachableByNavigations(modelBuilder, context); RemoveNavigationlessForeignKeys(modelBuilder); @@ -40,7 +41,8 @@ public virtual void ProcessModelFinalizing( } private void RemoveEntityTypesUnreachableByNavigations( - IConventionModelBuilder modelBuilder, IConventionContext context) + IConventionModelBuilder modelBuilder, + IConventionContext context) { var model = modelBuilder.Metadata; var rootEntityTypes = GetRoots(model, ConfigurationSource.DataAnnotation); @@ -103,11 +105,13 @@ public GraphAdapter([NotNull] IConventionModel model) _model = model; } - public override IEnumerable Vertices => _model.GetEntityTypes(); + public override IEnumerable Vertices + => _model.GetEntityTypes(); public override IEnumerable GetOutgoingNeighbors(IConventionEntityType from) => from.GetForeignKeys().Where(fk => fk.DependentToPrincipal != null).Select(fk => fk.PrincipalEntityType) - .Union(from.GetReferencingForeignKeys().Where(fk => fk.PrincipalToDependent != null).Select(fk => fk.DeclaringEntityType)) + .Union( + from.GetReferencingForeignKeys().Where(fk => fk.PrincipalToDependent != null).Select(fk => fk.DeclaringEntityType)) .Union(from.GetSkipNavigations().Where(sn => sn.ForeignKey != null).Select(sn => sn.ForeignKey.DeclaringEntityType)) .Union(from.GetSkipNavigations().Where(sn => sn.TargetEntityType != null).Select(sn => sn.TargetEntityType)); @@ -123,4 +127,3 @@ public override void Clear() } } } - diff --git a/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs b/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs index 43b5cf836e0..9206fa6152c 100644 --- a/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs +++ b/src/EFCore/Metadata/Conventions/NavigationAttributeConventionBase.cs @@ -85,7 +85,10 @@ public virtual void ProcessEntityTypeAdded( /// The ignored entity type. /// Additional information associated with convention execution. public virtual void ProcessEntityTypeIgnored( - IConventionModelBuilder modelBuilder, string name, Type type, IConventionContext context) + IConventionModelBuilder modelBuilder, + string name, + Type type, + IConventionContext context) { if (type == null) { @@ -207,7 +210,9 @@ public virtual void ProcessForeignKeyPrincipalEndChanged( /// public virtual void ProcessEntityTypeMemberIgnored( - IConventionEntityTypeBuilder entityTypeBuilder, string name, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + string name, + IConventionContext context) { var navigationPropertyInfo = entityTypeBuilder.Metadata.GetRuntimeProperties()?.Find(name); @@ -250,7 +255,8 @@ private Type FindCandidateNavigationWithAttributePropertyType([NotNull] Property /// The attribute type to look for. /// The attributes applied to the given navigation. protected static IEnumerable GetAttributes( - [NotNull] IConventionEntityType entityType, [NotNull] IConventionNavigation navigation) + [NotNull] IConventionEntityType entityType, + [NotNull] IConventionNavigation navigation) where TCustomAttribute : Attribute => GetAttributes(entityType, navigation.GetIdentifyingMemberInfo()); @@ -262,12 +268,14 @@ protected static IEnumerable GetAttributes( /// The attribute type to look for. /// The attributes applied to the given skip navigation. protected static IEnumerable GetAttributes( - [NotNull] IConventionEntityType entityType, [NotNull] IConventionSkipNavigation skipNavigation) + [NotNull] IConventionEntityType entityType, + [NotNull] IConventionSkipNavigation skipNavigation) where TCustomAttribute : Attribute => GetAttributes(entityType, skipNavigation.GetIdentifyingMemberInfo()); private static IEnumerable GetAttributes( - [NotNull] IConventionEntityType entityType, [NotNull] MemberInfo memberInfo) + [NotNull] IConventionEntityType entityType, + [NotNull] MemberInfo memberInfo) where TCustomAttribute : Attribute { if (!entityType.HasClrType() diff --git a/src/EFCore/Metadata/Conventions/NavigationBackingFieldAttributeConvention.cs b/src/EFCore/Metadata/Conventions/NavigationBackingFieldAttributeConvention.cs index 1a7d0b89630..1968c82fbf4 100644 --- a/src/EFCore/Metadata/Conventions/NavigationBackingFieldAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/NavigationBackingFieldAttributeConvention.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { /// /// A convention that configures a navigation property as having a backing field - /// based on the attribute. + /// based on the attribute. /// public class NavigationBackingFieldAttributeConvention : NavigationAttributeConventionBase { diff --git a/src/EFCore/Metadata/Conventions/NavigationEagerLoadingConvention.cs b/src/EFCore/Metadata/Conventions/NavigationEagerLoadingConvention.cs index 0b1ea7d489f..96fd5c657c0 100644 --- a/src/EFCore/Metadata/Conventions/NavigationEagerLoadingConvention.cs +++ b/src/EFCore/Metadata/Conventions/NavigationEagerLoadingConvention.cs @@ -32,7 +32,8 @@ public NavigationEagerLoadingConvention([NotNull] ProviderConventionSetBuilderDe /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyOwnershipChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { relationshipBuilder.Metadata.PrincipalToDependent?.Builder.AutoInclude(relationshipBuilder.Metadata.IsOwnership); } diff --git a/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs b/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs index e2bbbe5b9f6..01060dc2b8f 100644 --- a/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs +++ b/src/EFCore/Metadata/Conventions/NonNullableConventionBase.cs @@ -143,7 +143,9 @@ private NonNullabilityConventionState GetOrInitializeState(IConventionModelBuild ).Value; /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) => modelBuilder.Metadata.RemoveAnnotation(StateAnnotationName); private sealed class NonNullabilityConventionState diff --git a/src/EFCore/Metadata/Conventions/NonNullableNavigationConvention.cs b/src/EFCore/Metadata/Conventions/NonNullableNavigationConvention.cs index 563e6c33675..cb734a73449 100644 --- a/src/EFCore/Metadata/Conventions/NonNullableNavigationConvention.cs +++ b/src/EFCore/Metadata/Conventions/NonNullableNavigationConvention.cs @@ -3,7 +3,6 @@ using System.Reflection; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Internal; diff --git a/src/EFCore/Metadata/Conventions/NonNullableReferencePropertyConvention.cs b/src/EFCore/Metadata/Conventions/NonNullableReferencePropertyConvention.cs index 7f1bc70aebc..f0f15ebbab0 100644 --- a/src/EFCore/Metadata/Conventions/NonNullableReferencePropertyConvention.cs +++ b/src/EFCore/Metadata/Conventions/NonNullableReferencePropertyConvention.cs @@ -42,7 +42,8 @@ private void Process(IConventionPropertyBuilder propertyBuilder) /// The builder for the property. /// Additional information associated with convention execution. public virtual void ProcessPropertyAdded( - IConventionPropertyBuilder propertyBuilder, IConventionContext context) + IConventionPropertyBuilder propertyBuilder, + IConventionContext context) { Process(propertyBuilder); } diff --git a/src/EFCore/Metadata/Conventions/NotMappedMemberAttributeConvention.cs b/src/EFCore/Metadata/Conventions/NotMappedMemberAttributeConvention.cs index 16e291ecac5..90985578a2c 100644 --- a/src/EFCore/Metadata/Conventions/NotMappedMemberAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/NotMappedMemberAttributeConvention.cs @@ -38,7 +38,8 @@ public NotMappedMemberAttributeConvention([NotNull] ProviderConventionSetBuilder /// The builder for the entity type. /// Additional information associated with convention execution. public virtual void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); diff --git a/src/EFCore/Metadata/Conventions/QueryFilterRewritingConvention.cs b/src/EFCore/Metadata/Conventions/QueryFilterRewritingConvention.cs index cd981942a52..795d6c7356c 100644 --- a/src/EFCore/Metadata/Conventions/QueryFilterRewritingConvention.cs +++ b/src/EFCore/Metadata/Conventions/QueryFilterRewritingConvention.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { /// - /// Convention that converts accesses of inside query filters into . + /// Convention that converts accesses of inside query filters into . /// This makes them consistent with how DbSet accesses in the actual queries are represented, which allows for easier processing in the /// query pipeline. /// @@ -34,7 +34,7 @@ public QueryFilterRewritingConvention([NotNull] ProviderConventionSetBuilderDepe protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; } /// - /// Visitor used to rewrite accesses encountered in query filters to . + /// Visitor used to rewrite accesses encountered in query filters to . /// protected virtual DbSetAccessRewritingExpressionVisitor DbSetAccessRewriter { get; [param: NotNull] set; } @@ -54,7 +54,7 @@ public virtual void ProcessModelFinalizing( } /// - /// A visitor that rewrites DbSet accesses encountered in an expression to . + /// A visitor that rewrites DbSet accesses encountered in an expression to . /// protected class DbSetAccessRewritingExpressionVisitor : ExpressionVisitor { @@ -71,7 +71,7 @@ public DbSetAccessRewritingExpressionVisitor(Type contextType) } /// - /// Rewrites DbSet accesses encountered in the expression to . + /// Rewrites DbSet accesses encountered in the expression to . /// /// The model to look for entity types. /// The query expression to rewrite. @@ -118,7 +118,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp return base.VisitMethodCall(methodCallExpression); } - private IEntityType FindEntityType(Type dbSetType) => _model.FindRuntimeEntityType(dbSetType.GetGenericArguments()[0]); + private IEntityType FindEntityType(Type dbSetType) + => _model.FindRuntimeEntityType(dbSetType.GetGenericArguments()[0]); } } } diff --git a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs index dec053e1ac2..652a3cc0759 100644 --- a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs @@ -405,7 +405,9 @@ private static bool IsCompatibleInverse( } private static bool CanMergeWith( - IConventionNavigation existingNavigation, MemberInfo inverse, IConventionEntityTypeBuilder inverseEntityTypeBuilder) + IConventionNavigation existingNavigation, + MemberInfo inverse, + IConventionEntityTypeBuilder inverseEntityTypeBuilder) { var fk = existingNavigation.ForeignKey; return (fk.IsSelfReferencing() @@ -516,7 +518,8 @@ private static IReadOnlyList RemoveSingleSidedBaseNavigat } private void CreateRelationships( - IEnumerable relationshipCandidates, IConventionEntityTypeBuilder entityTypeBuilder) + IEnumerable relationshipCandidates, + IConventionEntityTypeBuilder entityTypeBuilder) { var unusedEntityTypes = new List(); foreach (var relationshipCandidate in relationshipCandidates) @@ -726,9 +729,11 @@ private void RemoveNavigation( if (existingNavigation != null) { if (existingNavigation.ForeignKey.DeclaringEntityType.Builder - .HasNoRelationship(existingNavigation.ForeignKey) == null + .HasNoRelationship(existingNavigation.ForeignKey) + == null && existingNavigation.ForeignKey.Builder.HasNavigation( - (string)null, existingNavigation.IsOnDependent) == null) + (string)null, existingNavigation.IsOnDependent) + == null) { // Navigations of higher configuration source are not ambiguous toRemoveFrom.Remove(navigationProperty); @@ -755,7 +760,8 @@ private void RemoveNavigation( /// public virtual void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) => DiscoverRelationships(entityTypeBuilder, context); /// @@ -843,7 +849,9 @@ private void Process( [ContractAnnotation("memberInfo:null => false")] private static bool IsCandidateNavigationProperty( - IConventionEntityTypeBuilder sourceEntityTypeBuilder, string navigationName, MemberInfo memberInfo) + IConventionEntityTypeBuilder sourceEntityTypeBuilder, + string navigationName, + MemberInfo memberInfo) => memberInfo != null && sourceEntityTypeBuilder?.IsIgnored(navigationName) == false && sourceEntityTypeBuilder.Metadata.FindProperty(navigationName) == null @@ -854,7 +862,10 @@ private static bool IsCandidateNavigationProperty( /// public virtual void ProcessEntityTypeIgnored( - IConventionModelBuilder modelBuilder, string name, Type type, IConventionContext context) + IConventionModelBuilder modelBuilder, + string name, + Type type, + IConventionContext context) { foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) { @@ -868,7 +879,9 @@ public virtual void ProcessEntityTypeIgnored( /// public virtual void ProcessEntityTypeMemberIgnored( - IConventionEntityTypeBuilder entityTypeBuilder, string name, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + string name, + IConventionContext context) { var anyAmbiguityRemoved = false; foreach (var derivedEntityType in entityTypeBuilder.Metadata.GetDerivedTypesInclusive()) @@ -1029,7 +1042,9 @@ private static ImmutableSortedDictionary GetAmbiguousNavigatio as ImmutableSortedDictionary; private static void AddAmbiguous( - IConventionEntityTypeBuilder entityTypeBuilder, IReadOnlyList navigationProperties, Type targetType) + IConventionEntityTypeBuilder entityTypeBuilder, + IReadOnlyList navigationProperties, + Type targetType) { if (navigationProperties.Count == 0) { @@ -1089,7 +1104,8 @@ private MemberInfoNameComparer() { } - public int Compare(MemberInfo x, MemberInfo y) => StringComparer.Ordinal.Compare(x.Name, y.Name); + public int Compare(MemberInfo x, MemberInfo y) + => StringComparer.Ordinal.Compare(x.Name, y.Name); } [DebuggerDisplay("{DebuggerDisplay(),nq}")] @@ -1109,13 +1125,13 @@ public RelationshipCandidate( public List NavigationProperties { [DebuggerStepThrough] get; } public List InverseProperties { [DebuggerStepThrough] get; } - private string DebuggerDisplay() => - TargetTypeBuilder.Metadata.ToDebugString(MetadataDebugStringOptions.SingleLineDefault) - + ": [" - + string.Join(", ", NavigationProperties.Select(p => p.Name)) - + "] - [" - + string.Join(", ", InverseProperties.Select(p => p.Name)) - + "]"; + private string DebuggerDisplay() + => TargetTypeBuilder.Metadata.ToDebugString(MetadataDebugStringOptions.SingleLineDefault) + + ": [" + + string.Join(", ", NavigationProperties.Select(p => p.Name)) + + "] - [" + + string.Join(", ", InverseProperties.Select(p => p.Name)) + + "]"; } } } diff --git a/src/EFCore/Metadata/Conventions/RequiredNavigationAttributeConvention.cs b/src/EFCore/Metadata/Conventions/RequiredNavigationAttributeConvention.cs index eb6c7b98796..37c95f5fda7 100644 --- a/src/EFCore/Metadata/Conventions/RequiredNavigationAttributeConvention.cs +++ b/src/EFCore/Metadata/Conventions/RequiredNavigationAttributeConvention.cs @@ -26,7 +26,7 @@ public RequiredNavigationAttributeConvention([NotNull] ProviderConventionSetBuil { } - /// + /// public override void ProcessNavigationAdded( IConventionNavigationBuilder navigationBuilder, RequiredAttribute attribute, diff --git a/src/EFCore/Metadata/Conventions/ServicePropertyDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/ServicePropertyDiscoveryConvention.cs index dbd140fa1f9..06d0b1b3eb7 100644 --- a/src/EFCore/Metadata/Conventions/ServicePropertyDiscoveryConvention.cs +++ b/src/EFCore/Metadata/Conventions/ServicePropertyDiscoveryConvention.cs @@ -44,7 +44,8 @@ public ServicePropertyDiscoveryConvention([NotNull] ProviderConventionSetBuilder /// The builder for the entity type. /// Additional information associated with convention execution. public virtual void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) => Process(entityTypeBuilder); /// @@ -132,7 +133,9 @@ private void Process(IConventionEntityTypeBuilder entityTypeBuilder) /// The name of the ignored member. /// Additional information associated with convention execution. public virtual void ProcessEntityTypeMemberIgnored( - IConventionEntityTypeBuilder entityTypeBuilder, string name, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + string name, + IConventionContext context) { var entityType = entityTypeBuilder.Metadata; var duplicateMap = GetDuplicateServiceProperties(entityType); @@ -166,7 +169,9 @@ public virtual void ProcessEntityTypeMemberIgnored( } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) { diff --git a/src/EFCore/Metadata/Conventions/TypeMappingConvention.cs b/src/EFCore/Metadata/Conventions/TypeMappingConvention.cs index b33ebf75a9e..72fe09679ce 100644 --- a/src/EFCore/Metadata/Conventions/TypeMappingConvention.cs +++ b/src/EFCore/Metadata/Conventions/TypeMappingConvention.cs @@ -28,7 +28,9 @@ public TypeMappingConvention([NotNull] ProviderConventionSetBuilderDependencies protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var property in modelBuilder.Metadata.GetEntityTypes().SelectMany(e => e.GetDeclaredProperties())) { diff --git a/src/EFCore/Metadata/Conventions/ValueGenerationConvention.cs b/src/EFCore/Metadata/Conventions/ValueGenerationConvention.cs index d6225e10c40..db2b9b6382e 100644 --- a/src/EFCore/Metadata/Conventions/ValueGenerationConvention.cs +++ b/src/EFCore/Metadata/Conventions/ValueGenerationConvention.cs @@ -42,7 +42,8 @@ public ValueGenerationConvention([NotNull] ProviderConventionSetBuilderDependenc /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyAdded( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var foreignKey = relationshipBuilder.Metadata; if (!foreignKey.IsBaseLinking()) @@ -218,7 +219,8 @@ private static bool CanBeGenerated(IProperty property) /// The builder for the foreign key. /// Additional information associated with convention execution. public virtual void ProcessForeignKeyOwnershipChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { foreach (var property in relationshipBuilder.Metadata.DeclaringEntityType.GetProperties()) { diff --git a/src/EFCore/Metadata/EntityTypeFullNameComparer.cs b/src/EFCore/Metadata/EntityTypeFullNameComparer.cs index 0fc6295a339..7f80a308234 100644 --- a/src/EFCore/Metadata/EntityTypeFullNameComparer.cs +++ b/src/EFCore/Metadata/EntityTypeFullNameComparer.cs @@ -93,7 +93,7 @@ public int Compare(IEntityType x, IEntityType y) /// /// The first object to compare. /// The second object to compare. - /// if the specified objects are equal; otherwise, . + /// if the specified objects are equal; otherwise, . public bool Equals(IEntityType x, IEntityType y) => Compare(x, y) == 0; diff --git a/src/EFCore/Metadata/ForeignKeyComparer.cs b/src/EFCore/Metadata/ForeignKeyComparer.cs index d3201808235..6d737d2538a 100644 --- a/src/EFCore/Metadata/ForeignKeyComparer.cs +++ b/src/EFCore/Metadata/ForeignKeyComparer.cs @@ -57,7 +57,7 @@ public int Compare(IForeignKey x, IForeignKey y) /// /// The first object to compare. /// The second object to compare. - /// if the specified objects are equal; otherwise, . + /// if the specified objects are equal; otherwise, . public bool Equals(IForeignKey x, IForeignKey y) => Compare(x, y) == 0; diff --git a/src/EFCore/Metadata/IClrCollectionAccessor.cs b/src/EFCore/Metadata/IClrCollectionAccessor.cs index 5c03b6a52ad..745af83ba4a 100644 --- a/src/EFCore/Metadata/IClrCollectionAccessor.cs +++ b/src/EFCore/Metadata/IClrCollectionAccessor.cs @@ -18,7 +18,7 @@ public interface IClrCollectionAccessor /// The entity instance. /// The value to add. /// If true, then the value is being added as part of query materialization. - /// if a value was added; if it was already in the collection. + /// if a value was added; if it was already in the collection. bool Add([NotNull] object entity, [NotNull] object value, bool forMaterialization); /// @@ -26,7 +26,7 @@ public interface IClrCollectionAccessor /// /// The entity instance. /// The value to check. - /// if the value is contained in the collection; otherwise. + /// if the value is contained in the collection; otherwise. bool Contains([NotNull] object entity, [NotNull] object value); /// @@ -34,7 +34,7 @@ public interface IClrCollectionAccessor /// /// The entity instance. /// The value to check. - /// if the value was contained in the collection; otherwise. + /// if the value was contained in the collection; otherwise. bool Remove([NotNull] object entity, [NotNull] object value); /// @@ -48,7 +48,7 @@ public interface IClrCollectionAccessor /// exists, then creates a new instance, sets it, and returns it. /// /// The entity instance. - /// If true, then this is happening as part of query materialization; otherwise. + /// If true, then this is happening as part of query materialization; otherwise. /// The existing or new collection. object GetOrCreate([NotNull] object entity, bool forMaterialization); diff --git a/src/EFCore/Metadata/IClrPropertyGetter.cs b/src/EFCore/Metadata/IClrPropertyGetter.cs index 70b074584c6..b8b10e85d37 100644 --- a/src/EFCore/Metadata/IClrPropertyGetter.cs +++ b/src/EFCore/Metadata/IClrPropertyGetter.cs @@ -22,7 +22,7 @@ public interface IClrPropertyGetter /// Checks whether or not the property is set to the CLR default for its type. /// /// The entity instance. - /// if the property value is the CLR default; it is any other value. + /// if the property value is the CLR default; it is any other value. bool HasDefaultValue([NotNull] object entity); } } diff --git a/src/EFCore/Metadata/IConventionEntityType.cs b/src/EFCore/Metadata/IConventionEntityType.cs index f69b2641e32..5f78428e221 100644 --- a/src/EFCore/Metadata/IConventionEntityType.cs +++ b/src/EFCore/Metadata/IConventionEntityType.cs @@ -357,7 +357,7 @@ IConventionIndex AddIndex( /// The corresponding CLR type member or for a shadow property. /// /// - /// An indexer with a parameter and return type can be used. + /// An indexer with a parameter and return type can be used. /// /// /// Indicates whether the type configuration source should be set. diff --git a/src/EFCore/Metadata/IConventionIndex.cs b/src/EFCore/Metadata/IConventionIndex.cs index ca5963d1185..fae466eb227 100644 --- a/src/EFCore/Metadata/IConventionIndex.cs +++ b/src/EFCore/Metadata/IConventionIndex.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Microsoft.EntityFrameworkCore.Metadata diff --git a/src/EFCore/Metadata/IConventionNavigationBase.cs b/src/EFCore/Metadata/IConventionNavigationBase.cs index 1d5fa67e4f4..8514f68f1c1 100644 --- a/src/EFCore/Metadata/IConventionNavigationBase.cs +++ b/src/EFCore/Metadata/IConventionNavigationBase.cs @@ -33,6 +33,6 @@ public interface IConventionNavigationBase : INavigationBase, IConventionPropert /// /// The configuration source for . ConfigurationSource? GetIsEagerLoadedConfigurationSource() - => FindAnnotation(CoreAnnotationNames.EagerLoaded)?.GetConfigurationSource(); + => FindAnnotation(CoreAnnotationNames.EagerLoaded)?.GetConfigurationSource(); } } diff --git a/src/EFCore/Metadata/IForeignKey.cs b/src/EFCore/Metadata/IForeignKey.cs index edefca787be..5c6326b310c 100644 --- a/src/EFCore/Metadata/IForeignKey.cs +++ b/src/EFCore/Metadata/IForeignKey.cs @@ -82,6 +82,6 @@ public interface IForeignKey : IAnnotatable /// The skip navigations using this foreign key. IEnumerable GetReferencingSkipNavigations() => PrincipalEntityType.GetSkipNavigations().Where(n => !n.IsOnDependent && n.ForeignKey == this) - .Concat(DeclaringEntityType.GetSkipNavigations().Where(n => n.IsOnDependent && n.ForeignKey == this)); + .Concat(DeclaringEntityType.GetSkipNavigations().Where(n => n.IsOnDependent && n.ForeignKey == this)); } } diff --git a/src/EFCore/Metadata/IMutableEntityType.cs b/src/EFCore/Metadata/IMutableEntityType.cs index 1843f13fc25..386a5666a50 100644 --- a/src/EFCore/Metadata/IMutableEntityType.cs +++ b/src/EFCore/Metadata/IMutableEntityType.cs @@ -26,7 +26,8 @@ public interface IMutableEntityType : IEntityType, IMutableTypeBase new IMutableModel Model { get; } /// - /// Gets or sets the base type of this entity type. Returns if this is not a derived type in an inheritance hierarchy. + /// Gets or sets the base type of this entity type. Returns if this is not a derived type in an inheritance + /// hierarchy. /// new IMutableEntityType BaseType { get; [param: CanBeNull] set; } @@ -226,7 +227,8 @@ IMutableSkipNavigation AddSkipNavigation( /// The name of the index. /// The newly created index. IMutableIndex AddIndex( - [NotNull] IReadOnlyList properties, [NotNull] string name); + [NotNull] IReadOnlyList properties, + [NotNull] string name); /// /// diff --git a/src/EFCore/Metadata/IMutableIndex.cs b/src/EFCore/Metadata/IMutableIndex.cs index 833726feb5a..9bf805b39a0 100644 --- a/src/EFCore/Metadata/IMutableIndex.cs +++ b/src/EFCore/Metadata/IMutableIndex.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using JetBrains.Annotations; namespace Microsoft.EntityFrameworkCore.Metadata { diff --git a/src/EFCore/Metadata/IMutableNavigationBase.cs b/src/EFCore/Metadata/IMutableNavigationBase.cs index 437240b4a1a..ce2b09532f1 100644 --- a/src/EFCore/Metadata/IMutableNavigationBase.cs +++ b/src/EFCore/Metadata/IMutableNavigationBase.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata.Internal; namespace Microsoft.EntityFrameworkCore.Metadata diff --git a/src/EFCore/Metadata/IParameterBindingFactory.cs b/src/EFCore/Metadata/IParameterBindingFactory.cs index 97dfa8d1bb2..169673ffcc5 100644 --- a/src/EFCore/Metadata/IParameterBindingFactory.cs +++ b/src/EFCore/Metadata/IParameterBindingFactory.cs @@ -25,7 +25,7 @@ public interface IParameterBindingFactory /// /// The parameter type. /// The parameter name. - /// if this parameter can be bound; otherwise. + /// if this parameter can be bound; otherwise. bool CanBind( [NotNull] Type parameterType, [NotNull] string parameterName); diff --git a/src/EFCore/Metadata/ISkipNavigation.cs b/src/EFCore/Metadata/ISkipNavigation.cs index 8a6cce47b32..c643780473e 100644 --- a/src/EFCore/Metadata/ISkipNavigation.cs +++ b/src/EFCore/Metadata/ISkipNavigation.cs @@ -15,7 +15,8 @@ public interface ISkipNavigation : INavigationBase /// /// Gets the join type used by the foreign key. /// - IEntityType JoinEntityType => IsOnDependent ? ForeignKey?.PrincipalEntityType : ForeignKey?.DeclaringEntityType; + IEntityType JoinEntityType + => IsOnDependent ? ForeignKey?.PrincipalEntityType : ForeignKey?.DeclaringEntityType; /// /// Gets the inverse skip navigation. diff --git a/src/EFCore/Metadata/IndexComparer.cs b/src/EFCore/Metadata/IndexComparer.cs index c721410b2dd..fe7cfed43f6 100644 --- a/src/EFCore/Metadata/IndexComparer.cs +++ b/src/EFCore/Metadata/IndexComparer.cs @@ -45,7 +45,7 @@ public int Compare(IIndex x, IIndex y) /// /// The first object to compare. /// The second object to compare. - /// if the specified objects are equal; otherwise, . + /// if the specified objects are equal; otherwise, . public bool Equals(IIndex x, IIndex y) => Compare(x, y) == 0; diff --git a/src/EFCore/Metadata/Internal/ClrCollectionAccessor.cs b/src/EFCore/Metadata/Internal/ClrCollectionAccessor.cs index c46e1236633..34f4e84b169 100644 --- a/src/EFCore/Metadata/Internal/ClrCollectionAccessor.cs +++ b/src/EFCore/Metadata/Internal/ClrCollectionAccessor.cs @@ -34,7 +34,8 @@ public class ClrICollectionAccessor : IClrCollec /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual Type CollectionType => typeof(TCollection); + public virtual Type CollectionType + => typeof(TCollection); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -197,8 +198,8 @@ public virtual bool Remove(object entity, object value) return false; case SortedSet sortedSet: return sortedSet.TryGetValue((TElement)value, out var found) - && ReferenceEquals(found, value) - && sortedSet.Remove(found); + && ReferenceEquals(found, value) + && sortedSet.Remove(found); default: return collection?.Remove((TElement)value) ?? false; } @@ -230,7 +231,7 @@ private static bool Contains(ICollection collection, object value) return false; case SortedSet sortedSet: return sortedSet.TryGetValue((TElement)value, out var found) - && ReferenceEquals(found, value); + && ReferenceEquals(found, value); default: return collection?.Contains((TElement)value) == true; } diff --git a/src/EFCore/Metadata/Internal/ClrPropertyGetter.cs b/src/EFCore/Metadata/Internal/ClrPropertyGetter.cs index 6aec7e10691..75d6565cb9a 100644 --- a/src/EFCore/Metadata/Internal/ClrPropertyGetter.cs +++ b/src/EFCore/Metadata/Internal/ClrPropertyGetter.cs @@ -39,7 +39,8 @@ public ClrPropertyGetter([NotNull] Func getter, [NotNull] Func< /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public object GetClrValue(object entity) => _getter((TEntity)entity); + public object GetClrValue(object entity) + => _getter((TEntity)entity); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -48,6 +49,7 @@ public ClrPropertyGetter([NotNull] Func getter, [NotNull] Func< /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool HasDefaultValue(object entity) => _hasDefaultValue((TEntity)entity); + public bool HasDefaultValue(object entity) + => _hasDefaultValue((TEntity)entity); } } diff --git a/src/EFCore/Metadata/Internal/ClrPropertyGetterFactory.cs b/src/EFCore/Metadata/Internal/ClrPropertyGetterFactory.cs index f08963fc8d2..9b6b0de5353 100644 --- a/src/EFCore/Metadata/Internal/ClrPropertyGetterFactory.cs +++ b/src/EFCore/Metadata/Internal/ClrPropertyGetterFactory.cs @@ -33,7 +33,8 @@ public override IClrPropertyGetter Create(IPropertyBase property) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override IClrPropertyGetter CreateGeneric( - MemberInfo memberInfo, IPropertyBase propertyBase) + MemberInfo memberInfo, + IPropertyBase propertyBase) { var entityParameter = Expression.Parameter(typeof(TEntity), "entity"); diff --git a/src/EFCore/Metadata/Internal/ClrPropertySetterFactory.cs b/src/EFCore/Metadata/Internal/ClrPropertySetterFactory.cs index f8a917bd8e3..e09ac49b7dc 100644 --- a/src/EFCore/Metadata/Internal/ClrPropertySetterFactory.cs +++ b/src/EFCore/Metadata/Internal/ClrPropertySetterFactory.cs @@ -33,7 +33,8 @@ public override IClrPropertySetter Create(IPropertyBase property) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override IClrPropertySetter CreateGeneric( - MemberInfo memberInfo, IPropertyBase propertyBase) + MemberInfo memberInfo, + IPropertyBase propertyBase) { var entityParameter = Expression.Parameter(typeof(TEntity), "entity"); var valueParameter = Expression.Parameter(typeof(TValue), "value"); @@ -82,7 +83,7 @@ Expression CreateMemberAssignment(Expression parameter) return propertyBase?.IsIndexerProperty() == true ? Expression.Assign( Expression.MakeIndex( - entityParameter, (PropertyInfo)memberInfo, new List() { Expression.Constant(propertyBase.Name) }), + entityParameter, (PropertyInfo)memberInfo, new List { Expression.Constant(propertyBase.Name) }), convertedParameter) : Expression.MakeMemberAccess(parameter, memberInfo).Assign(convertedParameter); } diff --git a/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs b/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs index 27f34fe899e..4c4143b88c3 100644 --- a/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs +++ b/src/EFCore/Metadata/Internal/ConstructorBindingFactory.cs @@ -90,7 +90,7 @@ private bool TryBindConstructor( p => (p, string.IsNullOrEmpty(p.Name) ? null : _propertyFactory.FindParameter(entityType, p.ParameterType, p.Name) - ?? bind(_factories.FindFactory(p.ParameterType, p.Name), entityType, p.ParameterType, p.Name))) + ?? bind(_factories.FindFactory(p.ParameterType, p.Name), entityType, p.ParameterType, p.Name))) .ToList(); if (bindings.Any(b => b.Binding == null)) diff --git a/src/EFCore/Metadata/Internal/ConventionAnnotatableExtensions.cs b/src/EFCore/Metadata/Internal/ConventionAnnotatableExtensions.cs index b9119c32f4e..9ec35cdc747 100644 --- a/src/EFCore/Metadata/Internal/ConventionAnnotatableExtensions.cs +++ b/src/EFCore/Metadata/Internal/ConventionAnnotatableExtensions.cs @@ -31,10 +31,8 @@ public static ConventionAnnotation SetOrRemoveAnnotation( annotatable.RemoveAnnotation(name); return null; } - else - { - return annotatable.SetAnnotation(name, value, configurationSource); - } + + return annotatable.SetAnnotation(name, value, configurationSource); } } } diff --git a/src/EFCore/Metadata/Internal/ConventionAnnotation.cs b/src/EFCore/Metadata/Internal/ConventionAnnotation.cs index 6d894a3e9d1..9cfefbeb6c0 100644 --- a/src/EFCore/Metadata/Internal/ConventionAnnotation.cs +++ b/src/EFCore/Metadata/Internal/ConventionAnnotation.cs @@ -34,7 +34,8 @@ public ConventionAnnotation([NotNull] string name, [CanBeNull] object value, Con /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource GetConfigurationSource() => _configurationSource; + public virtual ConfigurationSource GetConfigurationSource() + => _configurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/EntityType.cs b/src/EFCore/Metadata/Internal/EntityType.cs index 0a82e70cb06..36a341ab186 100644 --- a/src/EFCore/Metadata/Internal/EntityType.cs +++ b/src/EFCore/Metadata/Internal/EntityType.cs @@ -192,7 +192,8 @@ public virtual InternalEntityTypeBuilder Builder /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual EntityType BaseType => _baseType; + public virtual EntityType BaseType + => _baseType; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -270,7 +271,8 @@ public virtual bool IsKeyless /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetIsKeylessConfigurationSource() => _isKeylessConfigurationSource; + public virtual ConfigurationSource? GetIsKeylessConfigurationSource() + => _isKeylessConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -423,7 +425,8 @@ public virtual void OnTypeRemoved() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetBaseTypeConfigurationSource() => _baseTypeConfigurationSource; + public virtual ConfigurationSource? GetBaseTypeConfigurationSource() + => _baseTypeConfigurationSource; [DebuggerStepThrough] private void UpdateBaseTypeConfigurationSource(ConfigurationSource configurationSource) @@ -439,7 +442,8 @@ private void UpdateBaseTypeConfigurationSource(ConfigurationSource configuration /// // Note this is ISet because there is no suitable readonly interface in the profiles we are using [DebuggerStepThrough] - public virtual ISet GetDirectlyDerivedTypes() => _directlyDerivedTypes; + public virtual ISet GetDirectlyDerivedTypes() + => _directlyDerivedTypes; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -473,8 +477,8 @@ public virtual IEnumerable GetDerivedTypes() [DebuggerStepThrough] public virtual IEnumerable GetDerivedTypesInclusive() => _directlyDerivedTypes.Count == 0 - ? new[] { this } - : new[] { this }.Concat(GetDerivedTypes()); + ? new[] { this } + : new[] { this }.Concat(GetDerivedTypes()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -485,8 +489,8 @@ public virtual IEnumerable GetDerivedTypesInclusive() [DebuggerStepThrough] public virtual IEnumerable GetForeignKeysInHierarchy() => _directlyDerivedTypes.Count == 0 - ? GetForeignKeys() - : GetForeignKeys().Concat(GetDerivedForeignKeys()); + ? GetForeignKeys() + : GetForeignKeys().Concat(GetDerivedForeignKeys()); private bool InheritsFrom(EntityType entityType) { @@ -511,7 +515,8 @@ private bool InheritsFrom(EntityType entityType) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual EntityType RootType() => (EntityType)((IEntityType)this).GetRootType(); + public virtual EntityType RootType() + => (EntityType)((IEntityType)this).GetRootType(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -519,7 +524,8 @@ private bool InheritsFrom(EntityType entityType) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); /// /// Runs the conventions when an annotation was set or removed. @@ -529,7 +535,9 @@ private bool InheritsFrom(EntityType entityType) /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => Model.ConventionDispatcher.OnEntityTypeAnnotationChanged(Builder, name, annotation, oldAnnotation); /// @@ -681,7 +689,8 @@ public virtual Key FindPrimaryKey() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual Key FindDeclaredPrimaryKey() => _primaryKey; + public virtual Key FindDeclaredPrimaryKey() + => _primaryKey; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -711,7 +720,8 @@ public virtual Key FindPrimaryKey([CanBeNull] IReadOnlyList properties /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetPrimaryKeyConfigurationSource() => _primaryKeyConfigurationSource; + public virtual ConfigurationSource? GetPrimaryKeyConfigurationSource() + => _primaryKeyConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -825,8 +835,9 @@ public virtual Key AddKey( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual Key FindKey([NotNull] IProperty property) => FindKey( - new[] { property }); + public virtual Key FindKey([NotNull] IProperty property) + => FindKey( + new[] { property }); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -848,7 +859,8 @@ public virtual Key FindKey([NotNull] IReadOnlyList properties) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable GetDeclaredKeys() => _keys.Values; + public virtual IEnumerable GetDeclaredKeys() + => _keys.Values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -926,11 +938,12 @@ private void CheckKeyNotInUse(Key key) var foreignKey = key.GetReferencingForeignKeys().FirstOrDefault(); if (foreignKey != null) { - throw new InvalidOperationException(CoreStrings.KeyInUse( - key.Properties.Format(), - this.DisplayName(), - foreignKey.Properties.Format(), - foreignKey.DeclaringEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.KeyInUse( + key.Properties.Format(), + this.DisplayName(), + foreignKey.Properties.Format(), + foreignKey.DeclaringEntityType.DisplayName())); } } @@ -940,7 +953,8 @@ private void CheckKeyNotInUse(Key key) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable GetKeys() => _baseType?.GetKeys().Concat(_keys.Values) ?? _keys.Values; + public virtual IEnumerable GetKeys() + => _baseType?.GetKeys().Concat(_keys.Values) ?? _keys.Values; #endregion @@ -1154,7 +1168,8 @@ public virtual ForeignKey FindDeclaredOwnership() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable GetDeclaredForeignKeys() => _foreignKeys; + public virtual IEnumerable GetDeclaredForeignKeys() + => _foreignKeys; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1164,8 +1179,8 @@ public virtual ForeignKey FindDeclaredOwnership() /// public virtual IEnumerable GetDerivedForeignKeys() => _directlyDerivedTypes.Count == 0 - ? Enumerable.Empty() - : GetDerivedTypes().SelectMany(et => et.GetDeclaredForeignKeys()); + ? Enumerable.Empty() + : GetDerivedTypes().SelectMany(et => et.GetDeclaredForeignKeys()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1175,10 +1190,10 @@ public virtual IEnumerable GetDerivedForeignKeys() /// public virtual IEnumerable GetForeignKeys() => _baseType != null - ? _foreignKeys.Count == 0 - ? _baseType.GetForeignKeys() - : _baseType.GetForeignKeys().Concat(_foreignKeys) - : _foreignKeys; + ? _foreignKeys.Count == 0 + ? _baseType.GetForeignKeys() + : _baseType.GetForeignKeys().Concat(_foreignKeys) + : _foreignKeys; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1252,7 +1267,7 @@ public virtual IEnumerable FindDerivedForeignKeys( => _directlyDerivedTypes.Count == 0 ? Enumerable.Empty() : GetDerivedTypes().Select(et => et.FindDeclaredForeignKey(properties, principalKey, principalEntityType)) - .Where(fk => fk != null); + .Where(fk => fk != null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1279,7 +1294,7 @@ public virtual IEnumerable FindForeignKeysInHierarchy( => _directlyDerivedTypes.Count == 0 ? ToEnumerable(FindForeignKey(properties, principalKey, principalEntityType)) : ToEnumerable(FindForeignKey(properties, principalKey, principalEntityType)) - .Concat(FindDerivedForeignKeys(properties, principalKey, principalEntityType)); + .Concat(FindDerivedForeignKeys(properties, principalKey, principalEntityType)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1547,7 +1562,8 @@ public virtual Navigation FindDeclaredNavigation([NotNull] string name) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable GetDeclaredNavigations() => _navigations.Values; + public virtual IEnumerable GetDeclaredNavigations() + => _navigations.Values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1685,7 +1701,8 @@ public virtual SkipNavigation AddSkipNavigation( if (targetEntityType.DeclaredReferencingSkipNavigations == null) { - targetEntityType.DeclaredReferencingSkipNavigations = new SortedSet(SkipNavigationComparer.Instance) { skipNavigation }; + targetEntityType.DeclaredReferencingSkipNavigations = + new SortedSet(SkipNavigationComparer.Instance) { skipNavigation }; } else { @@ -1718,16 +1735,14 @@ private Type ValidateClrMember(string name, MemberInfo memberInfo, bool throwOnN return memberInfo.GetMemberType(); } - else + + var clashingMemberInfo = ClrType?.GetMembersInHierarchy(name).FirstOrDefault(); + if (clashingMemberInfo != null) { - var clashingMemberInfo = ClrType?.GetMembersInHierarchy(name).FirstOrDefault(); - if (clashingMemberInfo != null) - { - throw new InvalidOperationException( - CoreStrings.PropertyClashingNonIndexer( - name, - this.DisplayName())); - } + throw new InvalidOperationException( + CoreStrings.PropertyClashingNonIndexer( + name, + this.DisplayName())); } } @@ -1773,7 +1788,8 @@ public virtual SkipNavigation FindDeclaredSkipNavigation([NotNull] string name) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable GetDeclaredSkipNavigations() => _skipNavigations.Values; + public virtual IEnumerable GetDeclaredSkipNavigations() + => _skipNavigations.Values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1783,8 +1799,8 @@ public virtual SkipNavigation FindDeclaredSkipNavigation([NotNull] string name) /// public virtual IEnumerable GetDerivedSkipNavigations() => _directlyDerivedTypes.Count == 0 - ? Enumerable.Empty() - : GetDerivedTypes().SelectMany(et => et.GetDeclaredSkipNavigations()); + ? Enumerable.Empty() + : GetDerivedTypes().SelectMany(et => et.GetDeclaredSkipNavigations()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1850,8 +1866,9 @@ public virtual SkipNavigation RemoveSkipNavigation([NotNull] SkipNavigation navi if (navigation.DeclaringEntityType != this) { - throw new InvalidOperationException(CoreStrings.SkipNavigationWrongType( - navigation.Name, this.DisplayName(), navigation.DeclaringEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.SkipNavigationWrongType( + navigation.Name, this.DisplayName(), navigation.DeclaringEntityType.DisplayName())); } if (navigation.Inverse?.Inverse == navigation) @@ -1920,8 +1937,8 @@ public virtual IEnumerable GetDeclaredReferencingSkipNavigations /// public virtual IEnumerable GetDerivedReferencingSkipNavigations() => _directlyDerivedTypes.Count == 0 - ? Enumerable.Empty() - : GetDerivedTypes().SelectMany(et => et.GetDeclaredReferencingSkipNavigations()); + ? Enumerable.Empty() + : GetDerivedTypes().SelectMany(et => et.GetDeclaredReferencingSkipNavigations()); private SortedSet DeclaredReferencingSkipNavigations { get; set; } @@ -2099,8 +2116,8 @@ public virtual Index FindIndex([NotNull] string name) /// public virtual IEnumerable GetDeclaredIndexes() => _namedIndexes.Count == 0 - ? _unnamedIndexes.Values - : _unnamedIndexes.Values.Concat(_namedIndexes.Values); + ? _unnamedIndexes.Values + : _unnamedIndexes.Values.Concat(_namedIndexes.Values); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -2110,8 +2127,8 @@ public virtual IEnumerable GetDeclaredIndexes() /// public virtual IEnumerable GetDerivedIndexes() => _directlyDerivedTypes.Count == 0 - ? Enumerable.Empty() - : GetDerivedTypes().SelectMany(et => et.GetDeclaredIndexes()); + ? Enumerable.Empty() + : GetDerivedTypes().SelectMany(et => et.GetDeclaredIndexes()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -2143,8 +2160,8 @@ public virtual Index FindDeclaredIndex([NotNull] string name) /// public virtual IEnumerable FindDerivedIndexes([NotNull] IReadOnlyList properties) => _directlyDerivedTypes.Count == 0 - ? Enumerable.Empty() - : GetDerivedTypes().Select(et => et.FindDeclaredIndex(properties)).Where(i => i != null); + ? Enumerable.Empty() + : GetDerivedTypes().Select(et => et.FindDeclaredIndex(properties)).Where(i => i != null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -2154,8 +2171,8 @@ public virtual IEnumerable FindDerivedIndexes([NotNull] IReadOnlyList public virtual IEnumerable FindDerivedIndexes([NotNull] string name) => _directlyDerivedTypes.Count == 0 - ? Enumerable.Empty() - : GetDerivedTypes().Select(et => et.FindDeclaredIndex(Check.NotEmpty(name, nameof(name)))).Where(i => i != null); + ? Enumerable.Empty() + : GetDerivedTypes().Select(et => et.FindDeclaredIndex(Check.NotEmpty(name, nameof(name)))).Where(i => i != null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -2165,8 +2182,8 @@ public virtual IEnumerable FindDerivedIndexes([NotNull] string name) /// public virtual IEnumerable FindIndexesInHierarchy([NotNull] IReadOnlyList properties) => _directlyDerivedTypes.Count == 0 - ? ToEnumerable(FindIndex(properties)) - : ToEnumerable(FindIndex(properties)).Concat(FindDerivedIndexes(properties)); + ? ToEnumerable(FindIndex(properties)) + : ToEnumerable(FindIndex(properties)).Concat(FindDerivedIndexes(properties)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -2176,8 +2193,8 @@ public virtual IEnumerable FindIndexesInHierarchy([NotNull] IReadOnlyList /// public virtual IEnumerable FindIndexesInHierarchy([NotNull] string name) => _directlyDerivedTypes.Count == 0 - ? ToEnumerable(FindIndex(Check.NotEmpty(name, nameof(name)))) - : ToEnumerable(FindIndex(Check.NotEmpty(name, nameof(name)))).Concat(FindDerivedIndexes(name)); + ? ToEnumerable(FindIndex(Check.NotEmpty(name, nameof(name)))) + : ToEnumerable(FindIndex(Check.NotEmpty(name, nameof(name)))).Concat(FindDerivedIndexes(name)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -2264,10 +2281,10 @@ public virtual Index RemoveIndex([NotNull] Index index) /// public virtual IEnumerable GetIndexes() => _baseType != null - ? _namedIndexes.Count == 0 && _unnamedIndexes.Count == 0 - ? _baseType.GetIndexes() - : _baseType.GetIndexes().Concat(GetDeclaredIndexes()) - : GetDeclaredIndexes(); + ? _namedIndexes.Count == 0 && _unnamedIndexes.Count == 0 + ? _baseType.GetIndexes() + : _baseType.GetIndexes().Concat(GetDeclaredIndexes()) + : GetDeclaredIndexes(); #endregion @@ -2366,10 +2383,11 @@ public virtual Property AddProperty( { throw new InvalidOperationException( HasSharedClrType - ? CoreStrings.PropertyWrongEntitySharedClrType( - memberInfo.Name, this.DisplayName(), ClrType.ShortDisplayName(), memberInfo.DeclaringType?.ShortDisplayName()) - : CoreStrings.PropertyWrongEntityClrType( - memberInfo.Name, this.DisplayName(), memberInfo.DeclaringType?.ShortDisplayName())); + ? CoreStrings.PropertyWrongEntitySharedClrType( + memberInfo.Name, this.DisplayName(), ClrType.ShortDisplayName(), + memberInfo.DeclaringType?.ShortDisplayName()) + : CoreStrings.PropertyWrongEntityClrType( + memberInfo.Name, this.DisplayName(), memberInfo.DeclaringType?.ShortDisplayName())); } } else if (IsPropertyBag) @@ -2378,7 +2396,8 @@ public virtual Property AddProperty( } else { - Check.DebugAssert(ClrType?.GetMembersInHierarchy(name).FirstOrDefault() == null, + Check.DebugAssert( + ClrType?.GetMembersInHierarchy(name).FirstOrDefault() == null, "MemberInfo not supplied for non-shadow property"); } @@ -2434,7 +2453,8 @@ public virtual Property FindDeclaredProperty([NotNull] string name) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable GetDeclaredProperties() => _properties.Values; + public virtual IEnumerable GetDeclaredProperties() + => _properties.Values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -2853,10 +2873,10 @@ public virtual ServiceProperty RemoveServiceProperty([NotNull] ServiceProperty p /// public virtual IEnumerable GetServiceProperties() => _baseType != null - ? _serviceProperties.Count == 0 - ? _baseType.GetServiceProperties() - : _baseType.GetServiceProperties().Concat(_serviceProperties.Values) - : _serviceProperties.Values; + ? _serviceProperties.Count == 0 + ? _baseType.GetServiceProperties() + : _baseType.GetServiceProperties().Concat(_serviceProperties.Values) + : _serviceProperties.Values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3042,7 +3062,8 @@ public virtual void AddData([NotNull] IEnumerable data) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ChangeTrackingStrategy? SetChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, ConfigurationSource configurationSource) + ChangeTrackingStrategy? changeTrackingStrategy, + ConfigurationSource configurationSource) { if (changeTrackingStrategy != null) { @@ -3412,7 +3433,8 @@ IConventionKey IConventionEntityType.SetPrimaryKey(IReadOnlyList [DebuggerStepThrough] - IKey IEntityType.FindPrimaryKey() => FindPrimaryKey(); + IKey IEntityType.FindPrimaryKey() + => FindPrimaryKey(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3421,7 +3443,8 @@ IConventionKey IConventionEntityType.SetPrimaryKey(IReadOnlyList [DebuggerStepThrough] - IMutableKey IMutableEntityType.FindPrimaryKey() => FindPrimaryKey(); + IMutableKey IMutableEntityType.FindPrimaryKey() + => FindPrimaryKey(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3430,7 +3453,8 @@ IConventionKey IConventionEntityType.SetPrimaryKey(IReadOnlyList [DebuggerStepThrough] - IConventionKey IConventionEntityType.FindPrimaryKey() => FindPrimaryKey(); + IConventionKey IConventionEntityType.FindPrimaryKey() + => FindPrimaryKey(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3461,7 +3485,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IKey IEntityType.FindKey(IReadOnlyList properties) => FindKey(properties); + IKey IEntityType.FindKey(IReadOnlyList properties) + => FindKey(properties); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3470,7 +3495,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableKey IMutableEntityType.FindKey(IReadOnlyList properties) => FindKey(properties); + IMutableKey IMutableEntityType.FindKey(IReadOnlyList properties) + => FindKey(properties); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3479,7 +3505,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionKey IConventionEntityType.FindKey(IReadOnlyList properties) => FindKey(properties); + IConventionKey IConventionEntityType.FindKey(IReadOnlyList properties) + => FindKey(properties); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3488,7 +3515,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IEntityType.GetKeys() => GetKeys(); + IEnumerable IEntityType.GetKeys() + => GetKeys(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3497,7 +3525,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IMutableEntityType.GetKeys() => GetKeys(); + IEnumerable IMutableEntityType.GetKeys() + => GetKeys(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3506,7 +3535,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IConventionEntityType.GetKeys() => GetKeys(); + IEnumerable IConventionEntityType.GetKeys() + => GetKeys(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3515,7 +3545,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableKey IMutableEntityType.RemoveKey(IMutableKey key) => RemoveKey((Key)key); + IMutableKey IMutableEntityType.RemoveKey(IMutableKey key) + => RemoveKey((Key)key); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3524,7 +3555,8 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionKey IConventionEntityType.RemoveKey(IConventionKey key) => RemoveKey((Key)key); + IConventionKey IConventionEntityType.RemoveKey(IConventionKey key) + => RemoveKey((Key)key); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3534,7 +3566,9 @@ IConventionKey IConventionEntityType.AddKey(IReadOnlyList p /// [DebuggerStepThrough] IMutableForeignKey IMutableEntityType.AddForeignKey( - IReadOnlyList properties, IMutableKey principalKey, IMutableEntityType principalEntityType) + IReadOnlyList properties, + IMutableKey principalKey, + IMutableEntityType principalEntityType) => AddForeignKey( properties.Cast().ToList(), (Key)principalKey, @@ -3572,7 +3606,9 @@ IConventionForeignKey IConventionEntityType.AddForeignKey( /// [DebuggerStepThrough] IForeignKey IEntityType.FindForeignKey( - IReadOnlyList properties, IKey principalKey, IEntityType principalEntityType) + IReadOnlyList properties, + IKey principalKey, + IEntityType principalEntityType) => FindForeignKey(properties, principalKey, principalEntityType); /// @@ -3583,7 +3619,9 @@ IForeignKey IEntityType.FindForeignKey( /// [DebuggerStepThrough] IMutableForeignKey IMutableEntityType.FindForeignKey( - IReadOnlyList properties, IKey principalKey, IEntityType principalEntityType) + IReadOnlyList properties, + IKey principalKey, + IEntityType principalEntityType) => FindForeignKey(properties, principalKey, principalEntityType); /// @@ -3594,7 +3632,9 @@ IMutableForeignKey IMutableEntityType.FindForeignKey( /// [DebuggerStepThrough] IConventionForeignKey IConventionEntityType.FindForeignKey( - IReadOnlyList properties, IKey principalKey, IEntityType principalEntityType) + IReadOnlyList properties, + IKey principalKey, + IEntityType principalEntityType) => FindForeignKey(properties, principalKey, principalEntityType); /// @@ -3604,7 +3644,8 @@ IConventionForeignKey IConventionEntityType.FindForeignKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IEntityType.GetForeignKeys() => GetForeignKeys(); + IEnumerable IEntityType.GetForeignKeys() + => GetForeignKeys(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3613,7 +3654,8 @@ IConventionForeignKey IConventionEntityType.FindForeignKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IMutableEntityType.GetForeignKeys() => GetForeignKeys(); + IEnumerable IMutableEntityType.GetForeignKeys() + => GetForeignKeys(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3622,7 +3664,8 @@ IConventionForeignKey IConventionEntityType.FindForeignKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IConventionEntityType.GetForeignKeys() => GetForeignKeys(); + IEnumerable IConventionEntityType.GetForeignKeys() + => GetForeignKeys(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3657,7 +3700,8 @@ IMutableSkipNavigation IMutableEntityType.AddSkipNavigation( [NotNull] IMutableEntityType targetEntityType, bool collection, bool onDependent) - => AddSkipNavigation(name, memberInfo, (EntityType)targetEntityType, collection, onDependent, + => AddSkipNavigation( + name, memberInfo, (EntityType)targetEntityType, collection, onDependent, ConfigurationSource.Explicit); /// @@ -3674,7 +3718,8 @@ IConventionSkipNavigation IConventionEntityType.AddSkipNavigation( bool collection, bool onDependent, bool fromDataAnnotation) - => AddSkipNavigation(name, memberInfo, (EntityType)targetEntityType, collection, onDependent, + => AddSkipNavigation( + name, memberInfo, (EntityType)targetEntityType, collection, onDependent, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -3827,7 +3872,9 @@ IConventionIndex IConventionEntityType.AddIndex(IReadOnlyList [DebuggerStepThrough] IConventionIndex IConventionEntityType.AddIndex( - IReadOnlyList properties, string name, bool fromDataAnnotation) + IReadOnlyList properties, + string name, + bool fromDataAnnotation) => AddIndex( properties.Cast().ToList(), name, @@ -3840,7 +3887,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IIndex IEntityType.FindIndex(IReadOnlyList properties) => FindIndex(properties); + IIndex IEntityType.FindIndex(IReadOnlyList properties) + => FindIndex(properties); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3849,7 +3897,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IIndex IEntityType.FindIndex(string name) => FindIndex(name); + IIndex IEntityType.FindIndex(string name) + => FindIndex(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3858,7 +3907,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableIndex IMutableEntityType.FindIndex(IReadOnlyList properties) => FindIndex(properties); + IMutableIndex IMutableEntityType.FindIndex(IReadOnlyList properties) + => FindIndex(properties); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3867,7 +3917,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableIndex IMutableEntityType.FindIndex(string name) => FindIndex(name); + IMutableIndex IMutableEntityType.FindIndex(string name) + => FindIndex(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3876,7 +3927,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionIndex IConventionEntityType.FindIndex(IReadOnlyList properties) => FindIndex(properties); + IConventionIndex IConventionEntityType.FindIndex(IReadOnlyList properties) + => FindIndex(properties); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3885,7 +3937,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionIndex IConventionEntityType.FindIndex(string name) => FindIndex(name); + IConventionIndex IConventionEntityType.FindIndex(string name) + => FindIndex(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3894,7 +3947,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IEntityType.GetIndexes() => GetIndexes(); + IEnumerable IEntityType.GetIndexes() + => GetIndexes(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3903,7 +3957,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IMutableEntityType.GetIndexes() => GetIndexes(); + IEnumerable IMutableEntityType.GetIndexes() + => GetIndexes(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3912,7 +3967,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IConventionEntityType.GetIndexes() => GetIndexes(); + IEnumerable IConventionEntityType.GetIndexes() + => GetIndexes(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3921,7 +3977,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableIndex IMutableEntityType.RemoveIndex(IMutableIndex index) => RemoveIndex((Index)index); + IMutableIndex IMutableEntityType.RemoveIndex(IMutableIndex index) + => RemoveIndex((Index)index); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3930,7 +3987,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionIndex IConventionEntityType.RemoveIndex(IConventionIndex index) => RemoveIndex((Index)index); + IConventionIndex IConventionEntityType.RemoveIndex(IConventionIndex index) + => RemoveIndex((Index)index); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3940,7 +3998,8 @@ IConventionIndex IConventionEntityType.AddIndex( /// [DebuggerStepThrough] IMutableProperty IMutableEntityType.AddProperty(string name, Type propertyType, MemberInfo memberInfo) - => AddProperty(name, propertyType, memberInfo ?? ClrType?.GetMembersInHierarchy(name).FirstOrDefault(), + => AddProperty( + name, propertyType, memberInfo ?? ClrType?.GetMembersInHierarchy(name).FirstOrDefault(), ConfigurationSource.Explicit, ConfigurationSource.Explicit); /// @@ -3951,7 +4010,11 @@ IMutableProperty IMutableEntityType.AddProperty(string name, Type propertyType, /// [DebuggerStepThrough] IConventionProperty IConventionEntityType.AddProperty( - string name, Type propertyType, MemberInfo memberInfo, bool setTypeConfigurationSource, bool fromDataAnnotation) + string name, + Type propertyType, + MemberInfo memberInfo, + bool setTypeConfigurationSource, + bool fromDataAnnotation) => AddProperty( name, propertyType, @@ -3968,7 +4031,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IProperty IEntityType.FindProperty(string name) => FindProperty(name); + IProperty IEntityType.FindProperty(string name) + => FindProperty(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3977,7 +4041,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableProperty IMutableEntityType.FindProperty(string name) => FindProperty(name); + IMutableProperty IMutableEntityType.FindProperty(string name) + => FindProperty(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3986,7 +4051,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionProperty IConventionEntityType.FindProperty(string name) => FindProperty(name); + IConventionProperty IConventionEntityType.FindProperty(string name) + => FindProperty(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -3995,7 +4061,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IEntityType.GetProperties() => GetProperties(); + IEnumerable IEntityType.GetProperties() + => GetProperties(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4004,7 +4071,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IMutableEntityType.GetProperties() => GetProperties(); + IEnumerable IMutableEntityType.GetProperties() + => GetProperties(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4013,7 +4081,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IConventionEntityType.GetProperties() => GetProperties(); + IEnumerable IConventionEntityType.GetProperties() + => GetProperties(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4022,7 +4091,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableProperty IMutableEntityType.RemoveProperty(IMutableProperty property) => RemoveProperty((Property)property); + IMutableProperty IMutableEntityType.RemoveProperty(IMutableProperty property) + => RemoveProperty((Property)property); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4031,7 +4101,8 @@ IConventionProperty IConventionEntityType.AddProperty( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionProperty IConventionEntityType.RemoveProperty(IConventionProperty property) => RemoveProperty((Property)property); + IConventionProperty IConventionEntityType.RemoveProperty(IConventionProperty property) + => RemoveProperty((Property)property); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4060,7 +4131,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IServiceProperty IEntityType.FindServiceProperty(string name) => FindServiceProperty(name); + IServiceProperty IEntityType.FindServiceProperty(string name) + => FindServiceProperty(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4069,7 +4141,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableServiceProperty IMutableEntityType.FindServiceProperty(string name) => FindServiceProperty(name); + IMutableServiceProperty IMutableEntityType.FindServiceProperty(string name) + => FindServiceProperty(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4078,7 +4151,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionServiceProperty IConventionEntityType.FindServiceProperty(string name) => FindServiceProperty(name); + IConventionServiceProperty IConventionEntityType.FindServiceProperty(string name) + => FindServiceProperty(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4087,7 +4161,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IEntityType.GetServiceProperties() => GetServiceProperties(); + IEnumerable IEntityType.GetServiceProperties() + => GetServiceProperties(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4096,7 +4171,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IMutableEntityType.GetServiceProperties() => GetServiceProperties(); + IEnumerable IMutableEntityType.GetServiceProperties() + => GetServiceProperties(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4105,7 +4181,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IEnumerable IConventionEntityType.GetServiceProperties() => GetServiceProperties(); + IEnumerable IConventionEntityType.GetServiceProperties() + => GetServiceProperties(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4114,7 +4191,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableServiceProperty IMutableEntityType.RemoveServiceProperty(string name) => RemoveServiceProperty(name); + IMutableServiceProperty IMutableEntityType.RemoveServiceProperty(string name) + => RemoveServiceProperty(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4123,7 +4201,8 @@ IConventionServiceProperty IConventionEntityType.AddServiceProperty(MemberInfo m /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionServiceProperty IConventionEntityType.RemoveServiceProperty(string name) => RemoveServiceProperty(name); + IConventionServiceProperty IConventionEntityType.RemoveServiceProperty(string name) + => RemoveServiceProperty(name); #endregion diff --git a/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs b/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs index 0dfa499508b..fc01e962cd6 100644 --- a/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs +++ b/src/EFCore/Metadata/Internal/EntityTypeExtensions.cs @@ -364,7 +364,8 @@ public static IKey FindDeclaredPrimaryKey([NotNull] this IEntityType entityType) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static IEnumerable FindDerivedNavigations( - [NotNull] this IEntityType entityType, [NotNull] string navigationName) + [NotNull] this IEntityType entityType, + [NotNull] string navigationName) => entityType.GetDerivedTypes().SelectMany( et => et.GetDeclaredNavigations().Where(navigation => navigationName == navigation.Name)); @@ -403,7 +404,8 @@ public static IEnumerable GetPropertiesAndNavigations( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static IEnumerable GetNotificationProperties( - [NotNull] this IEntityType entityType, [CanBeNull] string propertyName) + [NotNull] this IEntityType entityType, + [CanBeNull] string propertyName) { if (string.IsNullOrEmpty(propertyName)) { diff --git a/src/EFCore/Metadata/Internal/ForeignKey.cs b/src/EFCore/Metadata/Internal/ForeignKey.cs index 2dd8c243e89..59e51abbd84 100644 --- a/src/EFCore/Metadata/Internal/ForeignKey.cs +++ b/src/EFCore/Metadata/Internal/ForeignKey.cs @@ -149,7 +149,8 @@ public virtual IEnumerable GetReferencingSkipNavigations() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource GetConfigurationSource() => _configurationSource; + public virtual ConfigurationSource GetConfigurationSource() + => _configurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -173,7 +174,9 @@ public virtual void UpdateConfigurationSource(ConfigurationSource configurationS /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => Builder.ModelBuilder.Metadata.ConventionDispatcher.OnForeignKeyAnnotationChanged(Builder, name, annotation, oldAnnotation); /// @@ -216,7 +219,8 @@ public virtual IReadOnlyList SetProperties( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetPropertiesConfigurationSource() => _propertiesConfigurationSource; + public virtual ConfigurationSource? GetPropertiesConfigurationSource() + => _propertiesConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -240,7 +244,8 @@ public virtual void UpdatePropertiesConfigurationSource(ConfigurationSource conf /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetPrincipalKeyConfigurationSource() => _principalKeyConfigurationSource; + public virtual ConfigurationSource? GetPrincipalKeyConfigurationSource() + => _principalKeyConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -261,7 +266,8 @@ public virtual void UpdatePrincipalKeyConfigurationSource(ConfigurationSource co /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetPrincipalEndConfigurationSource() => _principalEndConfigurationSource; + public virtual ConfigurationSource? GetPrincipalEndConfigurationSource() + => _principalEndConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -318,7 +324,8 @@ public virtual Navigation SetDependentToPrincipal( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetDependentToPrincipalConfigurationSource() => _dependentToPrincipalConfigurationSource; + public virtual ConfigurationSource? GetDependentToPrincipalConfigurationSource() + => _dependentToPrincipalConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -366,7 +373,8 @@ public virtual Navigation HasPrincipalToDependent( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetPrincipalToDependentConfigurationSource() => _principalToDependentConfigurationSource; + public virtual ConfigurationSource? GetPrincipalToDependentConfigurationSource() + => _principalToDependentConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -546,7 +554,8 @@ public virtual bool IsUnique : oldUnique; } - private static bool DefaultIsUnique => false; + private static bool DefaultIsUnique + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -555,7 +564,8 @@ public virtual bool IsUnique /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetIsUniqueConfigurationSource() => _isUniqueConfigurationSource; + public virtual ConfigurationSource? GetIsUniqueConfigurationSource() + => _isUniqueConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -589,7 +599,8 @@ public virtual bool IsRequired : oldRequired; } - private bool DefaultIsRequired => !Properties.Any(p => p.IsNullable); + private bool DefaultIsRequired + => !Properties.Any(p => p.IsNullable); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -598,7 +609,8 @@ public virtual bool IsRequired /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetIsRequiredConfigurationSource() => _isRequiredConfigurationSource; + public virtual ConfigurationSource? GetIsRequiredConfigurationSource() + => _isRequiredConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -648,7 +660,8 @@ public virtual bool IsRequiredDependent : oldRequired; } - private bool DefaultIsRequiredDependent => false; + private bool DefaultIsRequiredDependent + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -657,7 +670,8 @@ public virtual bool IsRequiredDependent /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetIsRequiredDependentConfigurationSource() => _isRequiredDependentConfigurationSource; + public virtual ConfigurationSource? GetIsRequiredDependentConfigurationSource() + => _isRequiredDependentConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -702,7 +716,8 @@ public virtual DeleteBehavior DeleteBehavior return DeleteBehavior; } - private static DeleteBehavior DefaultDeleteBehavior => DeleteBehavior.ClientSetNull; + private static DeleteBehavior DefaultDeleteBehavior + => DeleteBehavior.ClientSetNull; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -711,7 +726,8 @@ public virtual DeleteBehavior DeleteBehavior /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetDeleteBehaviorConfigurationSource() => _deleteBehaviorConfigurationSource; + public virtual ConfigurationSource? GetDeleteBehaviorConfigurationSource() + => _deleteBehaviorConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -759,7 +775,8 @@ public virtual bool IsOwnership : oldIsOwnership; } - private static bool DefaultIsOwnership => false; + private static bool DefaultIsOwnership + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -768,7 +785,8 @@ public virtual bool IsOwnership /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource? GetIsOwnershipConfigurationSource() => _isOwnershipConfigurationSource; + public virtual ConfigurationSource? GetIsOwnershipConfigurationSource() + => _isOwnershipConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -972,8 +990,8 @@ void IMutableForeignKey.SetProperties(IReadOnlyList properties /// 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. /// - IMutableNavigation IMutableForeignKey.SetDependentToPrincipal(string name) => - SetDependentToPrincipal(name, ConfigurationSource.Explicit); + IMutableNavigation IMutableForeignKey.SetDependentToPrincipal(string name) + => SetDependentToPrincipal(name, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -982,8 +1000,8 @@ IMutableNavigation IMutableForeignKey.SetDependentToPrincipal(string name) => /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableNavigation IMutableForeignKey.SetDependentToPrincipal(MemberInfo property) => - SetDependentToPrincipal(property, ConfigurationSource.Explicit); + IMutableNavigation IMutableForeignKey.SetDependentToPrincipal(MemberInfo property) + => SetDependentToPrincipal(property, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -992,8 +1010,8 @@ IMutableNavigation IMutableForeignKey.SetDependentToPrincipal(MemberInfo propert /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableNavigation IMutableForeignKey.SetPrincipalToDependent(string name) => - HasPrincipalToDependent(name, ConfigurationSource.Explicit); + IMutableNavigation IMutableForeignKey.SetPrincipalToDependent(string name) + => HasPrincipalToDependent(name, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1002,8 +1020,8 @@ IMutableNavigation IMutableForeignKey.SetPrincipalToDependent(string name) => /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IMutableNavigation IMutableForeignKey.SetPrincipalToDependent(MemberInfo property) => - HasPrincipalToDependent(property, ConfigurationSource.Explicit); + IMutableNavigation IMutableForeignKey.SetPrincipalToDependent(MemberInfo property) + => HasPrincipalToDependent(property, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1170,7 +1188,8 @@ public virtual DebugView DebugView /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); private void Validate( IReadOnlyList properties, @@ -1345,11 +1364,13 @@ public static bool AreCompatible( } private static bool ArePropertyCountsEqual( - IReadOnlyList principalProperties, IReadOnlyList dependentProperties) + IReadOnlyList principalProperties, + IReadOnlyList dependentProperties) => principalProperties.Count == dependentProperties.Count; private static bool ArePropertyTypesCompatible( - IReadOnlyList principalProperties, IReadOnlyList dependentProperties) + IReadOnlyList principalProperties, + IReadOnlyList dependentProperties) => principalProperties.Select(p => p.ClrType.UnwrapNullableType()).SequenceEqual( dependentProperties.Select(p => p.ClrType.UnwrapNullableType())); } diff --git a/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs b/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs index c5f29421dda..f7872899f2b 100644 --- a/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs +++ b/src/EFCore/Metadata/Internal/ForeignKeyExtensions.cs @@ -53,7 +53,8 @@ public static IEnumerable GetNavigations([NotNull] this IForeignKey /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static IEnumerable FindNavigationsFrom( - [NotNull] this IForeignKey foreignKey, [NotNull] IEntityType entityType) + [NotNull] this IForeignKey foreignKey, + [NotNull] IEntityType entityType) { if (foreignKey.DeclaringEntityType != entityType && foreignKey.PrincipalEntityType != entityType) @@ -77,7 +78,8 @@ public static IEnumerable FindNavigationsFrom( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static IEnumerable FindNavigationsFromInHierarchy( - [NotNull] this IForeignKey foreignKey, [NotNull] IEntityType entityType) + [NotNull] this IForeignKey foreignKey, + [NotNull] IEntityType entityType) { if (!foreignKey.DeclaringEntityType.IsAssignableFrom(entityType) && !foreignKey.PrincipalEntityType.IsAssignableFrom(entityType)) @@ -91,8 +93,8 @@ public static IEnumerable FindNavigationsFromInHierarchy( return foreignKey.DeclaringEntityType.IsAssignableFrom(foreignKey.PrincipalEntityType) || foreignKey.PrincipalEntityType.IsAssignableFrom(foreignKey.DeclaringEntityType) - ? foreignKey.GetNavigations() - : foreignKey.FindNavigations(foreignKey.DeclaringEntityType.IsAssignableFrom(entityType)); + ? foreignKey.GetNavigations() + : foreignKey.FindNavigations(foreignKey.DeclaringEntityType.IsAssignableFrom(entityType)); } /// @@ -125,7 +127,8 @@ public static IEnumerable FindNavigationsTo([NotNull] this IForeign /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static IEnumerable FindNavigationsToInHierarchy( - [NotNull] this IForeignKey foreignKey, [NotNull] IEntityType entityType) + [NotNull] this IForeignKey foreignKey, + [NotNull] IEntityType entityType) { if (!foreignKey.DeclaringEntityType.IsAssignableFrom(entityType) && !foreignKey.PrincipalEntityType.IsAssignableFrom(entityType)) @@ -138,12 +141,13 @@ public static IEnumerable FindNavigationsToInHierarchy( return foreignKey.DeclaringEntityType.IsAssignableFrom(foreignKey.PrincipalEntityType) || foreignKey.PrincipalEntityType.IsAssignableFrom(foreignKey.DeclaringEntityType) - ? foreignKey.GetNavigations() - : foreignKey.FindNavigations(foreignKey.PrincipalEntityType.IsAssignableFrom(entityType)); + ? foreignKey.GetNavigations() + : foreignKey.FindNavigations(foreignKey.PrincipalEntityType.IsAssignableFrom(entityType)); } private static IEnumerable FindNavigations( - this IForeignKey foreignKey, bool toPrincipal) + this IForeignKey foreignKey, + bool toPrincipal) { if (toPrincipal) { @@ -168,7 +172,8 @@ private static IEnumerable FindNavigations( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static IEntityType ResolveOtherEntityTypeInHierarchy( - [NotNull] this IForeignKey foreignKey, [NotNull] IEntityType entityType) + [NotNull] this IForeignKey foreignKey, + [NotNull] IEntityType entityType) { if (!foreignKey.DeclaringEntityType.IsAssignableFrom(entityType) && !foreignKey.PrincipalEntityType.IsAssignableFrom(entityType)) diff --git a/src/EFCore/Metadata/Internal/Index.cs b/src/EFCore/Metadata/Internal/Index.cs index bc96931311d..09dc1786c01 100644 --- a/src/EFCore/Metadata/Internal/Index.cs +++ b/src/EFCore/Metadata/Internal/Index.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; using System.Diagnostics; using JetBrains.Annotations; @@ -114,7 +113,8 @@ public virtual InternalIndexBuilder Builder /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource GetConfigurationSource() => _configurationSource; + public virtual ConfigurationSource GetConfigurationSource() + => _configurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -163,7 +163,8 @@ public virtual bool IsUnique : oldIsUnique; } - private static bool DefaultIsUnique => false; + private static bool DefaultIsUnique + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -171,7 +172,8 @@ public virtual bool IsUnique /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetIsUniqueConfigurationSource() => _isUniqueConfigurationSource; + public virtual ConfigurationSource? GetIsUniqueConfigurationSource() + => _isUniqueConfigurationSource; private void UpdateIsUniqueConfigurationSource(ConfigurationSource configurationSource) => _isUniqueConfigurationSource = configurationSource.Max(_isUniqueConfigurationSource); @@ -184,7 +186,9 @@ private void UpdateIsUniqueConfigurationSource(ConfigurationSource configuration /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => Builder.ModelBuilder.Metadata.ConventionDispatcher.OnIndexAnnotationChanged(Builder, name, annotation, oldAnnotation); /// @@ -203,7 +207,8 @@ public virtual IDependentKeyValueFactory GetNullableValueFactory() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs b/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs index b1f0c819313..e0b2caf2228 100644 --- a/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalEntityTypeBuilder.cs @@ -44,7 +44,8 @@ public InternalEntityTypeBuilder([NotNull] EntityType metadata, [NotNull] Intern /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalKeyBuilder PrimaryKey( - [CanBeNull] IReadOnlyList propertyNames, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList propertyNames, + ConfigurationSource configurationSource) => PrimaryKey(GetOrCreateProperties(propertyNames, configurationSource, required: true), configurationSource); /// @@ -54,7 +55,8 @@ public virtual InternalKeyBuilder PrimaryKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalKeyBuilder PrimaryKey( - [CanBeNull] IReadOnlyList clrMembers, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList clrMembers, + ConfigurationSource configurationSource) => PrimaryKey(GetOrCreateProperties(clrMembers, configurationSource), configurationSource); /// @@ -64,7 +66,8 @@ public virtual InternalKeyBuilder PrimaryKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalKeyBuilder PrimaryKey( - [CanBeNull] IReadOnlyList properties, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList properties, + ConfigurationSource configurationSource) { if (!CanSetPrimaryKey(properties, configurationSource)) { @@ -136,7 +139,9 @@ public virtual InternalKeyBuilder PrimaryKey( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual bool CanSetPrimaryKey([CanBeNull] IReadOnlyList properties, ConfigurationSource configurationSource) + public virtual bool CanSetPrimaryKey( + [CanBeNull] IReadOnlyList properties, + ConfigurationSource configurationSource) { var previousPrimaryKey = Metadata.FindPrimaryKey(); if (properties == null) @@ -412,7 +417,8 @@ public virtual bool CanRemoveKey(ConfigurationSource configurationSource) || (configurationSource.Overrides(Metadata.GetIsKeylessConfigurationSource()) && !Metadata.GetKeys().Any(key => !configurationSource.Overrides(key.GetConfigurationSource())) && !Metadata.GetReferencingForeignKeys().Any(fk => !configurationSource.Overrides(fk.GetConfigurationSource())) - && !Metadata.GetForeignKeys().Any(fk => !configurationSource.Overrides(fk.GetPrincipalToDependentConfigurationSource()))); + && !Metadata.GetForeignKeys() + .Any(fk => !configurationSource.Overrides(fk.GetPrincipalToDependentConfigurationSource()))); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -590,9 +596,9 @@ private InternalPropertyBuilder Property( typeConfigurationSource = ConfigurationSource.Explicit; } else if (memberInfo != null - && propertyType != memberInfo.GetMemberType() - && memberInfo != Metadata.FindIndexerPropertyInfo() - && typeConfigurationSource != null) + && propertyType != memberInfo.GetMemberType() + && memberInfo != Metadata.FindIndexerPropertyInfo() + && typeConfigurationSource != null) { return null; } @@ -644,7 +650,8 @@ private InternalPropertyBuilder Property( else if (foreignKey.Builder.HasNavigation( (string)null, conflictingNavigation.IsOnDependent, - configurationSource.Value) == null) + configurationSource.Value) + == null) { return null; } @@ -670,18 +677,20 @@ private InternalPropertyBuilder Property( } builder = entityType.AddProperty( - propertyName, propertyType, memberInfo, typeConfigurationSource, configurationSource.Value).Builder; + propertyName, propertyType, memberInfo, typeConfigurationSource, configurationSource.Value).Builder; detachedProperties?.Attach(this); } return builder.Metadata.Builder == null - ? Metadata.FindProperty(propertyName)?.Builder - : builder; + ? Metadata.FindProperty(propertyName)?.Builder + : builder; } private bool CanRemoveProperty( - [NotNull] Property property, ConfigurationSource configurationSource, bool canOverrideSameSource = true) + [NotNull] Property property, + ConfigurationSource configurationSource, + bool canOverrideSameSource = true) { Check.NotNull(property, nameof(property)); Check.DebugAssert(property.DeclaringEntityType == Metadata, "property.DeclaringEntityType != Metadata"); @@ -692,7 +701,9 @@ private bool CanRemoveProperty( } private ConfigurationSource? RemoveProperty( - Property property, ConfigurationSource configurationSource, bool canOverrideSameSource = true) + Property property, + ConfigurationSource configurationSource, + bool canOverrideSameSource = true) { var currentConfigurationSource = property.GetConfigurationSource(); if (!configurationSource.Overrides(currentConfigurationSource) @@ -772,7 +783,8 @@ public virtual IMutableNavigationBase Navigation([NotNull] string navigationName /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalServicePropertyBuilder ServiceProperty( - [NotNull] MemberInfo memberInfo, ConfigurationSource? configurationSource) + [NotNull] MemberInfo memberInfo, + ConfigurationSource? configurationSource) { var propertyName = memberInfo.GetSimpleMemberName(); List propertiesToDetach = null; @@ -865,7 +877,8 @@ public virtual InternalServicePropertyBuilder ServiceProperty( else if (foreignKey.Builder.HasNavigation( (string)null, conflictingNavigation.IsOnDependent, - configurationSource.Value) == null) + configurationSource.Value) + == null) { return null; } @@ -902,8 +915,8 @@ public virtual InternalServicePropertyBuilder ServiceProperty( } return builder.Metadata.Builder == null - ? Metadata.FindServiceProperty(propertyName)?.Builder - : builder; + ? Metadata.FindServiceProperty(propertyName)?.Builder + : builder; } /// @@ -917,8 +930,8 @@ public virtual bool CanHaveServiceProperty([NotNull] MemberInfo memberInfo, Conf var existingProperty = Metadata.FindServiceProperty(memberInfo); return existingProperty != null ? existingProperty.DeclaringEntityType == Metadata - || (configurationSource.HasValue - && configurationSource.Value.Overrides(existingProperty.GetConfigurationSource())) + || (configurationSource.HasValue + && configurationSource.Value.Overrides(existingProperty.GetConfigurationSource())) : CanAddServiceProperty(memberInfo, configurationSource); } @@ -951,6 +964,7 @@ private static InternalServicePropertyBuilder DetachServiceProperty(ServicePrope { return null; } + serviceProperty.DeclaringEntityType.RemoveServiceProperty(serviceProperty); return builder; } @@ -1063,7 +1077,8 @@ public virtual InternalEntityTypeBuilder Ignore([NotNull] string name, Configura inverse.DeclaringEntityType.Builder.HasNoSkipNavigation(inverse, configurationSource); } - Check.DebugAssert(skipNavigation.DeclaringEntityType == Metadata, "skipNavigation.DeclaringEntityType != Metadata"); + Check.DebugAssert( + skipNavigation.DeclaringEntityType == Metadata, "skipNavigation.DeclaringEntityType != Metadata"); Metadata.Builder.HasNoSkipNavigation(skipNavigation, configurationSource); } @@ -1072,7 +1087,8 @@ public virtual InternalEntityTypeBuilder Ignore([NotNull] string name, Configura var serviceProperty = Metadata.FindServiceProperty(name); if (serviceProperty != null) { - Check.DebugAssert(serviceProperty.DeclaringEntityType == Metadata, "serviceProperty.DeclaringEntityType != Metadata"); + Check.DebugAssert( + serviceProperty.DeclaringEntityType == Metadata, "serviceProperty.DeclaringEntityType != Metadata"); Metadata.RemoveServiceProperty(serviceProperty); } @@ -1117,7 +1133,8 @@ public virtual InternalEntityTypeBuilder Ignore([NotNull] string name, Configura if (derivedProperty != null) { derivedType.Builder.RemoveProperty( - derivedProperty, configurationSource, canOverrideSameSource: configurationSource != ConfigurationSource.Explicit); + derivedProperty, configurationSource, + canOverrideSameSource: configurationSource != ConfigurationSource.Explicit); } else { @@ -1272,7 +1289,8 @@ private bool CanIgnore(string name, ConfigurationSource configurationSource, boo /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder HasQueryFilter( - [CanBeNull] LambdaExpression filter, ConfigurationSource configurationSource) + [CanBeNull] LambdaExpression filter, + ConfigurationSource configurationSource) { if (CanSetQueryFilter(filter, configurationSource)) { @@ -1302,7 +1320,8 @@ public virtual bool CanSetQueryFilter([CanBeNull] LambdaExpression filter, Confi /// [Obsolete] public virtual InternalEntityTypeBuilder HasDefiningQuery( - [CanBeNull] LambdaExpression query, ConfigurationSource configurationSource) + [CanBeNull] LambdaExpression query, + ConfigurationSource configurationSource) { if (CanSetDefiningQuery(query, configurationSource)) { @@ -1370,7 +1389,8 @@ public virtual InternalEntityTypeBuilder HasBaseType([CanBeNull] string baseEnti /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder HasBaseType( - [CanBeNull] EntityType baseEntityType, ConfigurationSource configurationSource) + [CanBeNull] EntityType baseEntityType, + ConfigurationSource configurationSource) { if (Metadata.BaseType == baseEntityType) { @@ -1400,15 +1420,16 @@ public virtual InternalEntityTypeBuilder HasBaseType( .ToDictionary(m => m.Name, m => (ConfigurationSource?)m.GetConfigurationSource()); var relationshipsToBeDetached = - FindConflictingMembers(Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredNavigations()), - baseMemberNames, - n => - { - var baseNavigation = baseEntityType.FindNavigation(n.Name); - return baseNavigation != null - && n.TargetEntityType == baseNavigation.TargetEntityType; - }, - n => n.ForeignKey.DeclaringEntityType.RemoveForeignKey(n.ForeignKey)) + FindConflictingMembers( + Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredNavigations()), + baseMemberNames, + n => + { + var baseNavigation = baseEntityType.FindNavigation(n.Name); + return baseNavigation != null + && n.TargetEntityType == baseNavigation.TargetEntityType; + }, + n => n.ForeignKey.DeclaringEntityType.RemoveForeignKey(n.ForeignKey)) ?.Select(n => n.ForeignKey).ToHashSet(); foreach (var key in Metadata.GetDeclaredKeys().ToList()) @@ -1464,15 +1485,16 @@ public virtual InternalEntityTypeBuilder HasBaseType( } var skipNavigationsToDetach = - FindConflictingMembers(Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredSkipNavigations()), - baseMemberNames, - n => - { - var baseNavigation = baseEntityType.FindSkipNavigation(n.Name); - return baseNavigation != null - && n.TargetEntityType == baseNavigation.TargetEntityType; - }, - n => n.DeclaringEntityType.Builder.HasNoSkipNavigation(n, ConfigurationSource.Explicit)); + FindConflictingMembers( + Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredSkipNavigations()), + baseMemberNames, + n => + { + var baseNavigation = baseEntityType.FindSkipNavigation(n.Name); + return baseNavigation != null + && n.TargetEntityType == baseNavigation.TargetEntityType; + }, + n => n.DeclaringEntityType.Builder.HasNoSkipNavigation(n, ConfigurationSource.Explicit)); if (skipNavigationsToDetach != null) { @@ -1488,10 +1510,11 @@ public virtual InternalEntityTypeBuilder HasBaseType( Metadata.SetIsKeyless(false, configurationSource); var propertiesToDetach = - FindConflictingMembers(Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredProperties()), - baseMemberNames, - n => baseEntityType.FindProperty(n.Name) != null, - p => p.DeclaringEntityType.Builder.RemoveProperty(p, ConfigurationSource.Explicit)); + FindConflictingMembers( + Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredProperties()), + baseMemberNames, + n => baseEntityType.FindProperty(n.Name) != null, + p => p.DeclaringEntityType.Builder.RemoveProperty(p, ConfigurationSource.Explicit)); if (propertiesToDetach != null) { @@ -1499,10 +1522,11 @@ public virtual InternalEntityTypeBuilder HasBaseType( } var servicePropertiesToDetach = - FindConflictingMembers(Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredServiceProperties()), - baseMemberNames, - n => baseEntityType.FindServiceProperty(n.Name) != null, - p => p.DeclaringEntityType.RemoveServiceProperty(p)); + FindConflictingMembers( + Metadata.GetDerivedTypesInclusive().SelectMany(et => et.GetDeclaredServiceProperties()), + baseMemberNames, + n => baseEntityType.FindServiceProperty(n.Name) != null, + p => p.DeclaringEntityType.RemoveServiceProperty(p)); if (servicePropertiesToDetach != null) { @@ -1699,7 +1723,7 @@ List FindConflictingMembers( { ConfigurationSource? baseConfigurationSource = null; if ((!member.GetConfigurationSource().OverridesStrictly( - baseEntityType.FindIgnoredConfigurationSource(member.Name)) + baseEntityType.FindIgnoredConfigurationSource(member.Name)) && member.GetConfigurationSource() != ConfigurationSource.Explicit) || (baseMemberNames.TryGetValue(member.Name, out baseConfigurationSource) && baseConfigurationSource.Overrides(member.GetConfigurationSource()) @@ -1986,7 +2010,8 @@ public virtual InternalEntityTypeBuilder HasNoRelationship( { foreach (var referencingSkipNavigation in foreignKey.ReferencingSkipNavigations.ToList()) { - Check.DebugAssert(currentConfigurationSource.Overrides(referencingSkipNavigation.GetForeignKeyConfigurationSource()), + Check.DebugAssert( + currentConfigurationSource.Overrides(referencingSkipNavigation.GetForeignKeyConfigurationSource()), "Setting the FK on the skip navigation should upgrade the configuration source"); referencingSkipNavigation.Builder.HasForeignKey(null, configurationSource); @@ -2048,6 +2073,7 @@ public static EntityType.Snapshot DetachAllMembers([NotNull] EntityType entityTy { detachedSkipNavigations = new List(); } + detachedSkipNavigations.Add(DetachSkipNavigation(skipNavigationsToBeDetached)); } @@ -2110,6 +2136,7 @@ public static EntityType.Snapshot DetachAllMembers([NotNull] EntityType entityTy { detachedServiceProperties = new List(); } + detachedServiceProperties.Add(DetachServiceProperty(servicePropertiesToBeDetached)); } @@ -2199,7 +2226,8 @@ public virtual InternalIndexBuilder HasIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalIndexBuilder HasIndex( - [NotNull] IReadOnlyList clrMembers, ConfigurationSource configurationSource) + [NotNull] IReadOnlyList clrMembers, + ConfigurationSource configurationSource) => HasIndex(GetOrCreateProperties(clrMembers, configurationSource), configurationSource); /// @@ -2221,7 +2249,8 @@ public virtual InternalIndexBuilder HasIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalIndexBuilder HasIndex( - [CanBeNull] IReadOnlyList properties, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList properties, + ConfigurationSource configurationSource) { if (properties == null) { @@ -2647,7 +2676,8 @@ private InternalForeignKeyBuilder HasRelationship( if (setTargetAsPrincipal == false || (inverseNavigation == null && navigationProperty?.GetMemberType().IsAssignableFrom( - targetEntityType.ClrType) == false)) + targetEntityType.ClrType) + == false)) { // Target is expected to be dependent or only one nav specified and it can't be the nav to principal return targetEntityType.Builder.HasRelationship( @@ -2746,7 +2776,8 @@ private InternalForeignKeyBuilder HasRelationship( // are not in the same hierarchy therefore we don't need to check existing navigations if (navigationToTarget != null) { - Check.DebugAssert(navigationToTarget.Value.Name == existingRelationship.Metadata.PrincipalToDependent?.Name, + Check.DebugAssert( + navigationToTarget.Value.Name == existingRelationship.Metadata.PrincipalToDependent?.Name, $"Expected {navigationToTarget.Value.Name}, found {existingRelationship.Metadata.PrincipalToDependent?.Name}"); existingRelationship.Metadata.UpdatePrincipalToDependentConfigurationSource(configurationSource); @@ -2758,7 +2789,8 @@ private InternalForeignKeyBuilder HasRelationship( if (inverseNavigation != null) { - Check.DebugAssert(inverseNavigation.Value.Name == existingRelationship.Metadata.DependentToPrincipal?.Name, + Check.DebugAssert( + inverseNavigation.Value.Name == existingRelationship.Metadata.DependentToPrincipal?.Name, $"Expected {inverseNavigation.Value.Name}, found {existingRelationship.Metadata.DependentToPrincipal?.Name}"); existingRelationship.Metadata.UpdateDependentToPrincipalConfigurationSource(configurationSource); @@ -3106,7 +3138,8 @@ private InternalForeignKeyBuilder HasOwnership( { if (targetEntityType.Type != null) { - ModelBuilder.SharedTypeEntity(targetEntityType.Name, targetEntityType.Type, configurationSource, shouldBeOwned: true); + ModelBuilder.SharedTypeEntity( + targetEntityType.Name, targetEntityType.Type, configurationSource, shouldBeOwned: true); } else { @@ -3209,8 +3242,9 @@ private InternalForeignKeyBuilder HasOwnership( { if (configurationSource == ConfigurationSource.Explicit) { - throw new InvalidOperationException(CoreStrings.ClashingNamedOwnedType( - targetTypeName, Metadata.DisplayName(), navigation.Name)); + throw new InvalidOperationException( + CoreStrings.ClashingNamedOwnedType( + targetTypeName, Metadata.DisplayName(), navigation.Name)); } return null; @@ -3621,13 +3655,16 @@ public virtual InternalSkipNavigationBuilder HasSkipNavigation( var existingNavigation = Metadata.FindSkipNavigation(navigationName); if (existingNavigation != null) { - Check.DebugAssert(memberInfo == null || memberInfo.IsSameAs(existingNavigation.GetIdentifyingMemberInfo()), + Check.DebugAssert( + memberInfo == null || memberInfo.IsSameAs(existingNavigation.GetIdentifyingMemberInfo()), "Expected memberInfo to be the same on the existing navigation"); - Check.DebugAssert(collection == null || collection == existingNavigation.IsCollection, + Check.DebugAssert( + collection == null || collection == existingNavigation.IsCollection, "Expected existing navigation to have the same cardinality"); - Check.DebugAssert(onDependent == null || onDependent == existingNavigation.IsOnDependent, + Check.DebugAssert( + onDependent == null || onDependent == existingNavigation.IsOnDependent, "Expected existing navigation to be on the same side"); if (existingNavigation.DeclaringEntityType != Metadata) @@ -3717,12 +3754,14 @@ public virtual InternalSkipNavigationBuilder HasSkipNavigation( var conflictingForeignKey = conflictingNavigation.ForeignKey; if (conflictingForeignKey.GetConfigurationSource() == ConfigurationSource.Convention) { - conflictingForeignKey.DeclaringEntityType.Builder.HasNoRelationship(conflictingForeignKey, ConfigurationSource.Convention); + conflictingForeignKey.DeclaringEntityType.Builder.HasNoRelationship( + conflictingForeignKey, ConfigurationSource.Convention); } else if (conflictingForeignKey.Builder.HasNavigation( (string)null, conflictingNavigation.IsOnDependent, - configurationSource.Value) == null) + configurationSource.Value) + == null) { return null; } @@ -3752,8 +3791,8 @@ public virtual InternalSkipNavigationBuilder HasSkipNavigation( } return builder.Metadata.Builder == null - ? Metadata.FindSkipNavigation(navigationName)?.Builder - : builder; + ? Metadata.FindSkipNavigation(navigationName)?.Builder + : builder; } /// @@ -3763,7 +3802,8 @@ public virtual InternalSkipNavigationBuilder HasSkipNavigation( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder HasNoSkipNavigation( - [NotNull] SkipNavigation skipNavigation, ConfigurationSource configurationSource) + [NotNull] SkipNavigation skipNavigation, + ConfigurationSource configurationSource) { if (!CanRemoveSkipNavigation(skipNavigation, configurationSource)) { @@ -3810,13 +3850,13 @@ private static InternalSkipNavigationBuilder DetachSkipNavigation(SkipNavigation /// public virtual bool ShouldReuniquifyTemporaryProperties([NotNull] ForeignKey foreignKey) => TryCreateUniqueProperties( - foreignKey.PrincipalKey.Properties.Count, - foreignKey.Properties, - foreignKey.PrincipalKey.Properties.Select(p => p.ClrType), - foreignKey.PrincipalKey.Properties.Select(p => p.Name), - foreignKey.IsRequired + foreignKey.PrincipalKey.Properties.Count, + foreignKey.Properties, + foreignKey.PrincipalKey.Properties.Select(p => p.ClrType), + foreignKey.PrincipalKey.Properties.Select(p => p.Name), + foreignKey.IsRequired && foreignKey.GetIsRequiredConfigurationSource().Overrides(ConfigurationSource.Convention), - foreignKey.DependentToPrincipal?.Name + foreignKey.DependentToPrincipal?.Name ?? foreignKey.ReferencingSkipNavigations?.FirstOrDefault()?.Inverse?.Name ?? foreignKey.PrincipalEntityType.ShortName()) .Item1; @@ -3884,8 +3924,8 @@ private IReadOnlyList CreateUniqueProperties( using var principalPropertyTypesEnumerator = principalPropertyTypes.GetEnumerator(); for (var i = 0; i < propertyCount - && principalPropertyNamesEnumerator.MoveNext() - && principalPropertyTypesEnumerator.MoveNext(); + && principalPropertyNamesEnumerator.MoveNext() + && principalPropertyTypesEnumerator.MoveNext(); i++) { var keyPropertyName = principalPropertyNamesEnumerator.Current; @@ -4033,7 +4073,8 @@ public virtual IReadOnlyList GetOrCreateProperties( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IReadOnlyList GetOrCreateProperties( - [CanBeNull] IEnumerable clrMembers, ConfigurationSource? configurationSource) + [CanBeNull] IEnumerable clrMembers, + ConfigurationSource? configurationSource) { if (clrMembers == null) { @@ -4062,7 +4103,8 @@ public virtual IReadOnlyList GetOrCreateProperties( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IReadOnlyList GetActualProperties( - [CanBeNull] IReadOnlyList properties, ConfigurationSource? configurationSource) + [CanBeNull] IReadOnlyList properties, + ConfigurationSource? configurationSource) { if (properties == null) { @@ -4100,7 +4142,8 @@ public virtual IReadOnlyList GetActualProperties( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder HasChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, ConfigurationSource configurationSource) + ChangeTrackingStrategy? changeTrackingStrategy, + ConfigurationSource configurationSource) { if (CanSetChangeTrackingStrategy(changeTrackingStrategy, configurationSource)) { @@ -4119,7 +4162,8 @@ public virtual InternalEntityTypeBuilder HasChangeTrackingStrategy( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, ConfigurationSource configurationSource) + ChangeTrackingStrategy? changeTrackingStrategy, + ConfigurationSource configurationSource) => configurationSource.Overrides(Metadata.GetChangeTrackingStrategyConfigurationSource()) || Metadata.GetChangeTrackingStrategy() == changeTrackingStrategy; @@ -4130,7 +4174,8 @@ public virtual bool CanSetChangeTrackingStrategy( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) { if (CanSetPropertyAccessMode(propertyAccessMode, configurationSource)) { @@ -4170,15 +4215,17 @@ public virtual DiscriminatorBuilder HasDiscriminator(ConfigurationSource configu /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual DiscriminatorBuilder HasDiscriminator( - [CanBeNull] string name, [CanBeNull] Type type, ConfigurationSource configurationSource) + [CanBeNull] string name, + [CanBeNull] Type type, + ConfigurationSource configurationSource) { Check.DebugAssert(name != null || type != null, $"Either {nameof(name)} or {nameof(type)} should be non-null"); return CanSetDiscriminator(name, type, configurationSource) - ? DiscriminatorBuilder( - GetOrCreateDiscriminatorProperty(type, name, configurationSource), - configurationSource) - : null; + ? DiscriminatorBuilder( + GetOrCreateDiscriminatorProperty(type, name, configurationSource), + configurationSource) + : null; } /// @@ -4210,10 +4257,10 @@ private InternalPropertyBuilder GetOrCreateDiscriminatorProperty(Type type, stri } return Metadata.RootType().Builder.Property( - type ?? discriminatorProperty?.ClrType ?? _defaultDiscriminatorType, - name ?? discriminatorProperty?.Name ?? _defaultDiscriminatorName, - typeConfigurationSource: type != null ? configurationSource : (ConfigurationSource?)null, - configurationSource) + type ?? discriminatorProperty?.ClrType ?? _defaultDiscriminatorType, + name ?? discriminatorProperty?.Name ?? _defaultDiscriminatorName, + typeConfigurationSource: type != null ? configurationSource : (ConfigurationSource?)null, + configurationSource) ?.AfterSave(PropertySaveBehavior.Throw, ConfigurationSource.Convention); } @@ -4323,7 +4370,9 @@ private bool CanRemoveDiscriminator(ConfigurationSource configurationSource) => CanSetAnnotation(CoreAnnotationNames.DiscriminatorProperty, null, configurationSource); private bool CanAddDiscriminatorProperty( - [NotNull] Type propertyType, [NotNull] string name, ConfigurationSource? typeConfigurationSource) + [NotNull] Type propertyType, + [NotNull] string name, + ConfigurationSource? typeConfigurationSource) { var conflictingProperty = Metadata.FindPropertiesInHierarchy(name).FirstOrDefault(); if (conflictingProperty != null @@ -4393,7 +4442,10 @@ bool IConventionEntityTypeBuilder.CanSetBaseType(IConventionEntityType baseEntit /// [DebuggerStepThrough] IConventionPropertyBuilder IConventionEntityTypeBuilder.Property( - Type propertyType, string propertyName, bool setTypeConfigurationSource, bool fromDataAnnotation) + Type propertyType, + string propertyName, + bool setTypeConfigurationSource, + bool fromDataAnnotation) => Property( propertyType, propertyName, setTypeConfigurationSource @@ -4418,7 +4470,8 @@ IConventionPropertyBuilder IConventionEntityTypeBuilder.Property(MemberInfo memb /// [DebuggerStepThrough] IReadOnlyList IConventionEntityTypeBuilder.GetOrCreateProperties( - IReadOnlyList propertyNames, bool fromDataAnnotation) + IReadOnlyList propertyNames, + bool fromDataAnnotation) => GetOrCreateProperties( propertyNames, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4430,7 +4483,8 @@ IReadOnlyList IConventionEntityTypeBuilder.GetOrCreatePrope /// [DebuggerStepThrough] IReadOnlyList IConventionEntityTypeBuilder.GetOrCreateProperties( - IEnumerable memberInfos, bool fromDataAnnotation) + IEnumerable memberInfos, + bool fromDataAnnotation) => GetOrCreateProperties(memberInfos, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -4491,7 +4545,8 @@ bool IConventionEntityTypeBuilder.CanIgnore(string name, bool fromDataAnnotation /// [DebuggerStepThrough] IConventionKeyBuilder IConventionEntityTypeBuilder.PrimaryKey( - IReadOnlyList properties, bool fromDataAnnotation) + IReadOnlyList properties, + bool fromDataAnnotation) => PrimaryKey( properties as IReadOnlyList ?? properties?.Cast().ToList(), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4538,7 +4593,8 @@ IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoKey(bool fromData /// [DebuggerStepThrough] IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoKey( - IReadOnlyList properties, bool fromDataAnnotation) + IReadOnlyList properties, + bool fromDataAnnotation) { Check.NotEmpty(properties, nameof(properties)); @@ -4586,7 +4642,8 @@ bool IConventionEntityTypeBuilder.CanRemoveKey(bool fromDataAnnotation) /// [DebuggerStepThrough] IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( - IReadOnlyList propertyNames, bool fromDataAnnotation) + IReadOnlyList propertyNames, + bool fromDataAnnotation) => HasIndex( propertyNames, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4599,7 +4656,9 @@ IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( /// [DebuggerStepThrough] IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( - IReadOnlyList propertyNames, string name, bool fromDataAnnotation) + IReadOnlyList propertyNames, + string name, + bool fromDataAnnotation) => HasIndex( propertyNames, name, @@ -4613,7 +4672,8 @@ IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( /// [DebuggerStepThrough] IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( - IReadOnlyList properties, bool fromDataAnnotation) + IReadOnlyList properties, + bool fromDataAnnotation) => HasIndex( properties as IReadOnlyList ?? properties.Cast().ToList(), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4625,7 +4685,9 @@ IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( - IReadOnlyList properties, string name, bool fromDataAnnotation) + IReadOnlyList properties, + string name, + bool fromDataAnnotation) => HasIndex( properties as IReadOnlyList ?? properties.Cast().ToList(), name, @@ -4639,7 +4701,8 @@ IConventionIndexBuilder IConventionEntityTypeBuilder.HasIndex( /// [DebuggerStepThrough] IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoIndex( - IReadOnlyList properties, bool fromDataAnnotation) + IReadOnlyList properties, + bool fromDataAnnotation) { Check.NotEmpty(properties, nameof(properties)); @@ -4677,7 +4740,8 @@ bool IConventionEntityTypeBuilder.CanRemoveIndex([NotNull] IConventionIndex inde /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( - IConventionEntityType targetEntityType, bool fromDataAnnotation) + IConventionEntityType targetEntityType, + bool fromDataAnnotation) => HasRelationship( (EntityType)targetEntityType, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4689,7 +4753,9 @@ IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( - IConventionEntityType principalEntityType, IReadOnlyList dependentProperties, bool fromDataAnnotation) + IConventionEntityType principalEntityType, + IReadOnlyList dependentProperties, + bool fromDataAnnotation) => HasRelationship( (EntityType)principalEntityType, dependentProperties as IReadOnlyList ?? dependentProperties.Cast().ToList(), @@ -4703,7 +4769,9 @@ IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( - IConventionEntityType principalEntityType, IConventionKey principalKey, bool fromDataAnnotation) + IConventionEntityType principalEntityType, + IConventionKey principalKey, + bool fromDataAnnotation) => HasRelationship( (EntityType)principalEntityType, (Key)principalKey, @@ -4735,7 +4803,10 @@ IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( - IConventionEntityType targetEntityType, string navigationName, bool setTargetAsPrincipal, bool fromDataAnnotation) + IConventionEntityType targetEntityType, + string navigationName, + bool setTargetAsPrincipal, + bool fromDataAnnotation) => HasRelationship( (EntityType)targetEntityType, navigationName, @@ -4750,7 +4821,10 @@ IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasRelationship( - IConventionEntityType targetEntityType, MemberInfo navigation, bool setTargetAsPrincipal, bool fromDataAnnotation) + IConventionEntityType targetEntityType, + MemberInfo navigation, + bool setTargetAsPrincipal, + bool fromDataAnnotation) => HasRelationship( (EntityType)targetEntityType, navigation, @@ -4820,7 +4894,9 @@ IConventionSkipNavigationBuilder IConventionEntityTypeBuilder.HasSkipNavigation( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasOwnership( - Type targetEntityType, string navigationName, bool fromDataAnnotation) + Type targetEntityType, + string navigationName, + bool fromDataAnnotation) => HasOwnership( targetEntityType, navigationName, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4833,7 +4909,9 @@ IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasOwnership( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasOwnership( - Type targetEntityType, MemberInfo navigation, bool fromDataAnnotation) + Type targetEntityType, + MemberInfo navigation, + bool fromDataAnnotation) => HasOwnership( targetEntityType, navigation, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4846,7 +4924,10 @@ IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasOwnership( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasOwnership( - Type targetEntityType, string navigationName, string inversePropertyName, bool fromDataAnnotation) + Type targetEntityType, + string navigationName, + string inversePropertyName, + bool fromDataAnnotation) => HasOwnership( targetEntityType, navigationName, inversePropertyName, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4859,7 +4940,10 @@ IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasOwnership( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionEntityTypeBuilder.HasOwnership( - Type targetEntityType, MemberInfo navigation, MemberInfo inverseProperty, bool fromDataAnnotation) + Type targetEntityType, + MemberInfo navigation, + MemberInfo inverseProperty, + bool fromDataAnnotation) => HasOwnership( targetEntityType, navigation, inverseProperty, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4895,7 +4979,8 @@ IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoRelationship( /// [DebuggerStepThrough] IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoRelationship( - IConventionForeignKey foreignKey, bool fromDataAnnotation) + IConventionForeignKey foreignKey, + bool fromDataAnnotation) => HasNoRelationship( (ForeignKey)foreignKey, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4908,8 +4993,9 @@ IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoRelationship( /// [DebuggerStepThrough] bool IConventionEntityTypeBuilder.CanRemoveRelationship([NotNull] IConventionForeignKey foreignKey, bool fromDataAnnotation) - => CanRemoveForeignKey((ForeignKey)foreignKey, - fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); + => CanRemoveForeignKey( + (ForeignKey)foreignKey, + fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4967,14 +5053,18 @@ IConventionSkipNavigationBuilder IConventionEntityTypeBuilder.HasSkipNavigation( /// [DebuggerStepThrough] - IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoSkipNavigation(ISkipNavigation skipNavigation, bool fromDataAnnotation) - => HasNoSkipNavigation((SkipNavigation)skipNavigation, + IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoSkipNavigation( + ISkipNavigation skipNavigation, + bool fromDataAnnotation) + => HasNoSkipNavigation( + (SkipNavigation)skipNavigation, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// [DebuggerStepThrough] bool IConventionEntityTypeBuilder.CanRemoveSkipNavigation(ISkipNavigation skipNavigation, bool fromDataAnnotation) - => CanRemoveSkipNavigation((SkipNavigation)skipNavigation, + => CanRemoveSkipNavigation( + (SkipNavigation)skipNavigation, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5027,7 +5117,8 @@ bool IConventionEntityTypeBuilder.CanSetDefiningQuery(LambdaExpression query, bo /// [DebuggerStepThrough] IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, bool fromDataAnnotation) + ChangeTrackingStrategy? changeTrackingStrategy, + bool fromDataAnnotation) => HasChangeTrackingStrategy( changeTrackingStrategy, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -5039,7 +5130,8 @@ IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasChangeTrackingStrat /// [DebuggerStepThrough] bool IConventionEntityTypeBuilder.CanSetChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, bool fromDataAnnotation) + ChangeTrackingStrategy? changeTrackingStrategy, + bool fromDataAnnotation) => CanSetChangeTrackingStrategy( changeTrackingStrategy, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -5051,7 +5143,8 @@ bool IConventionEntityTypeBuilder.CanSetChangeTrackingStrategy( /// [DebuggerStepThrough] IConventionEntityTypeBuilder IConventionEntityTypeBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -5085,7 +5178,8 @@ IConventionDiscriminatorBuilder IConventionEntityTypeBuilder.HasDiscriminator(bo /// [DebuggerStepThrough] IConventionDiscriminatorBuilder IConventionEntityTypeBuilder.HasDiscriminator(Type type, bool fromDataAnnotation) - => HasDiscriminator(name: null, Check.NotNull(type, nameof(type)), + => HasDiscriminator( + name: null, Check.NotNull(type, nameof(type)), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5096,7 +5190,8 @@ IConventionDiscriminatorBuilder IConventionEntityTypeBuilder.HasDiscriminator(Ty /// [DebuggerStepThrough] IConventionDiscriminatorBuilder IConventionEntityTypeBuilder.HasDiscriminator(string name, bool fromDataAnnotation) - => HasDiscriminator(Check.NotEmpty(name, nameof(name)), type: null, + => HasDiscriminator( + Check.NotEmpty(name, nameof(name)), type: null, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5107,7 +5202,8 @@ IConventionDiscriminatorBuilder IConventionEntityTypeBuilder.HasDiscriminator(st /// [DebuggerStepThrough] IConventionDiscriminatorBuilder IConventionEntityTypeBuilder.HasDiscriminator(string name, Type type, bool fromDataAnnotation) - => HasDiscriminator(Check.NotEmpty(name, nameof(name)), Check.NotNull(type, nameof(type)), + => HasDiscriminator( + Check.NotEmpty(name, nameof(name)), Check.NotNull(type, nameof(type)), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5139,7 +5235,8 @@ IConventionEntityTypeBuilder IConventionEntityTypeBuilder.HasNoDiscriminator(boo /// [DebuggerStepThrough] bool IConventionEntityTypeBuilder.CanSetDiscriminator(string name, bool fromDataAnnotation) - => CanSetDiscriminator(name, type: null, + => CanSetDiscriminator( + name, type: null, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5150,7 +5247,8 @@ bool IConventionEntityTypeBuilder.CanSetDiscriminator(string name, bool fromData /// [DebuggerStepThrough] bool IConventionEntityTypeBuilder.CanSetDiscriminator(Type type, bool fromDataAnnotation) - => CanSetDiscriminator(name: null, type, + => CanSetDiscriminator( + name: null, type, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5161,7 +5259,8 @@ bool IConventionEntityTypeBuilder.CanSetDiscriminator(Type type, bool fromDataAn /// [DebuggerStepThrough] bool IConventionEntityTypeBuilder.CanSetDiscriminator(string name, Type type, bool fromDataAnnotation) - => CanSetDiscriminator(name, type, + => CanSetDiscriminator( + name, type, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5172,7 +5271,8 @@ bool IConventionEntityTypeBuilder.CanSetDiscriminator(string name, Type type, bo /// [DebuggerStepThrough] bool IConventionEntityTypeBuilder.CanSetDiscriminator([NotNull] MemberInfo memberInfo, bool fromDataAnnotation) - => CanSetDiscriminator(Check.NotNull(memberInfo, nameof(memberInfo)).GetSimpleMemberName(), memberInfo.GetMemberType(), + => CanSetDiscriminator( + Check.NotNull(memberInfo, nameof(memberInfo)).GetSimpleMemberName(), memberInfo.GetMemberType(), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// @@ -5187,7 +5287,10 @@ bool IConventionEntityTypeBuilder.CanRemoveDiscriminator(bool fromDataAnnotation /// [DebuggerStepThrough] - IConventionPropertyBuilder IConventionEntityTypeBuilder.CreateUniqueProperty(Type propertyType, string basePropertyName, bool required) + IConventionPropertyBuilder IConventionEntityTypeBuilder.CreateUniqueProperty( + Type propertyType, + string basePropertyName, + bool required) => CreateUniqueProperty(propertyType, basePropertyName, required); } } diff --git a/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs b/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs index d36f5065a4c..fc96ee5cf19 100644 --- a/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs @@ -319,7 +319,8 @@ private InternalForeignKeyBuilder HasNavigations( inverse.DeclaringEntityType.Builder.HasNoSkipNavigation(conflictingSkipNavigation, configurationSource); } - conflictingSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation(conflictingSkipNavigation, configurationSource); + conflictingSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation( + conflictingSkipNavigation, configurationSource); } } @@ -355,7 +356,8 @@ private InternalForeignKeyBuilder HasNavigations( inverse.DeclaringEntityType.Builder.HasNoSkipNavigation(conflictingSkipNavigation, configurationSource); } - conflictingSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation(conflictingSkipNavigation, configurationSource); + conflictingSkipNavigation.DeclaringEntityType.Builder.HasNoSkipNavigation( + conflictingSkipNavigation, configurationSource); } } @@ -814,8 +816,9 @@ private bool CanSetNavigations( } conflictingNavigationsFound = compatibleRelationship != null - || resolvableRelationships.Any(r => - (r.Resolution & (Resolution.ResetToDependent | Resolution.ResetToPrincipal)) != 0); + || resolvableRelationships.Any( + r => + (r.Resolution & (Resolution.ResetToDependent | Resolution.ResetToPrincipal)) != 0); if (shouldBeUnique == null && (Metadata.IsUnique || configurationSource.OverridesStrictly(Metadata.GetIsUniqueConfigurationSource())) @@ -864,11 +867,11 @@ private bool CanSetNavigations( private bool CanRemoveNavigation(bool pointsToPrincipal, ConfigurationSource? configurationSource, bool overrideSameSource = true) => pointsToPrincipal ? Metadata.DependentToPrincipal == null - || (configurationSource.Overrides(Metadata.GetDependentToPrincipalConfigurationSource()) - && (overrideSameSource || configurationSource != Metadata.GetDependentToPrincipalConfigurationSource())) + || (configurationSource.Overrides(Metadata.GetDependentToPrincipalConfigurationSource()) + && (overrideSameSource || configurationSource != Metadata.GetDependentToPrincipalConfigurationSource())) : Metadata.PrincipalToDependent == null - || (configurationSource.Overrides(Metadata.GetPrincipalToDependentConfigurationSource()) - && (overrideSameSource || configurationSource != Metadata.GetPrincipalToDependentConfigurationSource())); + || (configurationSource.Overrides(Metadata.GetPrincipalToDependentConfigurationSource()) + && (overrideSameSource || configurationSource != Metadata.GetPrincipalToDependentConfigurationSource())); private static bool IsCompatible( [NotNull] MemberInfo navigationMember, @@ -1004,8 +1007,8 @@ public virtual InternalForeignKeyBuilder IsRequiredDependent(bool? required, Con public virtual bool CanSetIsRequiredDependent(bool? required, ConfigurationSource? configurationSource) => Metadata.IsRequiredDependent == required || ((required != true - || Metadata.IsUnique - || configurationSource.Value.Overrides(Metadata.GetIsUniqueConfigurationSource())) + || Metadata.IsUnique + || configurationSource.Value.Overrides(Metadata.GetIsUniqueConfigurationSource())) && configurationSource.Overrides(Metadata.GetIsRequiredDependentConfigurationSource())); /// @@ -1047,7 +1050,7 @@ public virtual InternalForeignKeyBuilder IsOwnership(bool? ownership, Configurat Check.DebugAssert( Metadata.PrincipalToDependent == null || declaringType.DefiningNavigationName == Metadata.PrincipalToDependent.Name, - $"Unexpected navigation"); + "Unexpected navigation"); if (otherOwnership != null && !configurationSource.Overrides(otherOwnership.GetConfigurationSource())) @@ -1346,7 +1349,8 @@ private bool CanSetIsUnique(bool? unique, ConfigurationSource? configurationSour /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder DependentEntityType( - [NotNull] InternalEntityTypeBuilder dependentEntityTypeBuilder, ConfigurationSource configurationSource) + [NotNull] InternalEntityTypeBuilder dependentEntityTypeBuilder, + ConfigurationSource configurationSource) => DependentEntityType(dependentEntityTypeBuilder.Metadata, configurationSource); /// @@ -1356,7 +1360,8 @@ public virtual InternalForeignKeyBuilder DependentEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder DependentEntityType( - [NotNull] Type dependentType, ConfigurationSource configurationSource) + [NotNull] Type dependentType, + ConfigurationSource configurationSource) => DependentEntityType( ModelBuilder.Entity(dependentType, configurationSource).Metadata, configurationSource); @@ -1368,7 +1373,8 @@ public virtual InternalForeignKeyBuilder DependentEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder DependentEntityType( - [NotNull] string dependentTypeName, ConfigurationSource configurationSource) + [NotNull] string dependentTypeName, + ConfigurationSource configurationSource) => DependentEntityType(ModelBuilder.Entity(dependentTypeName, configurationSource).Metadata, configurationSource); /// @@ -1378,7 +1384,8 @@ public virtual InternalForeignKeyBuilder DependentEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder DependentEntityType( - [NotNull] EntityType dependentEntityType, ConfigurationSource configurationSource) + [NotNull] EntityType dependentEntityType, + ConfigurationSource configurationSource) { Check.NotNull(dependentEntityType, nameof(dependentEntityType)); @@ -1410,7 +1417,8 @@ public virtual InternalForeignKeyBuilder DependentEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder PrincipalEntityType( - [NotNull] InternalEntityTypeBuilder principalEntityTypeBuilder, ConfigurationSource configurationSource) + [NotNull] InternalEntityTypeBuilder principalEntityTypeBuilder, + ConfigurationSource configurationSource) => PrincipalEntityType(principalEntityTypeBuilder.Metadata, configurationSource); /// @@ -1420,7 +1428,8 @@ public virtual InternalForeignKeyBuilder PrincipalEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder PrincipalEntityType( - [NotNull] Type principalType, ConfigurationSource configurationSource) + [NotNull] Type principalType, + ConfigurationSource configurationSource) => PrincipalEntityType( ModelBuilder.Entity(principalType, configurationSource).Metadata, configurationSource); @@ -1432,7 +1441,8 @@ public virtual InternalForeignKeyBuilder PrincipalEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder PrincipalEntityType( - [NotNull] string principalTypeName, ConfigurationSource configurationSource) + [NotNull] string principalTypeName, + ConfigurationSource configurationSource) => PrincipalEntityType( ModelBuilder.Entity(principalTypeName, configurationSource).Metadata, configurationSource); @@ -1444,7 +1454,8 @@ public virtual InternalForeignKeyBuilder PrincipalEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder PrincipalEntityType( - [NotNull] EntityType principalEntityType, ConfigurationSource configurationSource) + [NotNull] EntityType principalEntityType, + ConfigurationSource configurationSource) { Check.NotNull(principalEntityType, nameof(principalEntityType)); @@ -1601,7 +1612,8 @@ public virtual bool CanSetEntityTypes( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanInvert( - [CanBeNull] IReadOnlyList newForeignKeyProperties, ConfigurationSource? configurationSource) + [CanBeNull] IReadOnlyList newForeignKeyProperties, + ConfigurationSource? configurationSource) => configurationSource.Overrides(Metadata.GetPrincipalEndConfigurationSource()) && ((newForeignKeyProperties == null) || CanSetForeignKey(newForeignKeyProperties, Metadata.PrincipalEntityType, configurationSource)); @@ -1689,7 +1701,8 @@ public virtual InternalForeignKeyBuilder ReuniquifyTemporaryProperties(bool forc /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder HasForeignKey( - [CanBeNull] IReadOnlyList properties, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList properties, + ConfigurationSource configurationSource) => HasForeignKey(properties, Metadata.DeclaringEntityType, configurationSource); /// @@ -1699,7 +1712,8 @@ public virtual InternalForeignKeyBuilder HasForeignKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder HasForeignKey( - [CanBeNull] IReadOnlyList propertyNames, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList propertyNames, + ConfigurationSource configurationSource) => HasForeignKey(propertyNames, Metadata.DeclaringEntityType, configurationSource); /// @@ -1709,7 +1723,8 @@ public virtual InternalForeignKeyBuilder HasForeignKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder HasForeignKey( - [CanBeNull] IReadOnlyList properties, [NotNull] EntityType dependentEntityType, + [CanBeNull] IReadOnlyList properties, + [NotNull] EntityType dependentEntityType, ConfigurationSource configurationSource) => HasForeignKey( dependentEntityType.Builder.GetOrCreateProperties(properties, configurationSource), @@ -1723,7 +1738,8 @@ public virtual InternalForeignKeyBuilder HasForeignKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder HasForeignKey( - [CanBeNull] IReadOnlyList propertyNames, [NotNull] EntityType dependentEntityType, + [CanBeNull] IReadOnlyList propertyNames, + [NotNull] EntityType dependentEntityType, ConfigurationSource configurationSource) => HasForeignKey( dependentEntityType.Builder.GetOrCreateProperties( @@ -1743,7 +1759,8 @@ public virtual InternalForeignKeyBuilder HasForeignKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder HasForeignKey( - [CanBeNull] IReadOnlyList properties, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList properties, + ConfigurationSource configurationSource) => HasForeignKey(properties, Metadata.DeclaringEntityType, configurationSource); /// @@ -1956,7 +1973,8 @@ public virtual InternalForeignKeyBuilder HasPrincipalKey( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalForeignKeyBuilder HasPrincipalKey( - [CanBeNull] IReadOnlyList properties, ConfigurationSource configurationSource) + [CanBeNull] IReadOnlyList properties, + ConfigurationSource configurationSource) { if (properties == null) { @@ -2107,10 +2125,11 @@ private InternalForeignKeyBuilder ReplaceForeignKey( && Metadata.GetIsRequiredConfigurationSource() == ConfigurationSource.Explicit && Metadata.GetPrincipalEndConfigurationSource() == null) { - throw new InvalidOperationException(CoreStrings.AmbiguousEndRequiredInverted( - Metadata.Properties.Format(), - Metadata.DeclaringEntityType.DisplayName(), - Metadata.PrincipalEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.AmbiguousEndRequiredInverted( + Metadata.Properties.Format(), + Metadata.DeclaringEntityType.DisplayName(), + Metadata.PrincipalEntityType.DisplayName())); } principalEntityTypeBuilder ??= (oldRelationshipInverted @@ -2471,7 +2490,7 @@ private InternalForeignKeyBuilder ReplaceForeignKey( dependentProperties?.Count == 0 ? null : dependentProperties, principalKey, navigationToPrincipal?.Name - ?? referencingSkipNavigations?.FirstOrDefault().Navigation?.Inverse?.Name, + ?? referencingSkipNavigations?.FirstOrDefault().Navigation?.Inverse?.Name, isRequired, configurationSource: null); @@ -2641,11 +2660,11 @@ private InternalForeignKeyBuilder ReplaceForeignKey( } } else if (oldNavigationToPrincipal != null - && newRelationshipBuilder.Metadata.DependentToPrincipal == null - && newRelationshipBuilder.CanSetNavigations( - oldNavigationToPrincipal.CreateMemberIdentity(), - navigationToDependent: null, - oldToPrincipalConfigurationSource)) + && newRelationshipBuilder.Metadata.DependentToPrincipal == null + && newRelationshipBuilder.CanSetNavigations( + oldNavigationToPrincipal.CreateMemberIdentity(), + navigationToDependent: null, + oldToPrincipalConfigurationSource)) { newRelationshipBuilder = newRelationshipBuilder.HasNavigations( oldNavigationToPrincipal.CreateMemberIdentity(), @@ -2684,8 +2703,8 @@ private InternalForeignKeyBuilder ReplaceForeignKey( } } else if (oldNavigationToDependent != null - && newRelationshipBuilder.Metadata.PrincipalToDependent == null - && newRelationshipBuilder.CanSetNavigations( + && newRelationshipBuilder.Metadata.PrincipalToDependent == null + && newRelationshipBuilder.CanSetNavigations( navigationToPrincipal: null, oldNavigationToDependent.CreateMemberIdentity(), oldToDependentConfigurationSource)) @@ -3224,8 +3243,8 @@ private InternalForeignKeyBuilder FindCompatibleRelationship( var candidates = unresolvableRelationships.Concat( resolvableRelationships.Where(r => r.SameConfigurationSource).Concat( - resolvableRelationships.Where(r => !r.SameConfigurationSource)) - .Select(r => r.Builder)); + resolvableRelationships.Where(r => !r.SameConfigurationSource)) + .Select(r => r.Builder)); foreach (var candidateRelationship in candidates) { if (!candidateRelationship.CanSetRelatedTypes( @@ -3297,7 +3316,10 @@ private InternalForeignKeyBuilder FindCompatibleRelationship( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public static void ThrowForConflictingNavigation([NotNull] IForeignKey foreignKey, [NotNull] string newInverseName, bool newToPrincipal) + public static void ThrowForConflictingNavigation( + [NotNull] IForeignKey foreignKey, + [NotNull] string newInverseName, + bool newToPrincipal) => ThrowForConflictingNavigation( foreignKey, foreignKey.PrincipalEntityType, foreignKey.DeclaringEntityType, @@ -3318,18 +3340,22 @@ public static void ThrowForConflictingNavigation( [CanBeNull] string navigationToPrincipal) => throw new InvalidOperationException( CoreStrings.ConflictingRelationshipNavigation( - principalEntityType.DisplayName() + (navigationToDependent == null - ? "" - : "." + navigationToDependent), - dependentEntityType.DisplayName() + (navigationToPrincipal == null - ? "" - : "." + navigationToPrincipal), - foreignKey.PrincipalEntityType.DisplayName() + (foreignKey.PrincipalToDependent == null - ? "" - : "." + foreignKey.PrincipalToDependent.Name), - foreignKey.DeclaringEntityType.DisplayName() + (foreignKey.DependentToPrincipal == null - ? "" - : "." + foreignKey.DependentToPrincipal.Name))); + principalEntityType.DisplayName() + + (navigationToDependent == null + ? "" + : "." + navigationToDependent), + dependentEntityType.DisplayName() + + (navigationToPrincipal == null + ? "" + : "." + navigationToPrincipal), + foreignKey.PrincipalEntityType.DisplayName() + + (foreignKey.PrincipalToDependent == null + ? "" + : "." + foreignKey.PrincipalToDependent.Name), + foreignKey.DeclaringEntityType.DisplayName() + + (foreignKey.DependentToPrincipal == null + ? "" + : "." + foreignKey.DependentToPrincipal.Name))); private static IReadOnlyList FindRelationships( [NotNull] EntityType principalEntityType, @@ -3786,14 +3812,14 @@ private bool CanSetRelatedTypes( throw new InvalidOperationException( CoreStrings.PrincipalKeylessType( principalEntityType.DisplayName(), - Metadata.PrincipalEntityType.DisplayName() - + (Metadata.PrincipalToDependent == null - ? "" - : "." + Metadata.PrincipalToDependent.Name), - Metadata.DeclaringEntityType.DisplayName() - + (Metadata.DependentToPrincipal == null - ? "" - : "." + Metadata.DependentToPrincipal.Name))); + Metadata.PrincipalEntityType.DisplayName() + + (Metadata.PrincipalToDependent == null + ? "" + : "." + Metadata.PrincipalToDependent.Name), + Metadata.DeclaringEntityType.DisplayName() + + (Metadata.DependentToPrincipal == null + ? "" + : "." + Metadata.DependentToPrincipal.Name))); } if (canInvert) @@ -4013,7 +4039,9 @@ IConventionForeignKey IConventionForeignKeyBuilder.Metadata /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasEntityTypes( - IConventionEntityType principalEntityType, IConventionEntityType dependentEntityType, bool fromDataAnnotation) + IConventionEntityType principalEntityType, + IConventionEntityType dependentEntityType, + bool fromDataAnnotation) => HasEntityTypes( (EntityType)principalEntityType, (EntityType)dependentEntityType, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4021,7 +4049,9 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasEntityTypes( /// [DebuggerStepThrough] bool IConventionForeignKeyBuilder.CanSetEntityTypes( - IConventionEntityType principalEntityType, IConventionEntityType dependentEntityType, bool fromDataAnnotation) + IConventionEntityType principalEntityType, + IConventionEntityType dependentEntityType, + bool fromDataAnnotation) => CanSetEntityTypes( (EntityType)principalEntityType, (EntityType)dependentEntityType, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4036,7 +4066,8 @@ bool IConventionForeignKeyBuilder.CanInvert(IReadOnlyList n /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasForeignKey( - [CanBeNull] IReadOnlyList properties, bool fromDataAnnotation) + [CanBeNull] IReadOnlyList properties, + bool fromDataAnnotation) => HasForeignKey( properties, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4044,7 +4075,8 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasForeignKey( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasForeignKey( - IReadOnlyList properties, bool fromDataAnnotation) + IReadOnlyList properties, + bool fromDataAnnotation) => HasForeignKey( properties as IReadOnlyList ?? properties?.Cast().ToList(), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4052,7 +4084,8 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasForeignKey( /// [DebuggerStepThrough] bool IConventionForeignKeyBuilder.CanSetForeignKey( - [CanBeNull] IReadOnlyList properties, bool fromDataAnnotation) + [CanBeNull] IReadOnlyList properties, + bool fromDataAnnotation) => CanSetForeignKey( properties, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4067,7 +4100,8 @@ bool IConventionForeignKeyBuilder.CanSetForeignKey(IReadOnlyList [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasPrincipalKey( - [CanBeNull] IReadOnlyList properties, bool fromDataAnnotation) + [CanBeNull] IReadOnlyList properties, + bool fromDataAnnotation) => HasPrincipalKey( properties, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4075,7 +4109,8 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasPrincipalKey( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasPrincipalKey( - IReadOnlyList properties, bool fromDataAnnotation) + IReadOnlyList properties, + bool fromDataAnnotation) => HasPrincipalKey( properties as IReadOnlyList ?? properties?.Cast().ToList(), fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4083,7 +4118,8 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasPrincipalKey( /// [DebuggerStepThrough] bool IConventionForeignKeyBuilder.CanSetPrincipalKey( - [CanBeNull] IReadOnlyList properties, bool fromDataAnnotation) + [CanBeNull] IReadOnlyList properties, + bool fromDataAnnotation) => CanSetPrincipalKey( properties, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4098,7 +4134,9 @@ bool IConventionForeignKeyBuilder.CanSetPrincipalKey(IReadOnlyList [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigation( - string name, bool pointsToPrincipal, bool fromDataAnnotation) + string name, + bool pointsToPrincipal, + bool fromDataAnnotation) => HasNavigation( name, pointsToPrincipal, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4106,7 +4144,9 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigation( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigation( - MemberInfo property, bool pointsToPrincipal, bool fromDataAnnotation) + MemberInfo property, + bool pointsToPrincipal, + bool fromDataAnnotation) => HasNavigation( property, pointsToPrincipal, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4114,7 +4154,9 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigation( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigations( - string navigationToPrincipalName, string navigationToDependentName, bool fromDataAnnotation) + string navigationToPrincipalName, + string navigationToDependentName, + bool fromDataAnnotation) => HasNavigations( navigationToPrincipalName, navigationToDependentName, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4122,7 +4164,9 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigations( /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigations( - MemberInfo navigationToPrincipal, MemberInfo navigationToDependent, bool fromDataAnnotation) + MemberInfo navigationToPrincipal, + MemberInfo navigationToDependent, + bool fromDataAnnotation) => HasNavigations( navigationToPrincipal, navigationToDependent, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4130,7 +4174,9 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.HasNavigations( /// [DebuggerStepThrough] bool IConventionForeignKeyBuilder.CanSetNavigation( - MemberInfo property, bool pointsToPrincipal, bool fromDataAnnotation) + MemberInfo property, + bool pointsToPrincipal, + bool fromDataAnnotation) => CanSetNavigation( property, pointsToPrincipal, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4145,7 +4191,9 @@ bool IConventionForeignKeyBuilder.CanSetNavigation(string name, bool pointsToPri /// [DebuggerStepThrough] bool IConventionForeignKeyBuilder.CanSetNavigations( - MemberInfo navigationToPrincipal, MemberInfo navigationToDependent, bool fromDataAnnotation) + MemberInfo navigationToPrincipal, + MemberInfo navigationToDependent, + bool fromDataAnnotation) => CanSetNavigations( navigationToPrincipal, navigationToDependent, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4153,7 +4201,9 @@ bool IConventionForeignKeyBuilder.CanSetNavigations( /// [DebuggerStepThrough] bool IConventionForeignKeyBuilder.CanSetNavigations( - string navigationToPrincipalName, string navigationToDependentName, bool fromDataAnnotation) + string navigationToPrincipalName, + string navigationToDependentName, + bool fromDataAnnotation) => CanSetNavigations( navigationToPrincipalName, navigationToDependentName, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -4176,7 +4226,8 @@ IConventionForeignKeyBuilder IConventionForeignKeyBuilder.IsRequiredDependent(bo /// [DebuggerStepThrough] bool IConventionForeignKeyBuilder.CanSetIsRequiredDependent(bool? required, bool fromDataAnnotation) - => CanSetIsRequiredDependent(required, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); + => CanSetIsRequiredDependent( + required, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -4206,7 +4257,8 @@ bool IConventionForeignKeyBuilder.CanSetIsOwnership(bool? ownership, bool fromDa /// [DebuggerStepThrough] IConventionForeignKeyBuilder IConventionForeignKeyBuilder.OnDelete( - DeleteBehavior? deleteBehavior, bool fromDataAnnotation) + DeleteBehavior? deleteBehavior, + bool fromDataAnnotation) => OnDelete(deleteBehavior, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// diff --git a/src/EFCore/Metadata/Internal/InternalIndexBuilder.cs b/src/EFCore/Metadata/Internal/InternalIndexBuilder.cs index 4bad9030ca0..57e1d121dad 100644 --- a/src/EFCore/Metadata/Internal/InternalIndexBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalIndexBuilder.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -88,7 +87,8 @@ public virtual InternalIndexBuilder Attach([NotNull] InternalEntityTypeBuilder e /// 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. /// - IConventionIndex IConventionIndexBuilder.Metadata => Metadata; + IConventionIndex IConventionIndexBuilder.Metadata + => Metadata; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/InternalKeyBuilder.cs b/src/EFCore/Metadata/Internal/InternalKeyBuilder.cs index 92853c0347a..42081847eae 100644 --- a/src/EFCore/Metadata/Internal/InternalKeyBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalKeyBuilder.cs @@ -63,6 +63,7 @@ public virtual InternalKeyBuilder Attach( return newKeyBuilder; } - IConventionKey IConventionKeyBuilder.Metadata => Metadata; + IConventionKey IConventionKeyBuilder.Metadata + => Metadata; } } diff --git a/src/EFCore/Metadata/Internal/InternalModelBuilder.cs b/src/EFCore/Metadata/Internal/InternalModelBuilder.cs index 53f49c51bdf..2113622e741 100644 --- a/src/EFCore/Metadata/Internal/InternalModelBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalModelBuilder.cs @@ -38,7 +38,8 @@ public InternalModelBuilder([NotNull] Model metadata) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override InternalModelBuilder ModelBuilder => this; + public override InternalModelBuilder ModelBuilder + => this; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -47,7 +48,9 @@ public InternalModelBuilder([NotNull] Model metadata) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder Entity( - [NotNull] string name, ConfigurationSource configurationSource, bool? shouldBeOwned = false) + [NotNull] string name, + ConfigurationSource configurationSource, + bool? shouldBeOwned = false) => Entity(new TypeIdentity(name), configurationSource, shouldBeOwned); /// @@ -57,7 +60,10 @@ public virtual InternalEntityTypeBuilder Entity( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder SharedTypeEntity( - [NotNull] string name, [NotNull] Type type, ConfigurationSource configurationSource, bool? shouldBeOwned = false) + [NotNull] string name, + [NotNull] Type type, + ConfigurationSource configurationSource, + bool? shouldBeOwned = false) => Entity(new TypeIdentity(name, Check.NotNull(type, nameof(type))), configurationSource, shouldBeOwned); /// @@ -67,11 +73,15 @@ public virtual InternalEntityTypeBuilder SharedTypeEntity( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalEntityTypeBuilder Entity( - [NotNull] Type type, ConfigurationSource configurationSource, bool? shouldBeOwned = false) + [NotNull] Type type, + ConfigurationSource configurationSource, + bool? shouldBeOwned = false) => Entity(new TypeIdentity(type, Metadata), configurationSource, shouldBeOwned); private InternalEntityTypeBuilder Entity( - in TypeIdentity type, ConfigurationSource configurationSource, bool? shouldBeOwned) + in TypeIdentity type, + ConfigurationSource configurationSource, + bool? shouldBeOwned) { if (IsIgnored(type, configurationSource)) { @@ -304,7 +314,8 @@ public virtual InternalModelBuilder RemoveImplicitJoinEntity([NotNull] EntityTyp /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IConventionOwnedEntityTypeBuilder Owned( - [NotNull] Type type, ConfigurationSource configurationSource) + [NotNull] Type type, + ConfigurationSource configurationSource) { if (IsIgnored(type, configurationSource)) { @@ -520,7 +531,8 @@ public virtual InternalModelBuilder HasNoEntityType([NotNull] EntityType entityT Check.DebugAssert(removed != null, "removed is null"); } - foreach (var skipNavigation in entityType.GetDeclaredForeignKeys().SelectMany(fk => fk.GetReferencingSkipNavigations()).ToList()) + foreach (var skipNavigation in entityType.GetDeclaredForeignKeys().SelectMany(fk => fk.GetReferencingSkipNavigations()) + .ToList()) { var removed = skipNavigation.Builder.HasForeignKey(null, configurationSource); Check.DebugAssert(removed != null, "removed is null"); @@ -551,7 +563,8 @@ public virtual InternalModelBuilder HasNoEntityType([NotNull] EntityType entityT /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalModelBuilder UseChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, ConfigurationSource configurationSource) + ChangeTrackingStrategy? changeTrackingStrategy, + ConfigurationSource configurationSource) { if (CanSetChangeTrackingStrategy(changeTrackingStrategy, configurationSource)) { @@ -570,7 +583,8 @@ public virtual InternalModelBuilder UseChangeTrackingStrategy( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, ConfigurationSource configurationSource) + ChangeTrackingStrategy? changeTrackingStrategy, + ConfigurationSource configurationSource) => configurationSource.Overrides(Metadata.GetChangeTrackingStrategyConfigurationSource()) || Metadata.GetChangeTrackingStrategy() == changeTrackingStrategy; @@ -581,7 +595,8 @@ public virtual bool CanSetChangeTrackingStrategy( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalModelBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) { if (CanSetPropertyAccessMode(propertyAccessMode, configurationSource)) { @@ -600,7 +615,8 @@ public virtual InternalModelBuilder UsePropertyAccessMode( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetPropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) => configurationSource.Overrides(Metadata.GetPropertyAccessModeConfigurationSource()) || Metadata.GetPropertyAccessMode() == propertyAccessMode; @@ -633,8 +649,13 @@ IConventionEntityTypeBuilder IConventionModelBuilder.Entity(string name, bool? s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - IConventionEntityTypeBuilder IConventionModelBuilder.SharedTypeEntity(string name, Type type, bool? shouldBeOwned, bool fromDataAnnotation) - => SharedTypeEntity(name, type, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention, shouldBeOwned); + IConventionEntityTypeBuilder IConventionModelBuilder.SharedTypeEntity( + string name, + Type type, + bool? shouldBeOwned, + bool fromDataAnnotation) + => SharedTypeEntity( + name, type, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention, shouldBeOwned); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -654,7 +675,10 @@ IConventionEntityTypeBuilder IConventionModelBuilder.Entity(Type type, bool? sho /// [DebuggerStepThrough] IConventionEntityTypeBuilder IConventionModelBuilder.Entity( - string name, string definingNavigationName, IConventionEntityType definingEntityType, bool fromDataAnnotation) + string name, + string definingNavigationName, + IConventionEntityType definingEntityType, + bool fromDataAnnotation) => Entity( name, definingNavigationName, @@ -669,7 +693,10 @@ IConventionEntityTypeBuilder IConventionModelBuilder.Entity( /// [DebuggerStepThrough] IConventionEntityTypeBuilder IConventionModelBuilder.Entity( - Type type, string definingNavigationName, IConventionEntityType definingEntityType, bool fromDataAnnotation) + Type type, + string definingNavigationName, + IConventionEntityType definingEntityType, + bool fromDataAnnotation) => Entity( type, definingNavigationName, @@ -765,7 +792,8 @@ bool IConventionModelBuilder.CanIgnore(string name, bool fromDataAnnotation) /// [DebuggerStepThrough] IConventionModelBuilder IConventionModelBuilder.HasChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, bool fromDataAnnotation) + ChangeTrackingStrategy? changeTrackingStrategy, + bool fromDataAnnotation) => UseChangeTrackingStrategy( changeTrackingStrategy, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -788,7 +816,8 @@ bool IConventionModelBuilder.CanSetChangeTrackingStrategy(ChangeTrackingStrategy /// [DebuggerStepThrough] IConventionModelBuilder IConventionModelBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); diff --git a/src/EFCore/Metadata/Internal/InternalNavigationBuilder.cs b/src/EFCore/Metadata/Internal/InternalNavigationBuilder.cs index f0c800d638d..23871fc283a 100644 --- a/src/EFCore/Metadata/Internal/InternalNavigationBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalNavigationBuilder.cs @@ -54,7 +54,8 @@ public InternalNavigationBuilder([NotNull] Navigation metadata, [NotNull] Intern /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public new virtual InternalNavigationBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) => (InternalNavigationBuilder)base.UsePropertyAccessMode(propertyAccessMode, configurationSource); /// @@ -138,22 +139,17 @@ public virtual InternalNavigationBuilder IsRequired(bool? required, Configuratio : foreignKey.Builder.IsRequiredDependent(required, configurationSource) .Metadata.PrincipalToDependent.Builder; } - else + + if (Metadata.IsOnDependent) { - if (Metadata.IsOnDependent) - { - return foreignKey.Builder.IsRequired(required, configurationSource) - .Metadata.DependentToPrincipal.Builder; - } - else - { - throw new InvalidOperationException( - CoreStrings.NonUniqueRequiredDependentNavigation( - foreignKey.PrincipalEntityType.DisplayName(), Metadata.Name)); - } + return foreignKey.Builder.IsRequired(required, configurationSource) + .Metadata.DependentToPrincipal.Builder; } - } + throw new InvalidOperationException( + CoreStrings.NonUniqueRequiredDependentNavigation( + foreignKey.PrincipalEntityType.DisplayName(), Metadata.Name)); + } return null; } @@ -179,14 +175,16 @@ bool IConventionPropertyBaseBuilder.CanSetPropertyAccessMode(PropertyAccessMode? /// [DebuggerStepThrough] IConventionPropertyBaseBuilder IConventionPropertyBaseBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// [DebuggerStepThrough] IConventionNavigationBuilder IConventionNavigationBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); diff --git a/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs b/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs index e2e2c03fe3b..8144eef0f24 100644 --- a/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs +++ b/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs @@ -33,7 +33,9 @@ public InternalPropertyBaseBuilder([NotNull] TPropertyBase metadata, [NotNull] I /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual InternalPropertyBaseBuilder HasField([CanBeNull] string fieldName, ConfigurationSource configurationSource) + public virtual InternalPropertyBaseBuilder HasField( + [CanBeNull] string fieldName, + ConfigurationSource configurationSource) { if (CanSetField(fieldName, configurationSource)) { @@ -79,7 +81,9 @@ public virtual bool CanSetField([CanBeNull] string fieldName, ConfigurationSourc /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual InternalPropertyBaseBuilder HasField([CanBeNull] FieldInfo fieldInfo, ConfigurationSource configurationSource) + public virtual InternalPropertyBaseBuilder HasField( + [CanBeNull] FieldInfo fieldInfo, + ConfigurationSource configurationSource) { if (CanSetField(fieldInfo, configurationSource)) { @@ -112,7 +116,8 @@ public virtual bool CanSetField([CanBeNull] FieldInfo fieldInfo, ConfigurationSo /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalPropertyBaseBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) { if (CanSetPropertyAccessMode(propertyAccessMode, configurationSource)) { @@ -131,7 +136,8 @@ public virtual InternalPropertyBaseBuilder UsePropertyAccessMode( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetPropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource? configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource? configurationSource) => configurationSource.Overrides(Metadata.GetPropertyAccessModeConfigurationSource()) || ((IPropertyBase)Metadata).GetPropertyAccessMode() == propertyAccessMode; } diff --git a/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs b/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs index 0ac3ab4efcb..ab445f0f990 100644 --- a/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalPropertyBuilder.cs @@ -172,7 +172,8 @@ public virtual bool CanSetIsConcurrencyToken(bool? concurrencyToken, Configurati /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public new virtual InternalPropertyBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) => (InternalPropertyBuilder)base.UsePropertyAccessMode(propertyAccessMode, configurationSource); /// @@ -229,7 +230,7 @@ public virtual InternalPropertyBuilder HasPrecision(int? precision, Configuratio /// public virtual bool CanSetPrecision(int? precision, ConfigurationSource? configurationSource) => configurationSource.Overrides(Metadata.GetPrecisionConfigurationSource()) - || Metadata.GetPrecision() == precision; + || Metadata.GetPrecision() == precision; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -257,7 +258,7 @@ public virtual InternalPropertyBuilder HasScale(int? scale, ConfigurationSource /// public virtual bool CanSetScale(int? scale, ConfigurationSource? configurationSource) => configurationSource.Overrides(Metadata.GetScaleConfigurationSource()) - || Metadata.GetScale() == scale; + || Metadata.GetScale() == scale; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -352,7 +353,8 @@ public virtual bool CanSetAfterSave(PropertySaveBehavior? behavior, Configuratio /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalPropertyBuilder HasValueGenerator( - [CanBeNull] Type valueGeneratorType, ConfigurationSource configurationSource) + [CanBeNull] Type valueGeneratorType, + ConfigurationSource configurationSource) { if (valueGeneratorType == null) { @@ -408,7 +410,8 @@ public virtual InternalPropertyBuilder HasValueGenerator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetValueGenerator( - [CanBeNull] Func factory, ConfigurationSource? configurationSource) + [CanBeNull] Func factory, + ConfigurationSource? configurationSource) => configurationSource.Overrides(Metadata.GetValueGeneratorFactoryConfigurationSource()) || Metadata.GetValueGeneratorFactory() == factory; @@ -437,7 +440,8 @@ public virtual InternalPropertyBuilder HasConversion([CanBeNull] ValueConverter /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetConversion( - [CanBeNull] ValueConverter converter, ConfigurationSource? configurationSource) + [CanBeNull] ValueConverter converter, + ConfigurationSource? configurationSource) => configurationSource == ConfigurationSource.Explicit || (configurationSource.Overrides(Metadata.GetValueConverterConfigurationSource()) && Metadata.CheckValueConverter(converter) == null) @@ -478,7 +482,8 @@ public virtual bool CanSetConversion([CanBeNull] Type providerClrType, Configura /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalPropertyBuilder HasTypeMapping( - [CanBeNull] CoreTypeMapping typeMapping, ConfigurationSource configurationSource) + [CanBeNull] CoreTypeMapping typeMapping, + ConfigurationSource configurationSource) { if (CanSetTypeMapping(typeMapping, configurationSource)) { @@ -507,7 +512,8 @@ public virtual bool CanSetTypeMapping([CanBeNull] CoreTypeMapping typeMapping, C /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalPropertyBuilder HasValueComparer( - [CanBeNull] ValueComparer comparer, ConfigurationSource configurationSource) + [CanBeNull] ValueComparer comparer, + ConfigurationSource configurationSource) { if (CanSetValueComparer(comparer, configurationSource)) { @@ -537,7 +543,8 @@ public virtual bool CanSetValueComparer([CanBeNull] ValueComparer comparer, Conf /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalPropertyBuilder HasKeyValueComparer( - [CanBeNull] ValueComparer comparer, ConfigurationSource configurationSource) + [CanBeNull] ValueComparer comparer, + ConfigurationSource configurationSource) => HasValueComparer(comparer, configurationSource); /// @@ -788,7 +795,8 @@ bool IConventionPropertyBaseBuilder.CanSetField(FieldInfo fieldInfo, bool fromDa /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionPropertyBaseBuilder IConventionPropertyBaseBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -799,7 +807,8 @@ IConventionPropertyBaseBuilder IConventionPropertyBaseBuilder.UsePropertyAccessM /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionPropertyBuilder IConventionPropertyBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -902,7 +911,8 @@ IConventionPropertyBuilder IConventionPropertyBuilder.HasValueGenerator(Type val /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionPropertyBuilder IConventionPropertyBuilder.HasValueGenerator( - Func factory, bool fromDataAnnotation) + Func factory, + bool fromDataAnnotation) => HasValueGenerator(factory, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// diff --git a/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs b/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs index 461ad8a6f88..ca43b01dda2 100644 --- a/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs @@ -3,7 +3,6 @@ using System.Reflection; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Microsoft.EntityFrameworkCore.Metadata.Internal @@ -52,7 +51,8 @@ public InternalServicePropertyBuilder([NotNull] ServiceProperty property, [NotNu /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public new virtual InternalServicePropertyBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) => (InternalServicePropertyBuilder)base.UsePropertyAccessMode(propertyAccessMode, configurationSource); /// @@ -62,7 +62,8 @@ public InternalServicePropertyBuilder([NotNull] ServiceProperty property, [NotNu /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalServicePropertyBuilder HasParameterBinding( - [CanBeNull] ServiceParameterBinding parameterBinding, ConfigurationSource configurationSource) + [CanBeNull] ServiceParameterBinding parameterBinding, + ConfigurationSource configurationSource) { if (CanSetParameterBinding(parameterBinding, configurationSource)) { @@ -80,7 +81,8 @@ public virtual InternalServicePropertyBuilder HasParameterBinding( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetParameterBinding( - [CanBeNull] ServiceParameterBinding parameterBinding, ConfigurationSource? configurationSource) + [CanBeNull] ServiceParameterBinding parameterBinding, + ConfigurationSource? configurationSource) => configurationSource.Overrides(Metadata.GetParameterBindingConfigurationSource()) || (Metadata.ParameterBinding == parameterBinding); @@ -92,7 +94,8 @@ public virtual bool CanSetParameterBinding( /// public virtual InternalServicePropertyBuilder Attach([NotNull] InternalEntityTypeBuilder entityTypeBuilder = null) { - var newPropertyBuilder = entityTypeBuilder.ServiceProperty(Metadata.GetIdentifyingMemberInfo(), Metadata.GetConfigurationSource()); + var newPropertyBuilder = entityTypeBuilder.ServiceProperty( + Metadata.GetIdentifyingMemberInfo(), Metadata.GetConfigurationSource()); if (newPropertyBuilder == null) { return null; @@ -122,7 +125,8 @@ public virtual InternalServicePropertyBuilder Attach([NotNull] InternalEntityTyp /// 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. /// - IConventionPropertyBase IConventionPropertyBaseBuilder.Metadata => Metadata; + IConventionPropertyBase IConventionPropertyBaseBuilder.Metadata + => Metadata; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -130,7 +134,8 @@ public virtual InternalServicePropertyBuilder Attach([NotNull] InternalEntityTyp /// 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. /// - IConventionServiceProperty IConventionServicePropertyBuilder.Metadata => Metadata; + IConventionServiceProperty IConventionServicePropertyBuilder.Metadata + => Metadata; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -193,7 +198,8 @@ bool IConventionPropertyBaseBuilder.CanSetField(FieldInfo fieldInfo, bool fromDa /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionPropertyBaseBuilder IConventionPropertyBaseBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -204,7 +210,8 @@ IConventionPropertyBaseBuilder IConventionPropertyBaseBuilder.UsePropertyAccessM /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionServicePropertyBuilder IConventionServicePropertyBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -225,7 +232,8 @@ bool IConventionPropertyBaseBuilder.CanSetPropertyAccessMode(PropertyAccessMode? /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionServicePropertyBuilder IConventionServicePropertyBuilder.HasParameterBinding( - ServiceParameterBinding parameterBinding, bool fromDataAnnotation) + ServiceParameterBinding parameterBinding, + bool fromDataAnnotation) => HasParameterBinding( parameterBinding, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); diff --git a/src/EFCore/Metadata/Internal/InternalSkipNavigationBuilder.cs b/src/EFCore/Metadata/Internal/InternalSkipNavigationBuilder.cs index 8f0bc103a60..5fc9c5a2b61 100644 --- a/src/EFCore/Metadata/Internal/InternalSkipNavigationBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalSkipNavigationBuilder.cs @@ -53,7 +53,8 @@ public InternalSkipNavigationBuilder([NotNull] SkipNavigation metadata, [NotNull /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public new virtual InternalSkipNavigationBuilder UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) => (InternalSkipNavigationBuilder)base.UsePropertyAccessMode(propertyAccessMode, configurationSource); /// @@ -62,7 +63,9 @@ public InternalSkipNavigationBuilder([NotNull] SkipNavigation metadata, [NotNull /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual InternalSkipNavigationBuilder HasForeignKey([CanBeNull] ForeignKey foreignKey, ConfigurationSource configurationSource) + public virtual InternalSkipNavigationBuilder HasForeignKey( + [CanBeNull] ForeignKey foreignKey, + ConfigurationSource configurationSource) { if (!CanSetForeignKey(foreignKey, configurationSource)) { @@ -75,7 +78,7 @@ public virtual InternalSkipNavigationBuilder HasForeignKey([CanBeNull] ForeignKe if (Metadata.Inverse?.JoinEntityType != null && Metadata.Inverse.JoinEntityType - != (Metadata.IsOnDependent ? foreignKey.PrincipalEntityType : foreignKey.DeclaringEntityType)) + != (Metadata.IsOnDependent ? foreignKey.PrincipalEntityType : foreignKey.DeclaringEntityType)) { Metadata.Inverse.Builder.HasForeignKey(null, configurationSource); } @@ -114,7 +117,7 @@ public virtual bool CanSetForeignKey([CanBeNull] ForeignKey foreignKey, Configur } if (Metadata.DeclaringEntityType - != (Metadata.IsOnDependent ? foreignKey.DeclaringEntityType : foreignKey.PrincipalEntityType)) + != (Metadata.IsOnDependent ? foreignKey.DeclaringEntityType : foreignKey.PrincipalEntityType)) { return false; } @@ -125,8 +128,8 @@ public virtual bool CanSetForeignKey([CanBeNull] ForeignKey foreignKey, Configur } return Metadata.Inverse.JoinEntityType - == (Metadata.IsOnDependent ? foreignKey.PrincipalEntityType : foreignKey.DeclaringEntityType) - || Metadata.Inverse.Builder.CanSetForeignKey(null, configurationSource); + == (Metadata.IsOnDependent ? foreignKey.PrincipalEntityType : foreignKey.DeclaringEntityType) + || Metadata.Inverse.Builder.CanSetForeignKey(null, configurationSource); } /// @@ -136,7 +139,8 @@ public virtual bool CanSetForeignKey([CanBeNull] ForeignKey foreignKey, Configur /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InternalSkipNavigationBuilder HasInverse( - [CanBeNull] SkipNavigation inverse, ConfigurationSource configurationSource) + [CanBeNull] SkipNavigation inverse, + ConfigurationSource configurationSource) { if (!CanSetInverse(inverse, configurationSource)) { @@ -174,7 +178,8 @@ public virtual InternalSkipNavigationBuilder HasInverse( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual bool CanSetInverse( - [CanBeNull] SkipNavigation inverse, ConfigurationSource? configurationSource) + [CanBeNull] SkipNavigation inverse, + ConfigurationSource? configurationSource) { if (!configurationSource.Overrides(Metadata.GetInverseConfigurationSource()) || (inverse != null @@ -189,10 +194,10 @@ public virtual bool CanSetInverse( } return Metadata.TargetEntityType == inverse.DeclaringEntityType - && Metadata.DeclaringEntityType == inverse.TargetEntityType - && (Metadata.JoinEntityType == null - || inverse.JoinEntityType == null - || Metadata.JoinEntityType == inverse.JoinEntityType); + && Metadata.DeclaringEntityType == inverse.TargetEntityType + && (Metadata.JoinEntityType == null + || inverse.JoinEntityType == null + || Metadata.JoinEntityType == inverse.JoinEntityType); } /// @@ -386,7 +391,8 @@ bool IConventionPropertyBaseBuilder.CanSetField(FieldInfo fieldInfo, bool fromDa /// [DebuggerStepThrough] IConventionPropertyBaseBuilder IConventionPropertyBaseBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -394,7 +400,8 @@ IConventionPropertyBaseBuilder IConventionPropertyBaseBuilder.UsePropertyAccessM /// [DebuggerStepThrough] IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.UsePropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => UsePropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -402,7 +409,8 @@ IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.UsePropertyAcc /// [DebuggerStepThrough] bool IConventionPropertyBaseBuilder.CanSetPropertyAccessMode( - PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation) + PropertyAccessMode? propertyAccessMode, + bool fromDataAnnotation) => CanSetPropertyAccessMode( propertyAccessMode, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -410,7 +418,8 @@ bool IConventionPropertyBaseBuilder.CanSetPropertyAccessMode( /// [DebuggerStepThrough] IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.HasForeignKey( - IConventionForeignKey foreignKey, bool fromDataAnnotation) + IConventionForeignKey foreignKey, + bool fromDataAnnotation) => HasForeignKey( (ForeignKey)foreignKey, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -418,7 +427,8 @@ IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.HasForeignKey( /// [DebuggerStepThrough] bool IConventionSkipNavigationBuilder.CanSetForeignKey( - IConventionForeignKey foreignKey, bool fromDataAnnotation) + IConventionForeignKey foreignKey, + bool fromDataAnnotation) => CanSetForeignKey( (ForeignKey)foreignKey, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -426,7 +436,8 @@ bool IConventionSkipNavigationBuilder.CanSetForeignKey( /// [DebuggerStepThrough] IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.HasInverse( - IConventionSkipNavigation inverse, bool fromDataAnnotation) + IConventionSkipNavigation inverse, + bool fromDataAnnotation) => HasInverse( (SkipNavigation)inverse, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -434,7 +445,8 @@ IConventionSkipNavigationBuilder IConventionSkipNavigationBuilder.HasInverse( /// [DebuggerStepThrough] bool IConventionSkipNavigationBuilder.CanSetInverse( - IConventionSkipNavigation inverse, bool fromDataAnnotation) + IConventionSkipNavigation inverse, + bool fromDataAnnotation) => CanSetInverse( (SkipNavigation)inverse, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); diff --git a/src/EFCore/Metadata/Internal/Key.cs b/src/EFCore/Metadata/Internal/Key.cs index 456f6b4e13c..4e4dd69cbf3 100644 --- a/src/EFCore/Metadata/Internal/Key.cs +++ b/src/EFCore/Metadata/Internal/Key.cs @@ -87,7 +87,8 @@ public virtual InternalKeyBuilder Builder /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource GetConfigurationSource() => _configurationSource; + public virtual ConfigurationSource GetConfigurationSource() + => _configurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -112,7 +113,9 @@ public virtual void UpdateConfigurationSource(ConfigurationSource configurationS /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => Builder.ModelBuilder.Metadata.ConventionDispatcher.OnKeyAnnotationChanged(Builder, name, annotation, oldAnnotation); /// @@ -158,7 +161,8 @@ public virtual IPrincipalKeyValueFactory GetPrincipalKeyValueFactory /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/Model.cs b/src/EFCore/Metadata/Internal/Model.cs index 31232c3b1f5..c19e5eb98e4 100644 --- a/src/EFCore/Metadata/Internal/Model.cs +++ b/src/EFCore/Metadata/Internal/Model.cs @@ -68,7 +68,7 @@ private readonly Dictionary _ignoredTypeNames /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public Model() - : this(new ConventionSet(), null) + : this(new ConventionSet()) { } @@ -242,7 +242,8 @@ private EntityType AddEntityType(EntityType entityType) { if (_entityTypes.Any(et => !et.Value.HasSharedClrType && et.Value.ClrType == entityType.ClrType)) { - throw new InvalidOperationException(CoreStrings.ClashingNonSharedType(entityType.Name, entityType.ClrType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.ClashingNonSharedType(entityType.Name, entityType.ClrType.DisplayName())); } if (_sharedTypes.TryGetValue(entityType.ClrType, out var existingConfigurationSource)) @@ -272,7 +273,8 @@ private EntityType AddEntityType(EntityType entityType) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual EntityType FindEntityType([NotNull] Type type) => FindEntityType(GetDisplayName(type)); + public virtual EntityType FindEntityType([NotNull] Type type) + => FindEntityType(GetDisplayName(type)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -610,7 +612,8 @@ public virtual IReadOnlyCollection GetEntityTypes([NotNull] string n /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IReadOnlyList FindLeastDerivedEntityTypes( - [NotNull] Type type, [CanBeNull] Func condition = null) + [NotNull] Type type, + [CanBeNull] Func condition = null) { var derivedLevels = new Dictionary { [type] = 0 }; @@ -720,8 +723,8 @@ private string AddIgnored( // This is to populate Type for convention when removing shared type entity type type = _entityTypes.TryGetValue(name, out var existingEntityType) && existingEntityType.HasSharedClrType - ? existingEntityType.ClrType - : null; + ? existingEntityType.ClrType + : null; } return ConventionDispatcher.OnEntityTypeIgnored(Builder, name, type); @@ -909,7 +912,8 @@ public virtual void AddShared([NotNull] Type type, ConfigurationSource configura /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual PropertyAccessMode? SetPropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) { this.SetOrRemoveAnnotation(CoreAnnotationNames.PropertyAccessMode, propertyAccessMode, configurationSource); @@ -923,7 +927,8 @@ public virtual void AddShared([NotNull] Type type, ConfigurationSource configura /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ChangeTrackingStrategy? SetChangeTrackingStrategy( - ChangeTrackingStrategy? changeTrackingStrategy, ConfigurationSource configurationSource) + ChangeTrackingStrategy? changeTrackingStrategy, + ConfigurationSource configurationSource) { this.SetOrRemoveAnnotation(CoreAnnotationNames.ChangeTrackingStrategy, changeTrackingStrategy, configurationSource); @@ -938,7 +943,9 @@ public virtual void AddShared([NotNull] Type type, ConfigurationSource configura /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => ConventionDispatcher.OnModelAnnotationChanged(Builder, name, annotation, oldAnnotation); /// @@ -999,7 +1006,8 @@ public virtual DebugView DebugView /// 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. /// - IEntityType IModel.FindEntityType(string name) => FindEntityType(name); + IEntityType IModel.FindEntityType(string name) + => FindEntityType(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1007,7 +1015,8 @@ public virtual DebugView DebugView /// 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. /// - IEnumerable IModel.GetEntityTypes() => GetEntityTypes(); + IEnumerable IModel.GetEntityTypes() + => GetEntityTypes(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1015,7 +1024,8 @@ public virtual DebugView DebugView /// 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. /// - IMutableEntityType IMutableModel.FindEntityType(string name) => FindEntityType(name); + IMutableEntityType IMutableModel.FindEntityType(string name) + => FindEntityType(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1023,7 +1033,8 @@ public virtual DebugView DebugView /// 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. /// - IMutableEntityType IMutableModel.AddEntityType(string name) => AddEntityType(name, ConfigurationSource.Explicit); + IMutableEntityType IMutableModel.AddEntityType(string name) + => AddEntityType(name, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1031,7 +1042,8 @@ public virtual DebugView DebugView /// 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. /// - IMutableEntityType IMutableModel.AddEntityType(Type type) => AddEntityType(type, ConfigurationSource.Explicit); + IMutableEntityType IMutableModel.AddEntityType(Type type) + => AddEntityType(type, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1039,7 +1051,8 @@ public virtual DebugView DebugView /// 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. /// - IMutableEntityType IMutableModel.AddEntityType(string name, Type type) => AddEntityType(name, type, ConfigurationSource.Explicit); + IMutableEntityType IMutableModel.AddEntityType(string name, Type type) + => AddEntityType(name, type, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1047,7 +1060,8 @@ public virtual DebugView DebugView /// 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. /// - IMutableEntityType IMutableModel.RemoveEntityType(IMutableEntityType entityType) => RemoveEntityType((EntityType)entityType); + IMutableEntityType IMutableModel.RemoveEntityType(IMutableEntityType entityType) + => RemoveEntityType((EntityType)entityType); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1065,7 +1079,9 @@ IEntityType IModel.FindEntityType(string name, string definingNavigationName, IE /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IMutableEntityType IMutableModel.FindEntityType( - string name, string definingNavigationName, IMutableEntityType definingEntityType) + string name, + string definingNavigationName, + IMutableEntityType definingEntityType) => FindEntityType(name, definingNavigationName, (EntityType)definingEntityType); /// @@ -1098,7 +1114,8 @@ IMutableEntityType IMutableModel.AddEntityType( /// 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. /// - IEnumerable IMutableModel.GetEntityTypes() => GetEntityTypes(); + IEnumerable IMutableModel.GetEntityTypes() + => GetEntityTypes(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1139,7 +1156,8 @@ IConventionAnnotatableBuilder IConventionAnnotatable.Builder /// 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. /// - IConventionEntityType IConventionModel.FindEntityType(string name) => FindEntityType(name); + IConventionEntityType IConventionModel.FindEntityType(string name) + => FindEntityType(name); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1148,7 +1166,9 @@ IConventionAnnotatableBuilder IConventionAnnotatable.Builder /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionEntityType IConventionModel.FindEntityType( - string name, string definingNavigationName, IConventionEntityType definingEntityType) + string name, + string definingNavigationName, + IConventionEntityType definingEntityType) => FindEntityType(name, definingNavigationName, (EntityType)definingEntityType); /// @@ -1185,7 +1205,10 @@ IConventionEntityType IConventionModel.AddEntityType(string name, Type type, boo /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionEntityType IConventionModel.AddEntityType( - string name, string definingNavigationName, IConventionEntityType definingEntityType, bool fromDataAnnotation) + string name, + string definingNavigationName, + IConventionEntityType definingEntityType, + bool fromDataAnnotation) => AddEntityType( name, definingNavigationName, (EntityType)definingEntityType, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -1197,7 +1220,10 @@ IConventionEntityType IConventionModel.AddEntityType( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// IConventionEntityType IConventionModel.AddEntityType( - Type type, string definingNavigationName, IConventionEntityType definingEntityType, bool fromDataAnnotation) + Type type, + string definingNavigationName, + IConventionEntityType definingEntityType, + bool fromDataAnnotation) => AddEntityType( type, definingNavigationName, (EntityType)definingEntityType, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -1217,7 +1243,8 @@ IConventionEntityType IConventionModel.RemoveEntityType(IConventionEntityType en /// 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. /// - IEnumerable IConventionModel.GetEntityTypes() => GetEntityTypes(); + IEnumerable IConventionModel.GetEntityTypes() + => GetEntityTypes(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -1234,6 +1261,7 @@ string IConventionModel.AddIgnored(string name, bool fromDataAnnotation) /// 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. /// - bool IConventionModel.IsShared(Type type) => IsShared(type); + bool IConventionModel.IsShared(Type type) + => IsShared(type); } } diff --git a/src/EFCore/Metadata/Internal/Navigation.cs b/src/EFCore/Metadata/Internal/Navigation.cs index 1097fa42cc1..f141655440d 100644 --- a/src/EFCore/Metadata/Internal/Navigation.cs +++ b/src/EFCore/Metadata/Internal/Navigation.cs @@ -50,7 +50,8 @@ public Navigation( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override Type ClrType => this.GetIdentifyingMemberInfo()?.GetMemberType() ?? typeof(object); + public override Type ClrType + => this.GetIdentifyingMemberInfo()?.GetMemberType() ?? typeof(object); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -309,7 +310,9 @@ public virtual IClrCollectionAccessor CollectionAccessor /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => DeclaringType.Model.ConventionDispatcher.OnNavigationAnnotationChanged( ForeignKey.Builder, this, name, annotation, oldAnnotation); @@ -319,7 +322,8 @@ protected override IConventionAnnotation OnAnnotationSet( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/Property.cs b/src/EFCore/Metadata/Internal/Property.cs index 0c60862b497..1737966d0a7 100644 --- a/src/EFCore/Metadata/Internal/Property.cs +++ b/src/EFCore/Metadata/Internal/Property.cs @@ -105,7 +105,8 @@ public override TypeBase DeclaringType /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetTypeConfigurationSource() => _typeConfigurationSource; + public virtual ConfigurationSource? GetTypeConfigurationSource() + => _typeConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -175,7 +176,8 @@ public virtual bool IsNullable return nullable; } - private bool DefaultIsNullable => ClrType.IsNullableType(); + private bool DefaultIsNullable + => ClrType.IsNullableType(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -183,7 +185,8 @@ public virtual bool IsNullable /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetIsNullableConfigurationSource() => _isNullableConfigurationSource; + public virtual ConfigurationSource? GetIsNullableConfigurationSource() + => _isNullableConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -223,7 +226,8 @@ public virtual ValueGenerated ValueGenerated return valueGenerated; } - private static ValueGenerated DefaultValueGenerated => ValueGenerated.Never; + private static ValueGenerated DefaultValueGenerated + => ValueGenerated.Never; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -231,7 +235,8 @@ public virtual ValueGenerated ValueGenerated /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetValueGeneratedConfigurationSource() => _valueGeneratedConfigurationSource; + public virtual ConfigurationSource? GetValueGeneratedConfigurationSource() + => _valueGeneratedConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -265,7 +270,8 @@ public virtual bool IsConcurrencyToken return concurrencyToken; } - private static bool DefaultIsConcurrencyToken => false; + private static bool DefaultIsConcurrencyToken + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -273,7 +279,8 @@ public virtual bool IsConcurrencyToken /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetIsConcurrencyTokenConfigurationSource() => _isConcurrencyTokenConfigurationSource; + public virtual ConfigurationSource? GetIsConcurrencyTokenConfigurationSource() + => _isConcurrencyTokenConfigurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -350,7 +357,8 @@ public virtual bool IsConcurrencyToken /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual PropertySaveBehavior? SetBeforeSaveBehavior( - PropertySaveBehavior? beforeSaveBehavior, ConfigurationSource configurationSource) + PropertySaveBehavior? beforeSaveBehavior, + ConfigurationSource configurationSource) { this.SetOrRemoveAnnotation(CoreAnnotationNames.BeforeSaveBehavior, beforeSaveBehavior, configurationSource); @@ -364,7 +372,8 @@ public virtual bool IsConcurrencyToken /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual PropertySaveBehavior? SetAfterSaveBehavior( - PropertySaveBehavior? afterSaveBehavior, ConfigurationSource configurationSource) + PropertySaveBehavior? afterSaveBehavior, + ConfigurationSource configurationSource) { if (afterSaveBehavior != null) { @@ -389,8 +398,8 @@ public virtual bool IsConcurrencyToken public virtual string CheckAfterSaveBehavior(PropertySaveBehavior behavior) => behavior != PropertySaveBehavior.Throw && this.IsKey() - ? CoreStrings.KeyPropertyMustBeReadOnly(Name, DeclaringEntityType.DisplayName()) - : null; + ? CoreStrings.KeyPropertyMustBeReadOnly(Name, DeclaringEntityType.DisplayName()) + : null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -414,7 +423,8 @@ public virtual Func SetValueGeneratorFac /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ValueConverter SetValueConverter( - [CanBeNull] ValueConverter converter, ConfigurationSource configurationSource) + [CanBeNull] ValueConverter converter, + ConfigurationSource configurationSource) { var errorString = CheckValueConverter(converter); if (errorString != null) @@ -436,12 +446,12 @@ public virtual ValueConverter SetValueConverter( public virtual string CheckValueConverter([CanBeNull] ValueConverter converter) => converter != null && converter.ModelClrType.UnwrapNullableType() != ClrType.UnwrapNullableType() - ? CoreStrings.ConverterPropertyMismatch( - converter.ModelClrType.ShortDisplayName(), - DeclaringEntityType.DisplayName(), - Name, - ClrType.ShortDisplayName()) - : null; + ? CoreStrings.ConverterPropertyMismatch( + converter.ModelClrType.ShortDisplayName(), + DeclaringEntityType.DisplayName(), + Name, + ClrType.ShortDisplayName()) + : null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -522,12 +532,12 @@ public virtual ValueComparer SetValueComparer([CanBeNull] ValueComparer comparer public virtual string CheckValueComparer([CanBeNull] ValueComparer comparer) => comparer != null && comparer.Type != ClrType - ? CoreStrings.ComparerPropertyMismatch( - comparer.Type.ShortDisplayName(), - DeclaringEntityType.DisplayName(), - Name, - ClrType.ShortDisplayName()) - : null; + ? CoreStrings.ComparerPropertyMismatch( + comparer.Type.ShortDisplayName(), + DeclaringEntityType.DisplayName(), + Name, + ClrType.ShortDisplayName()) + : null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -596,7 +606,9 @@ public virtual IEnumerable GetContainingIndexes() /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => DeclaringType.Model.ConventionDispatcher.OnPropertyAnnotationChanged(Builder, name, annotation, oldAnnotation); /// @@ -639,7 +651,8 @@ public static bool AreCompatible([NotNull] IReadOnlyList properties, [ /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/PropertyAccessorsFactory.cs b/src/EFCore/Metadata/Internal/PropertyAccessorsFactory.cs index 67343795d98..2942b8bf94c 100644 --- a/src/EFCore/Metadata/Internal/PropertyAccessorsFactory.cs +++ b/src/EFCore/Metadata/Internal/PropertyAccessorsFactory.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using JetBrains.Annotations; @@ -50,7 +49,8 @@ private static PropertyAccessors CreateGeneric(IPropertyBase property } private static Func CreateCurrentValueGetter( - IPropertyBase propertyBase, bool useStoreGeneratedValues) + IPropertyBase propertyBase, + bool useStoreGeneratedValues) { var entityClrType = propertyBase.DeclaringType.ClrType; var updateParameter = Expression.Parameter(typeof(IUpdateEntry), "entry"); diff --git a/src/EFCore/Metadata/Internal/PropertyBase.cs b/src/EFCore/Metadata/Internal/PropertyBase.cs index 6484fbd4887..b3d83b4db52 100644 --- a/src/EFCore/Metadata/Internal/PropertyBase.cs +++ b/src/EFCore/Metadata/Internal/PropertyBase.cs @@ -98,7 +98,8 @@ public virtual FieldInfo FieldInfo /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource GetConfigurationSource() => _configurationSource; + public virtual ConfigurationSource GetConfigurationSource() + => _configurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -151,7 +152,10 @@ public virtual FieldInfo SetField([CanBeNull] string fieldName, ConfigurationSou /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static FieldInfo GetFieldInfo( - [NotNull] string fieldName, [NotNull] TypeBase type, [CanBeNull] string propertyName, bool shouldThrow) + [NotNull] string fieldName, + [NotNull] TypeBase type, + [CanBeNull] string propertyName, + bool shouldThrow) { Check.DebugAssert(propertyName != null || !shouldThrow, "propertyName is null"); @@ -193,6 +197,7 @@ public virtual FieldInfo SetFieldInfo([CanBeNull] FieldInfo fieldInfo, Configura throw new InvalidOperationException( CoreStrings.BackingFieldOnIndexer(fieldInfo.GetSimpleMemberName(), DeclaringType.DisplayName(), Name)); } + UpdateFieldInfoConfigurationSource(configurationSource); } else @@ -220,7 +225,8 @@ public virtual FieldInfo SetFieldInfo([CanBeNull] FieldInfo fieldInfo, Configura /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual PropertyAccessMode? SetPropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) { this.SetOrRemoveAnnotation(CoreAnnotationNames.PropertyAccessMode, propertyAccessMode, configurationSource); @@ -283,12 +289,13 @@ public static bool IsCompatible( /// public virtual PropertyIndexes PropertyIndexes { - get => NonCapturingLazyInitializer.EnsureInitialized( - ref _indexes, this, - property => - { - var _ = (property.DeclaringType as EntityType)?.Counts; - }); + get + => NonCapturingLazyInitializer.EnsureInitialized( + ref _indexes, this, + property => + { + var _ = (property.DeclaringType as EntityType)?.Counts; + }); [param: CanBeNull] set @@ -321,7 +328,8 @@ protected virtual FieldInfo OnFieldInfoSet([CanBeNull] FieldInfo newFieldInfo, [ /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetFieldInfoConfigurationSource() => _fieldInfoConfigurationSource; + public virtual ConfigurationSource? GetFieldInfoConfigurationSource() + => _fieldInfoConfigurationSource; private void UpdateFieldInfoConfigurationSource(ConfigurationSource configurationSource) => _fieldInfoConfigurationSource = configurationSource.Max(_fieldInfoConfigurationSource); @@ -340,8 +348,8 @@ private void UpdateFieldInfoConfigurationSource(ConfigurationSource configuratio /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IClrPropertyGetter Getter => - NonCapturingLazyInitializer.EnsureInitialized( + public virtual IClrPropertyGetter Getter + => NonCapturingLazyInitializer.EnsureInitialized( ref _getter, this, p => new ClrPropertyGetterFactory().Create(p)); /// @@ -350,8 +358,8 @@ private void UpdateFieldInfoConfigurationSource(ConfigurationSource configuratio /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IClrPropertySetter Setter => - NonCapturingLazyInitializer.EnsureInitialized( + public virtual IClrPropertySetter Setter + => NonCapturingLazyInitializer.EnsureInitialized( ref _setter, this, p => new ClrPropertySetterFactory().Create(p)); /// @@ -360,8 +368,8 @@ private void UpdateFieldInfoConfigurationSource(ConfigurationSource configuratio /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IClrPropertySetter MaterializationSetter => - NonCapturingLazyInitializer.EnsureInitialized( + public virtual IClrPropertySetter MaterializationSetter + => NonCapturingLazyInitializer.EnsureInitialized( ref _materializationSetter, this, p => new ClrPropertyMaterializationSetterFactory().Create(p)); /// @@ -379,8 +387,8 @@ public virtual PropertyAccessors Accessors /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IComparer CurrentValueComparer => - NonCapturingLazyInitializer.EnsureInitialized( + public virtual IComparer CurrentValueComparer + => NonCapturingLazyInitializer.EnsureInitialized( ref _currentValueComparer, this, p => new CurrentValueComparerFactory().Create(p)); private static readonly MethodInfo _containsKeyMethod = @@ -412,7 +420,8 @@ public static Expression CreateMemberAccess( var defaultValueConstant = property.ClrType.GetDefaultValueConstant(); expression = Expression.Condition( - Expression.Call(instanceExpression, _containsKeyMethod, new List { Expression.Constant(property.Name) }), + Expression.Call( + instanceExpression, _containsKeyMethod, new List { Expression.Constant(property.Name) }), expression, defaultValueConstant); } diff --git a/src/EFCore/Metadata/Internal/PropertyBaseExtensions.cs b/src/EFCore/Metadata/Internal/PropertyBaseExtensions.cs index c1ba48e41c7..3d6ccc0aef6 100644 --- a/src/EFCore/Metadata/Internal/PropertyBaseExtensions.cs +++ b/src/EFCore/Metadata/Internal/PropertyBaseExtensions.cs @@ -357,7 +357,8 @@ private static string GetNoFieldErrorMessage(IPropertyBase propertyBase) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static PropertyBase AsPropertyBase( - [NotNull] this IPropertyBase propertyBase, [NotNull] [CallerMemberName] string methodName = "") + [NotNull] this IPropertyBase propertyBase, + [NotNull] [CallerMemberName] string methodName = "") => MetadataExtensions.AsConcreteMetadataType(propertyBase, methodName); } } diff --git a/src/EFCore/Metadata/Internal/ServiceProperty.cs b/src/EFCore/Metadata/Internal/ServiceProperty.cs index 1c84a0c9436..477452320dd 100644 --- a/src/EFCore/Metadata/Internal/ServiceProperty.cs +++ b/src/EFCore/Metadata/Internal/ServiceProperty.cs @@ -103,7 +103,8 @@ public virtual ServiceParameterBinding ParameterBinding /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ServiceParameterBinding SetParameterBinding( - [CanBeNull] ServiceParameterBinding parameterBinding, ConfigurationSource configurationSource) + [CanBeNull] ServiceParameterBinding parameterBinding, + ConfigurationSource configurationSource) { _parameterBinding = parameterBinding; @@ -119,7 +120,8 @@ public virtual ServiceParameterBinding SetParameterBinding( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// ServiceParameterBinding IConventionServiceProperty.SetParameterBinding( - ServiceParameterBinding parameterBinding, bool fromDataAnnotation) + ServiceParameterBinding parameterBinding, + bool fromDataAnnotation) => SetParameterBinding( parameterBinding, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); @@ -129,7 +131,8 @@ ServiceParameterBinding IConventionServiceProperty.SetParameterBinding( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual ConfigurationSource? GetParameterBindingConfigurationSource() => _parameterBindingConfigurationSource; + public virtual ConfigurationSource? GetParameterBindingConfigurationSource() + => _parameterBindingConfigurationSource; private void UpdateParameterBindingConfigurationSource(ConfigurationSource configurationSource) => _parameterBindingConfigurationSource = configurationSource.Max(_parameterBindingConfigurationSource); @@ -195,7 +198,8 @@ IConventionEntityType IConventionServiceProperty.DeclaringEntityType /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs b/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs index e8b934cc569..89855cf17d6 100644 --- a/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs +++ b/src/EFCore/Metadata/Internal/ServicePropertyExtensions.cs @@ -30,7 +30,8 @@ public static ServiceParameterBinding GetParameterBinding([NotNull] this IServic /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public static ServiceProperty AsServiceProperty( - [NotNull] this IServiceProperty serviceProperty, [NotNull] [CallerMemberName] string methodName = "") + [NotNull] this IServiceProperty serviceProperty, + [NotNull] [CallerMemberName] string methodName = "") => MetadataExtensions.AsConcreteMetadataType(serviceProperty, methodName); } } diff --git a/src/EFCore/Metadata/Internal/SkipNavigation.cs b/src/EFCore/Metadata/Internal/SkipNavigation.cs index 2f968cc46d4..ad000eb5f64 100644 --- a/src/EFCore/Metadata/Internal/SkipNavigation.cs +++ b/src/EFCore/Metadata/Internal/SkipNavigation.cs @@ -76,7 +76,8 @@ private void ProcessForeignKey(ForeignKey foreignKey) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override Type ClrType => this.GetIdentifyingMemberInfo()?.GetMemberType(); + public override Type ClrType + => this.GetIdentifyingMemberInfo()?.GetMemberType(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -108,7 +109,8 @@ private void ProcessForeignKey(ForeignKey foreignKey) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override TypeBase DeclaringType => DeclaringEntityType; + public override TypeBase DeclaringType + => DeclaringEntityType; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -116,7 +118,8 @@ private void ProcessForeignKey(ForeignKey foreignKey) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual EntityType JoinEntityType => IsOnDependent ? ForeignKey?.PrincipalEntityType : ForeignKey?.DeclaringEntityType; + public virtual EntityType JoinEntityType + => IsOnDependent ? ForeignKey?.PrincipalEntityType : ForeignKey?.DeclaringEntityType; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -194,10 +197,11 @@ public virtual ForeignKey SetForeignKey([CanBeNull] ForeignKey foreignKey, Confi if (Inverse?.JoinEntityType != null && Inverse.JoinEntityType != JoinEntityType) { - throw new InvalidOperationException(CoreStrings.SkipInverseMismatchedForeignKey( - foreignKey.Properties.Format(), - Name, JoinEntityType.DisplayName(), - Inverse.Name, Inverse.JoinEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.SkipInverseMismatchedForeignKey( + foreignKey.Properties.Format(), + Name, JoinEntityType.DisplayName(), + Inverse.Name, Inverse.JoinEntityType.DisplayName())); } return isChanging @@ -247,16 +251,18 @@ public virtual SkipNavigation SetInverse([CanBeNull] SkipNavigation inverse, Con if (inverse.DeclaringEntityType != TargetEntityType) { - throw new InvalidOperationException(CoreStrings.SkipNavigationWrongInverse( - inverse.Name, inverse.DeclaringEntityType.DisplayName(), Name, TargetEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.SkipNavigationWrongInverse( + inverse.Name, inverse.DeclaringEntityType.DisplayName(), Name, TargetEntityType.DisplayName())); } if (inverse.JoinEntityType != null && JoinEntityType != null && inverse.JoinEntityType != JoinEntityType) { - throw new InvalidOperationException(CoreStrings.SkipInverseMismatchedJoinType( - inverse.Name, inverse.JoinEntityType.DisplayName(), Name, JoinEntityType.DisplayName())); + throw new InvalidOperationException( + CoreStrings.SkipInverseMismatchedJoinType( + inverse.Name, inverse.JoinEntityType.DisplayName(), Name, JoinEntityType.DisplayName())); } Inverse = inverse; @@ -303,7 +309,9 @@ public virtual void SetIsEagerLoaded(bool? eagerLoaded, ConfigurationSource conf /// The old annotation. /// The annotation that was set. protected override IConventionAnnotation OnAnnotationSet( - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation) + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation) => DeclaringType.Model.ConventionDispatcher.OnSkipNavigationAnnotationChanged( Builder, name, annotation, oldAnnotation); @@ -345,7 +353,8 @@ public virtual DebugView DebugView /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public override string ToString() => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); + public override string ToString() + => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault); /// IConventionSkipNavigationBuilder IConventionSkipNavigation.Builder @@ -390,7 +399,8 @@ void IMutableSkipNavigation.SetForeignKey([CanBeNull] IMutableForeignKey foreign /// [DebuggerStepThrough] IConventionForeignKey IConventionSkipNavigation.SetForeignKey([CanBeNull] IConventionForeignKey foreignKey, bool fromDataAnnotation) - => SetForeignKey((ForeignKey)foreignKey, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); + => SetForeignKey( + (ForeignKey)foreignKey, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// ISkipNavigation ISkipNavigation.Inverse @@ -406,7 +416,10 @@ IMutableSkipNavigation IMutableSkipNavigation.SetInverse([CanBeNull] IMutableSki /// [DebuggerStepThrough] - IConventionSkipNavigation IConventionSkipNavigation.SetInverse([CanBeNull] IConventionSkipNavigation inverse, bool fromDataAnnotation) - => SetInverse((SkipNavigation)inverse, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); + IConventionSkipNavigation IConventionSkipNavigation.SetInverse( + [CanBeNull] IConventionSkipNavigation inverse, + bool fromDataAnnotation) + => SetInverse( + (SkipNavigation)inverse, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); } } diff --git a/src/EFCore/Metadata/Internal/TypeBase.cs b/src/EFCore/Metadata/Internal/TypeBase.cs index e28cb38c996..b30aa208ce7 100644 --- a/src/EFCore/Metadata/Internal/TypeBase.cs +++ b/src/EFCore/Metadata/Internal/TypeBase.cs @@ -136,7 +136,8 @@ private TypeBase([NotNull] Model model, ConfigurationSource configurationSource) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [DebuggerStepThrough] - public virtual ConfigurationSource GetConfigurationSource() => _configurationSource; + public virtual ConfigurationSource GetConfigurationSource() + => _configurationSource; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -240,7 +241,8 @@ public virtual PropertyInfo FindIndexerPropertyInfo() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual PropertyAccessMode? SetPropertyAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) { this.SetOrRemoveAnnotation(CoreAnnotationNames.PropertyAccessMode, propertyAccessMode, configurationSource); @@ -254,7 +256,8 @@ public virtual PropertyInfo FindIndexerPropertyInfo() /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual PropertyAccessMode? SetNavigationAccessMode( - PropertyAccessMode? propertyAccessMode, ConfigurationSource configurationSource) + PropertyAccessMode? propertyAccessMode, + ConfigurationSource configurationSource) { this.SetOrRemoveAnnotation(CoreAnnotationNames.NavigationAccessMode, propertyAccessMode, configurationSource); @@ -390,7 +393,8 @@ Type ITypeBase.ClrType /// 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. /// - string IMutableTypeBase.AddIgnored(string name) => AddIgnored(name, ConfigurationSource.Explicit); + string IMutableTypeBase.AddIgnored(string name) + => AddIgnored(name, ConfigurationSource.Explicit); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Metadata/Internal/TypeIdentity.cs b/src/EFCore/Metadata/Internal/TypeIdentity.cs index 33ca3288e29..cd577444e55 100644 --- a/src/EFCore/Metadata/Internal/TypeIdentity.cs +++ b/src/EFCore/Metadata/Internal/TypeIdentity.cs @@ -32,11 +32,11 @@ public TypeIdentity([NotNull] string name) } /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// [DebuggerStepThrough] public TypeIdentity([NotNull] string name, [NotNull] Type type) { @@ -83,26 +83,29 @@ public TypeIdentity([NotNull] Type type, [NotNull] Model model) /// public bool IsNamed { [DebuggerStepThrough] get; } - private string DebuggerDisplay() => Name; + private string DebuggerDisplay() + => Name; /// - public override bool Equals(object obj) => obj is TypeIdentity identity && Equals(identity); + public override bool Equals(object obj) + => obj is TypeIdentity identity && Equals(identity); /// public bool Equals(TypeIdentity other) => Name == other.Name - && EqualityComparer.Default.Equals(Type, other.Type) - && IsNamed == other.IsNamed; + && EqualityComparer.Default.Equals(Type, other.Type) + && IsNamed == other.IsNamed; /// - public override int GetHashCode() => HashCode.Combine(Name, Type, IsNamed); + public override int GetHashCode() + => HashCode.Combine(Name, Type, IsNamed); /// /// Compares one id to another id to see if they represent the same type. /// /// The first id. /// The second id. - /// if they represent the same type; otherwise. + /// if they represent the same type; otherwise. public static bool operator ==(TypeIdentity left, TypeIdentity right) => left.Equals(right); @@ -111,7 +114,7 @@ public bool Equals(TypeIdentity other) /// /// The first id. /// The second id. - /// if they represent different types; otherwise. + /// if they represent different types; otherwise. public static bool operator !=(TypeIdentity left, TypeIdentity right) => !(left == right); } diff --git a/src/EFCore/Metadata/KeyComparer.cs b/src/EFCore/Metadata/KeyComparer.cs index 01b883aae66..dd0133f0cad 100644 --- a/src/EFCore/Metadata/KeyComparer.cs +++ b/src/EFCore/Metadata/KeyComparer.cs @@ -45,7 +45,7 @@ public int Compare(IKey x, IKey y) /// /// The first object to compare. /// The second object to compare. - /// if the specified objects are equal; otherwise, . + /// if the specified objects are equal; otherwise, . public bool Equals(IKey x, IKey y) => Compare(x, y) == 0; diff --git a/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs b/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs index a6dad835b2e..809c65151b2 100644 --- a/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs +++ b/src/EFCore/Metadata/LazyLoaderParameterBindingFactory.cs @@ -44,7 +44,7 @@ public LazyLoaderParameterBindingFactory([NotNull] LazyLoaderParameterBindingFac /// /// The parameter type. /// The parameter name. - /// if this parameter can be bound; otherwise. + /// if this parameter can be bound; otherwise. public override bool CanBind( Type parameterType, string parameterName) @@ -65,7 +65,9 @@ public override bool CanBind( /// The parameter name. /// The binding. public override ParameterBinding Bind( - IMutableEntityType entityType, Type parameterType, string parameterName) + IMutableEntityType entityType, + Type parameterType, + string parameterName) { Check.NotNull(entityType, nameof(entityType)); Check.NotNull(parameterType, nameof(parameterType)); diff --git a/src/EFCore/Metadata/MemberIdentity.cs b/src/EFCore/Metadata/MemberIdentity.cs index 03b9d034415..f9c84d54879 100644 --- a/src/EFCore/Metadata/MemberIdentity.cs +++ b/src/EFCore/Metadata/MemberIdentity.cs @@ -47,7 +47,8 @@ private MemberIdentity([CanBeNull] object nameOrMember) /// Checks if the identity is empty, as opposed to representing a member. /// /// if the identity is empty; otherwise. - public bool IsNone() => _nameOrMember == null; + public bool IsNone() + => _nameOrMember == null; /// /// A instance that does not represent any member. @@ -92,21 +93,23 @@ private string DebuggerDisplay() => Name ?? "NONE"; /// - public override bool Equals(object obj) => obj is MemberIdentity identity && Equals(identity); + public override bool Equals(object obj) + => obj is MemberIdentity identity && Equals(identity); /// public bool Equals(MemberIdentity other) => EqualityComparer.Default.Equals(_nameOrMember, other._nameOrMember); /// - public override int GetHashCode() => HashCode.Combine(_nameOrMember); + public override int GetHashCode() + => HashCode.Combine(_nameOrMember); /// /// Compares one id to another id to see if they represent the same member. /// /// The first id. /// The second id. - /// if they represent the same member; otherwise. + /// if they represent the same member; otherwise. public static bool operator ==(MemberIdentity left, MemberIdentity right) => left.Equals(right); @@ -115,7 +118,7 @@ public bool Equals(MemberIdentity other) /// /// The first id. /// The second id. - /// if they represent different members; otherwise. + /// if they represent different members; otherwise. public static bool operator !=(MemberIdentity left, MemberIdentity right) => !(left == right); } diff --git a/src/EFCore/Metadata/ParameterBindingInfo.cs b/src/EFCore/Metadata/ParameterBindingInfo.cs index 77cd292520e..d2e639b4340 100644 --- a/src/EFCore/Metadata/ParameterBindingInfo.cs +++ b/src/EFCore/Metadata/ParameterBindingInfo.cs @@ -43,6 +43,7 @@ public ParameterBindingInfo( /// /// The property. /// The index where its value can be found. - public int GetValueBufferIndex([NotNull] IPropertyBase property) => property.GetIndex(); + public int GetValueBufferIndex([NotNull] IPropertyBase property) + => property.GetIndex(); } } diff --git a/src/EFCore/Metadata/PropertyParameterBinding.cs b/src/EFCore/Metadata/PropertyParameterBinding.cs index fe6cc74c785..410b8be9d45 100644 --- a/src/EFCore/Metadata/PropertyParameterBinding.cs +++ b/src/EFCore/Metadata/PropertyParameterBinding.cs @@ -34,7 +34,7 @@ public override Expression BindToParameter(ParameterBindingInfo bindingInfo) var property = ConsumedProperties[0]; return Expression.Call(bindingInfo.MaterializationContextExpression, MaterializationContext.GetValueBufferMethod) - .CreateValueBufferReadValueExpression(property.ClrType, bindingInfo.GetValueBufferIndex(property), property); + .CreateValueBufferReadValueExpression(property.ClrType, bindingInfo.GetValueBufferIndex(property), property); } } } diff --git a/src/EFCore/Metadata/ServiceParameterBindingFactory.cs b/src/EFCore/Metadata/ServiceParameterBindingFactory.cs index b1bfe1643be..1620945952a 100644 --- a/src/EFCore/Metadata/ServiceParameterBindingFactory.cs +++ b/src/EFCore/Metadata/ServiceParameterBindingFactory.cs @@ -40,7 +40,7 @@ public ServiceParameterBindingFactory([NotNull] Type serviceType) /// /// The parameter type. /// The parameter name. - /// if this parameter can be bound; otherwise. + /// if this parameter can be bound; otherwise. public virtual bool CanBind( Type parameterType, string parameterName) diff --git a/src/EFCore/Metadata/SimpleModelFactory.cs b/src/EFCore/Metadata/SimpleModelFactory.cs index 91ff1b1e323..1b97fdcb8a0 100644 --- a/src/EFCore/Metadata/SimpleModelFactory.cs +++ b/src/EFCore/Metadata/SimpleModelFactory.cs @@ -22,6 +22,7 @@ public class SimpleModelFactory /// Creates an empty model with no conventions. All aspects of the model must be exhaustively configured. /// /// The newly created model. - public virtual IMutableModel Create() => new Model(); + public virtual IMutableModel Create() + => new Model(); } } diff --git a/src/EFCore/ModelBuilder.cs b/src/EFCore/ModelBuilder.cs index 162c4f4cebb..fa984aa97fb 100644 --- a/src/EFCore/ModelBuilder.cs +++ b/src/EFCore/ModelBuilder.cs @@ -92,7 +92,8 @@ public ModelBuilder([NotNull] IMutableModel model) /// /// The model being configured. /// - public virtual IMutableModel Model => Builder.Metadata; + public virtual IMutableModel Model + => Builder.Metadata; /// /// Adds or updates an annotation on the model. If an annotation with the key specified in @@ -120,7 +121,8 @@ public virtual ModelBuilder HasAnnotation([NotNull] string annotation, [NotNull] /// application code. /// /// - IConventionModelBuilder IInfrastructure.Instance => _builder; + IConventionModelBuilder IInfrastructure.Instance + => _builder; /// /// Returns an object that can be used to configure a given entity type in the model. @@ -257,7 +259,9 @@ public virtual ModelBuilder Entity([NotNull] Action /// The same instance so that additional configuration calls can be chained. /// - public virtual ModelBuilder SharedTypeEntity([NotNull] string name, [NotNull] Action> buildAction) + public virtual ModelBuilder SharedTypeEntity( + [NotNull] string name, + [NotNull] Action> buildAction) where TEntity : class { Check.NotEmpty(name, nameof(name)); @@ -345,7 +349,10 @@ public virtual ModelBuilder Entity([NotNull] string name, [NotNull] Action /// The same instance so that additional configuration calls can be chained. /// - public virtual ModelBuilder SharedTypeEntity([NotNull] string name, [NotNull] Type type, [NotNull] Action buildAction) + public virtual ModelBuilder SharedTypeEntity( + [NotNull] string name, + [NotNull] Type type, + [NotNull] Action buildAction) { Check.NotEmpty(name, nameof(name)); Check.NotNull(type, nameof(type)); @@ -430,7 +437,8 @@ public virtual ModelBuilder ApplyConfiguration([NotNull] IEntityTypeCon /// The same instance so that additional configuration calls can be chained. /// public virtual ModelBuilder ApplyConfigurationsFromAssembly( - [NotNull] Assembly assembly, [CanBeNull] Func predicate = null) + [NotNull] Assembly assembly, + [CanBeNull] Func predicate = null) { var applyEntityConfigurationMethod = typeof(ModelBuilder) .GetMethods() @@ -537,9 +545,11 @@ public virtual ModelBuilder UsePropertyAccessMode(PropertyAccessMode propertyAcc /// explicitly in cases where the automatic execution is not possible. /// /// The finalized . - public virtual IModel FinalizeModel() => Builder.Metadata.FinalizeModel(); + public virtual IModel FinalizeModel() + => Builder.Metadata.FinalizeModel(); - private InternalModelBuilder Builder => (InternalModelBuilder)this.GetInfrastructure(); + private InternalModelBuilder Builder + => (InternalModelBuilder)this.GetInfrastructure(); #region Hidden System.Object members @@ -548,22 +558,25 @@ public virtual ModelBuilder UsePropertyAccessMode(PropertyAccessMode propertyAcc /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore/Properties/TypeForwards.cs b/src/EFCore/Properties/TypeForwards.cs index ed8181a1076..8b4fb17ee75 100644 --- a/src/EFCore/Properties/TypeForwards.cs +++ b/src/EFCore/Properties/TypeForwards.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; -[assembly:TypeForwardedToAttribute(typeof(ObservableBackedBindingList<>))] -[assembly:TypeForwardedToAttribute(typeof(ObservableCollectionExtensions))] -[assembly:TypeForwardedToAttribute(typeof(ObservableCollectionListSource<>))] -[assembly:TypeForwardedToAttribute(typeof(SortableBindingList<>))] +[assembly: TypeForwardedToAttribute(typeof(ObservableBackedBindingList<>))] +[assembly: TypeForwardedToAttribute(typeof(ObservableCollectionExtensions))] +[assembly: TypeForwardedToAttribute(typeof(ObservableCollectionListSource<>))] +[assembly: TypeForwardedToAttribute(typeof(SortableBindingList<>))] diff --git a/src/EFCore/Query/CollectionShaperExpression.cs b/src/EFCore/Query/CollectionShaperExpression.cs index 52cbc5aa0f0..ce6aeec7449 100644 --- a/src/EFCore/Query/CollectionShaperExpression.cs +++ b/src/EFCore/Query/CollectionShaperExpression.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore.Query { /// /// - /// An expression that represents creation of a collection in . + /// An expression that represents creation of a collection in . /// /// /// This type is typically used by database providers (and other extensions). It is generally @@ -47,23 +47,29 @@ public CollectionShaperExpression( /// The expression to get value from query for this collection. /// public virtual Expression Projection { get; } + /// /// The expression to create inner elements. /// public virtual Expression InnerShaper { get; } + /// - /// The navigation if associated with the collection. + /// The navigation if associated with the collection. /// public virtual INavigationBase Navigation { get; } + /// /// The clr type of elements of the collection. /// public virtual Type ElementType { get; } /// - public sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; + /// - public override Type Type => Navigation?.ClrType ?? typeof(List<>).MakeGenericType(ElementType); + public override Type Type + => Navigation?.ClrType ?? typeof(List<>).MakeGenericType(ElementType); /// protected override Expression VisitChildren(ExpressionVisitor visitor) @@ -80,8 +86,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. /// - /// The property of the result. - /// The property of the result. + /// The property of the result. + /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual CollectionShaperExpression Update( [NotNull] Expression projection, diff --git a/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs b/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs index 5efd37c3dcb..bdd5241c170 100644 --- a/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs +++ b/src/EFCore/Query/CompiledQueryCacheKeyGenerator.cs @@ -109,7 +109,8 @@ public CompiledQueryCacheKey( /// The object to compare this key to. /// /// - /// if the object is a and is for the same query, otherwise . + /// if the object is a and is for the same query, otherwise + /// . /// public override bool Equals(object obj) => obj is CompiledQueryCacheKey other && Equals(other); diff --git a/src/EFCore/Query/EntityShaperExpression.cs b/src/EFCore/Query/EntityShaperExpression.cs index 31ec111ce7a..b2158ebd4bf 100644 --- a/src/EFCore/Query/EntityShaperExpression.cs +++ b/src/EFCore/Query/EntityShaperExpression.cs @@ -17,7 +17,7 @@ namespace Microsoft.EntityFrameworkCore.Query { /// /// - /// An expression that represents creation of an entity instance in . + /// An expression that represents creation of an entity instance in . /// /// /// This type is typically used by database providers (and other extensions). It is generally @@ -54,7 +54,10 @@ public EntityShaperExpression( /// The entity type to shape. /// An expression of ValueBuffer to get values for properties of the entity. /// Whether this entity instance can be null. - /// An expression of to determine which entity type to materialize. + /// + /// An expression of to determine which entity type to + /// materialize. + /// protected EntityShaperExpression( [NotNull] IEntityType entityType, [NotNull] Expression valueBufferExpression, @@ -69,8 +72,8 @@ protected EntityShaperExpression( materializationCondition = GenerateMaterializationCondition(entityType, nullable); } else if (materializationCondition.Parameters.Count != 1 - || materializationCondition.Parameters[0].Type != typeof(ValueBuffer) - || materializationCondition.ReturnType != typeof(IEntityType)) + || materializationCondition.Parameters[0].Type != typeof(ValueBuffer) + || materializationCondition.ReturnType != typeof(IEntityType)) { throw new InvalidOperationException(CoreStrings.QueryEntityMaterializationConditionWrongShape(entityType.DisplayName())); } @@ -82,11 +85,11 @@ protected EntityShaperExpression( } /// - /// Creates an expression of to determine which entity type to materialize. + /// Creates an expression of to determine which entity type to materialize. /// /// The entity type to create materialization condition for. /// Whether this entity instance can be null. - /// An expression of representing materilization condition for the entity type. + /// An expression of representing materilization condition for the entity type. protected virtual LambdaExpression GenerateMaterializationCondition([NotNull] IEntityType entityType, bool nullable) { Check.NotNull(entityType, nameof(EntityType)); @@ -114,8 +117,10 @@ protected virtual LambdaExpression GenerateMaterializationCondition([NotNull] IE } var exception = Block( - Throw(Call( - _createUnableToDiscriminateException, Constant(entityType), Convert(discriminatorValueVariable, typeof(object)))), + Throw( + Call( + _createUnableToDiscriminateException, Constant(entityType), + Convert(discriminatorValueVariable, typeof(object)))), Constant(null, typeof(IEntityType))); expressions.Add(Switch(discriminatorValueVariable, exception, switchCases)); @@ -131,9 +136,10 @@ protected virtual LambdaExpression GenerateMaterializationCondition([NotNull] IE { body = Condition( entityType.GetProperties() - .Select(p => NotEqual( - valueBufferParameter.CreateValueBufferReadValueExpression(typeof(object), p.GetIndex(), p), - Constant(null))) + .Select( + p => NotEqual( + valueBufferParameter.CreateValueBufferReadValueExpression(typeof(object), p.GetIndex(), p), + Constant(null))) .Aggregate((a, b) => OrElse(a, b)), body, Default(typeof(IEntityType))); @@ -146,14 +152,17 @@ protected virtual LambdaExpression GenerateMaterializationCondition([NotNull] IE /// The entity type being shaped. /// public virtual IEntityType EntityType { get; } + /// /// The expression representing a to get values from that are used to create the entity instance. /// public virtual Expression ValueBufferExpression { get; } + /// /// A value indicating whether this entity instance can be null. /// public virtual bool IsNullable { get; } + /// /// The materilization condition to use for shaping this entity. /// @@ -197,7 +206,7 @@ public virtual EntityShaperExpression MarkAsNullable() /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. /// - /// The property of the result. + /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual EntityShaperExpression Update([NotNull] Expression valueBufferExpression) { @@ -209,10 +218,12 @@ public virtual EntityShaperExpression Update([NotNull] Expression valueBufferExp } /// - public override Type Type => EntityType.ClrType; + public override Type Type + => EntityType.ClrType; /// - public sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) diff --git a/src/EFCore/Query/EvaluatableExpressionFilter.cs b/src/EFCore/Query/EvaluatableExpressionFilter.cs index 4eb07add21e..848a4e4bb84 100644 --- a/src/EFCore/Query/EvaluatableExpressionFilter.cs +++ b/src/EFCore/Query/EvaluatableExpressionFilter.cs @@ -74,14 +74,14 @@ public EvaluatableExpressionFilter( /// /// Parameter object containing service dependencies. /// - protected virtual EvaluatableExpressionFilterDependencies Dependencies { get; } + protected virtual EvaluatableExpressionFilterDependencies Dependencies { get; } /// /// Checks whether the given expression can be evaluated. /// /// The expression. /// The model. - /// if the expression can be evaluated; otherwise. + /// if the expression can be evaluated; otherwise. public virtual bool IsEvaluatableExpression(Expression expression, IModel model) { Check.NotNull(expression, nameof(expression)); diff --git a/src/EFCore/Query/ExpressionEqualityComparer.cs b/src/EFCore/Query/ExpressionEqualityComparer.cs index c99cce31fa7..98a464fa993 100644 --- a/src/EFCore/Query/ExpressionEqualityComparer.cs +++ b/src/EFCore/Query/ExpressionEqualityComparer.cs @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Query { /// - /// A comparer which implements for . + /// A comparer which implements for . /// public sealed class ExpressionEqualityComparer : IEqualityComparer { @@ -33,8 +33,8 @@ private ExpressionEqualityComparer() /// /// Returns the hash code for given expression. /// - /// The obj to compute hash code for. - /// The hash code value for . + /// The obj to compute hash code for. + /// The hash code value for . public int GetHashCode(Expression obj) { if (obj == null) @@ -75,6 +75,7 @@ public int GetHashCode(Expression obj) { hash.Add(constantExpression.Value); } + break; case DefaultExpression defaultExpression: @@ -190,6 +191,7 @@ public int GetHashCode(Expression obj) hash.Add(handler.Test); } } + break; case TypeBinaryExpression typeBinaryExpression: @@ -282,7 +284,8 @@ void AddMemberBindingsToHash(IReadOnlyList memberBindings) /// The left expression. /// The right expression. /// if the expressions are equal, otherwise. - public bool Equals(Expression x, Expression y) => new ExpressionComparer().Compare(x, y); + public bool Equals(Expression x, Expression y) + => new ExpressionComparer().Compare(x, y); private struct ExpressionComparer { @@ -331,7 +334,8 @@ public bool Compare(Expression left, Expression right) NewArrayExpression leftNewArray => CompareNewArray(leftNewArray, (NewArrayExpression)right), NewExpression leftNew => CompareNew(leftNew, (NewExpression)right), ParameterExpression leftParameter => CompareParameter(leftParameter, (ParameterExpression)right), - RuntimeVariablesExpression leftRuntimeVariables => CompareRuntimeVariables(leftRuntimeVariables, (RuntimeVariablesExpression)right), + RuntimeVariablesExpression leftRuntimeVariables => CompareRuntimeVariables( + leftRuntimeVariables, (RuntimeVariablesExpression)right), SwitchExpression leftSwitch => CompareSwitch(leftSwitch, (SwitchExpression)right), TryExpression leftTry => CompareTry(leftTry, (TryExpression)right), TypeBinaryExpression leftTypeBinary => CompareTypeBinary(leftTypeBinary, (TypeBinaryExpression)right), @@ -400,6 +404,7 @@ private bool CompareLambda(LambdaExpression a, LambdaExpression b) { _parameterScope.Remove(a.Parameters[j]); } + return false; } @@ -452,8 +457,8 @@ private bool CompareNew(NewExpression a, NewExpression b) private bool CompareParameter(ParameterExpression a, ParameterExpression b) => _parameterScope != null && _parameterScope.TryGetValue(a, out var mapped) - ? mapped.Name == b.Name - : a.Name == b.Name; + ? mapped.Name == b.Name + : a.Name == b.Name; private bool CompareRuntimeVariables(RuntimeVariablesExpression a, RuntimeVariablesExpression b) => CompareExpressionList(a.Variables, b.Variables); diff --git a/src/EFCore/Query/ExpressionPrinter.cs b/src/EFCore/Query/ExpressionPrinter.cs index 07a7e2d542d..38b466d8895 100644 --- a/src/EFCore/Query/ExpressionPrinter.cs +++ b/src/EFCore/Query/ExpressionPrinter.cs @@ -79,7 +79,8 @@ public ExpressionPrinter() /// /// A collection of items to print. /// A join action to use when joining printout of individual item in the collection. - public virtual void VisitCollection([NotNull] IReadOnlyCollection items, + public virtual void VisitCollection( + [NotNull] IReadOnlyCollection items, [CanBeNull] Action joinAction = null) where T : Expression { @@ -140,7 +141,8 @@ public virtual ExpressionPrinter AppendLines([NotNull] string value, bool skipFi /// Creates a scoped indenter that will increment the indent, then decrement it when disposed. /// /// An indenter. - public virtual IDisposable Indent() => _stringBuilder.Indent(); + public virtual IDisposable Indent() + => _stringBuilder.Indent(); /// /// Appends the given string to current output being built. @@ -204,7 +206,7 @@ private string PrintCore( } /// - /// Returns binary operator string corresponding to given . + /// Returns binary operator string corresponding to given . /// /// The expression type to generate binary operator for. /// The binary operator string. @@ -978,11 +980,12 @@ protected override Expression VisitIndex(IndexExpression indexExpression) Visit(indexExpression.Object); _stringBuilder.Append("["); - VisitArguments(indexExpression.Arguments, s => - { - _stringBuilder.Append(s); - return null; - }); + VisitArguments( + indexExpression.Arguments, s => + { + _stringBuilder.Append(s); + return null; + }); _stringBuilder.Append("]"); return indexExpression; diff --git a/src/EFCore/Query/GroupByShaperExpression.cs b/src/EFCore/Query/GroupByShaperExpression.cs index 2f53b53aaed..d399e95437e 100644 --- a/src/EFCore/Query/GroupByShaperExpression.cs +++ b/src/EFCore/Query/GroupByShaperExpression.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query { /// /// - /// An expression that represents creation of a grouping element in . + /// An expression that represents creation of a grouping element in . /// /// /// This type is typically used by database providers (and other extensions). It is generally @@ -40,15 +40,19 @@ public GroupByShaperExpression( /// The expression representing the key selector for this grouping element. /// public virtual Expression KeySelector { get; } + /// /// The expression representing the element selector for this grouping element. /// public virtual Expression ElementSelector { get; } /// - public override Type Type => typeof(IGrouping<,>).MakeGenericType(KeySelector.Type, ElementSelector.Type); + public override Type Type + => typeof(IGrouping<,>).MakeGenericType(KeySelector.Type, ElementSelector.Type); + /// - public sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// protected override Expression VisitChildren(ExpressionVisitor visitor) @@ -65,8 +69,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. /// - /// The property of the result. - /// The property of the result. + /// The property of the result. + /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual GroupByShaperExpression Update([NotNull] Expression keySelector, [NotNull] Expression elementSelector) { diff --git a/src/EFCore/Query/ICompiledQueryCacheKeyGenerator.cs b/src/EFCore/Query/ICompiledQueryCacheKeyGenerator.cs index edeeb25c429..46eebd1a0e4 100644 --- a/src/EFCore/Query/ICompiledQueryCacheKeyGenerator.cs +++ b/src/EFCore/Query/ICompiledQueryCacheKeyGenerator.cs @@ -24,7 +24,7 @@ public interface ICompiledQueryCacheKeyGenerator /// Generates a cache key. /// /// The query to generate a cache key for. - /// if the query will be executed asynchronously. + /// if the query will be executed asynchronously. /// An object representing a query cache key. object GenerateCacheKey([NotNull] Expression query, bool async); } diff --git a/src/EFCore/Query/IEvaluatableExpressionFilter.cs b/src/EFCore/Query/IEvaluatableExpressionFilter.cs index 0b1eabdee97..5cc64d4a090 100644 --- a/src/EFCore/Query/IEvaluatableExpressionFilter.cs +++ b/src/EFCore/Query/IEvaluatableExpressionFilter.cs @@ -25,7 +25,7 @@ public interface IEvaluatableExpressionFilter /// /// The expression. /// The model. - /// if the expression can be evaluated; otherwise. + /// if the expression can be evaluated; otherwise. bool IsEvaluatableExpression([NotNull] Expression expression, [NotNull] IModel model); } } diff --git a/src/EFCore/Query/IEvaluatableExpressionFilterPlugin.cs b/src/EFCore/Query/IEvaluatableExpressionFilterPlugin.cs index 24298d81c4f..f5c0588e05a 100644 --- a/src/EFCore/Query/IEvaluatableExpressionFilterPlugin.cs +++ b/src/EFCore/Query/IEvaluatableExpressionFilterPlugin.cs @@ -24,7 +24,7 @@ public interface IEvaluatableExpressionFilterPlugin /// Checks whether the given expression can be evaluated. /// /// The expression. - /// if the expression can be evaluated; otherwise. + /// if the expression can be evaluated; otherwise. bool IsEvaluatableExpression([NotNull] Expression expression); } } diff --git a/src/EFCore/Query/IPrintableExpression.cs b/src/EFCore/Query/IPrintableExpression.cs index 2dff03cfe3d..fc4f28ae87b 100644 --- a/src/EFCore/Query/IPrintableExpression.cs +++ b/src/EFCore/Query/IPrintableExpression.cs @@ -5,10 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - /// /// - /// An interface that allows printing via . + /// An interface that allows printing via . /// /// /// This interface is typically used by database providers (and other extensions). It is generally @@ -18,7 +17,7 @@ namespace Microsoft.EntityFrameworkCore.Query public interface IPrintableExpression { /// - /// Creates a printable string representation of the given expression using . + /// Creates a printable string representation of the given expression using . /// /// The expression printer to use. void Print([NotNull] ExpressionPrinter expressionPrinter); diff --git a/src/EFCore/Query/IQueryCompilationContextFactory.cs b/src/EFCore/Query/IQueryCompilationContextFactory.cs index 5d7de27278f..74a05adabe9 100644 --- a/src/EFCore/Query/IQueryCompilationContextFactory.cs +++ b/src/EFCore/Query/IQueryCompilationContextFactory.cs @@ -19,7 +19,7 @@ namespace Microsoft.EntityFrameworkCore.Query public interface IQueryCompilationContextFactory { /// - /// Creates a new . + /// Creates a new . /// /// Specifies whether the query is async. /// The created query compilation context. diff --git a/src/EFCore/Query/IQueryTranslationPostprocessorFactory.cs b/src/EFCore/Query/IQueryTranslationPostprocessorFactory.cs index 52a06d8259f..eb89acbeeec 100644 --- a/src/EFCore/Query/IQueryTranslationPostprocessorFactory.cs +++ b/src/EFCore/Query/IQueryTranslationPostprocessorFactory.cs @@ -19,7 +19,7 @@ namespace Microsoft.EntityFrameworkCore.Query public interface IQueryTranslationPostprocessorFactory { /// - /// Creates a new for given . + /// Creates a new for given . /// /// The query compilation context to use. /// The created visitor. diff --git a/src/EFCore/Query/IQueryTranslationPreprocessorFactory.cs b/src/EFCore/Query/IQueryTranslationPreprocessorFactory.cs index 5e15812f6ee..dd5c48f0fc5 100644 --- a/src/EFCore/Query/IQueryTranslationPreprocessorFactory.cs +++ b/src/EFCore/Query/IQueryTranslationPreprocessorFactory.cs @@ -19,7 +19,7 @@ namespace Microsoft.EntityFrameworkCore.Query public interface IQueryTranslationPreprocessorFactory { /// - /// Creates a new for given . + /// Creates a new for given . /// /// The query compilation context to use. /// The created visitor. diff --git a/src/EFCore/Query/IQueryableMethodTranslatingExpressionVisitorFactory.cs b/src/EFCore/Query/IQueryableMethodTranslatingExpressionVisitorFactory.cs index 3d4a0e65a29..13c86adfaaf 100644 --- a/src/EFCore/Query/IQueryableMethodTranslatingExpressionVisitorFactory.cs +++ b/src/EFCore/Query/IQueryableMethodTranslatingExpressionVisitorFactory.cs @@ -19,7 +19,7 @@ namespace Microsoft.EntityFrameworkCore.Query public interface IQueryableMethodTranslatingExpressionVisitorFactory { /// - /// Creates a new for given . + /// Creates a new for given . /// /// The query compilation context to use. /// The created visitor. diff --git a/src/EFCore/Query/IShapedQueryCompilingExpressionVisitorFactory.cs b/src/EFCore/Query/IShapedQueryCompilingExpressionVisitorFactory.cs index 7c57ec51b26..a9468692c41 100644 --- a/src/EFCore/Query/IShapedQueryCompilingExpressionVisitorFactory.cs +++ b/src/EFCore/Query/IShapedQueryCompilingExpressionVisitorFactory.cs @@ -19,7 +19,7 @@ namespace Microsoft.EntityFrameworkCore.Query public interface IShapedQueryCompilingExpressionVisitorFactory { /// - /// Creates a new for given . + /// Creates a new for given . /// /// The query compilation context to use. /// The created visitor. diff --git a/src/EFCore/Query/IncludeExpression.cs b/src/EFCore/Query/IncludeExpression.cs index 60cb17f12fb..3459faa4db3 100644 --- a/src/EFCore/Query/IncludeExpression.cs +++ b/src/EFCore/Query/IncludeExpression.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query { /// /// - /// An expression that represents include operation in . + /// An expression that represents include operation in . /// /// /// This type is typically used by database providers (and other extensions). It is generally @@ -45,17 +45,21 @@ public IncludeExpression( /// The expression representing entity perfoming this include. /// public virtual Expression EntityExpression { get; } + /// /// The expression representing included navigation element. /// public virtual Expression NavigationExpression { get; } + /// /// The navigation associated with this include operation. /// public virtual INavigationBase Navigation { get; } /// - public sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; + /// public override Type Type { get; } @@ -74,8 +78,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. /// - /// The property of the result. - /// The property of the result. + /// The property of the result. + /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual IncludeExpression Update([NotNull] Expression entityExpression, [NotNull] Expression navigationExpression) { diff --git a/src/EFCore/Query/Internal/CompiledQueryBase.cs b/src/EFCore/Query/Internal/CompiledQueryBase.cs index 8258e825d00..a873d9ab2f6 100644 --- a/src/EFCore/Query/Internal/CompiledQueryBase.cs +++ b/src/EFCore/Query/Internal/CompiledQueryBase.cs @@ -82,7 +82,8 @@ protected virtual TResult ExecuteCore( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected abstract Func CreateCompiledQuery( - [NotNull] IQueryCompiler queryCompiler, [NotNull] Expression expression); + [NotNull] IQueryCompiler queryCompiler, + [NotNull] Expression expression); private Func EnsureExecutor(TContext context) => NonCapturingLazyInitializer.EnsureInitialized( @@ -103,7 +104,8 @@ private sealed class QueryExpressionRewriter : ExpressionVisitor private readonly IReadOnlyCollection _parameters; public QueryExpressionRewriter( - TContext context, IReadOnlyCollection parameters) + TContext context, + IReadOnlyCollection parameters) { _context = context; _parameters = parameters; diff --git a/src/EFCore/Query/Internal/CompiledQueryCache.cs b/src/EFCore/Query/Internal/CompiledQueryCache.cs index ad3935d098d..a8ac848fcc3 100644 --- a/src/EFCore/Query/Internal/CompiledQueryCache.cs +++ b/src/EFCore/Query/Internal/CompiledQueryCache.cs @@ -3,12 +3,8 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; @@ -50,7 +46,8 @@ public CompiledQueryCache([NotNull] IMemoryCache memoryCache) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual Func GetOrAddQuery( - object cacheKey, Func> compiler) + object cacheKey, + Func> compiler) { // ReSharper disable once InconsistentlySynchronizedField if (_memoryCache.TryGetValue(cacheKey, out Func compiledQuery)) diff --git a/src/EFCore/Query/Internal/EntityMaterializerSource.cs b/src/EFCore/Query/Internal/EntityMaterializerSource.cs index 33b5a19d2b0..5b3697f5803 100644 --- a/src/EFCore/Query/Internal/EntityMaterializerSource.cs +++ b/src/EFCore/Query/Internal/EntityMaterializerSource.cs @@ -141,7 +141,7 @@ static Expression CreateMemberAssignment(Expression parameter, MemberInfo member return property.IsIndexerProperty() ? Expression.Assign( Expression.MakeIndex( - parameter, (PropertyInfo)memberInfo, new List() { Expression.Constant(property.Name) }), + parameter, (PropertyInfo)memberInfo, new List { Expression.Constant(property.Name) }), value) : Expression.MakeMemberAccess(parameter, memberInfo).Assign(value); } diff --git a/src/EFCore/Query/Internal/EntityQueryable`.cs b/src/EFCore/Query/Internal/EntityQueryable`.cs index 95bce15d7c6..6b11bce7d4a 100644 --- a/src/EFCore/Query/Internal/EntityQueryable`.cs +++ b/src/EFCore/Query/Internal/EntityQueryable`.cs @@ -61,7 +61,8 @@ public EntityQueryable([NotNull] IAsyncQueryProvider queryProvider, [NotNull] Ex /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual Type ElementType => typeof(TResult); + public virtual Type ElementType + => typeof(TResult); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -77,7 +78,8 @@ public EntityQueryable([NotNull] IAsyncQueryProvider queryProvider, [NotNull] Ex /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IQueryProvider Provider => _queryProvider; + public virtual IQueryProvider Provider + => _queryProvider; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -123,7 +125,8 @@ IList IListSource.GetList() /// 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. /// - bool IListSource.ContainsListCollection => false; + bool IListSource.ContainsListCollection + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -131,6 +134,7 @@ IList IListSource.GetList() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual QueryDebugView DebugView => new QueryDebugView(() => Expression.Print(), this.ToQueryString); + public virtual QueryDebugView DebugView + => new QueryDebugView(() => Expression.Print(), this.ToQueryString); } } diff --git a/src/EFCore/Query/Internal/ICompiledQueryCache.cs b/src/EFCore/Query/Internal/ICompiledQueryCache.cs index c5ef3b47f5f..28dd751ca2e 100644 --- a/src/EFCore/Query/Internal/ICompiledQueryCache.cs +++ b/src/EFCore/Query/Internal/ICompiledQueryCache.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Threading.Tasks; using JetBrains.Annotations; using Microsoft.Extensions.DependencyInjection; diff --git a/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs b/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs index f9efa048d27..8068906679b 100644 --- a/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/InvocationExpressionRemovingExpressionVisitor.cs @@ -48,7 +48,7 @@ private Expression StripTrivialConversions(Expression expression) private Expression InlineLambdaExpression(LambdaExpression lambdaExpression, ReadOnlyCollection arguments) => new ReplacingExpressionVisitor( - lambdaExpression.Parameters.ToArray(), arguments.ToArray()) + lambdaExpression.Parameters.ToArray(), arguments.ToArray()) .Visit(lambdaExpression.Body); } } diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs index 034cc1661e7..e0c61eec45e 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs @@ -134,7 +134,10 @@ private Expression TryExpandNavigation(Expression root, MemberIdentity memberIde } protected Expression ExpandNavigation( - Expression root, EntityReference entityReference, INavigation navigation, bool derivedTypeConversion) + Expression root, + EntityReference entityReference, + INavigation navigation, + bool derivedTypeConversion) { var targetType = navigation.TargetEntityType; if (targetType.HasDefiningNavigation() @@ -177,7 +180,10 @@ protected Expression ExpandNavigation( } protected Expression ExpandSkipNavigation( - Expression root, EntityReference entityReference, ISkipNavigation navigation, bool derivedTypeConversion) + Expression root, + EntityReference entityReference, + ISkipNavigation navigation, + bool derivedTypeConversion) { var inverseNavigation = navigation.Inverse; var includeTree = entityReference.IncludePaths.TryGetValue(navigation, out var tree) @@ -221,19 +227,19 @@ protected Expression ExpandSkipNavigation( var sourceElementType = primaryExpansion.Type.GetSequenceType(); var outerKeyparameter = Expression.Parameter(sourceElementType); var outerKey = outerKeyparameter.CreateKeyValuesExpression( - !inverseNavigation.IsOnDependent - ? secondaryForeignKey.Properties - : secondaryForeignKey.PrincipalKey.Properties, - makeNullable: true); + !inverseNavigation.IsOnDependent + ? secondaryForeignKey.Properties + : secondaryForeignKey.PrincipalKey.Properties, + makeNullable: true); var outerKeySelector = Expression.Lambda(outerKey, outerKeyparameter); var innerSourceElementType = innerSource.Type.GetSequenceType(); var innerKeyParameter = Expression.Parameter(innerSourceElementType); var innerKey = innerKeyParameter.CreateKeyValuesExpression( - !inverseNavigation.IsOnDependent - ? secondaryForeignKey.PrincipalKey.Properties - : secondaryForeignKey.Properties, - makeNullable: true); + !inverseNavigation.IsOnDependent + ? secondaryForeignKey.PrincipalKey.Properties + : secondaryForeignKey.Properties, + makeNullable: true); var innerKeySelector = Expression.Lambda(innerKey, innerKeyParameter); var resultSelector = Expression.Lambda(innerKeyParameter, outerKeyparameter, innerKeyParameter); @@ -244,14 +250,14 @@ protected Expression ExpandSkipNavigation( (innerJoin ? QueryableMethods.Join : QueryableExtensions.LeftJoinMethodInfo).MakeGenericMethod( - sourceElementType, innerSourceElementType, - outerKeySelector.ReturnType, - resultSelector.ReturnType), - primaryExpansion, - innerSource, - Expression.Quote(outerKeySelector), - Expression.Quote(innerKeySelector), - Expression.Quote(resultSelector)); + sourceElementType, innerSourceElementType, + outerKeySelector.ReturnType, + resultSelector.ReturnType), + primaryExpansion, + innerSource, + Expression.Quote(outerKeySelector), + Expression.Quote(innerKeySelector), + Expression.Quote(resultSelector)); } else { @@ -268,18 +274,18 @@ protected Expression ExpandSkipNavigation( var sourceElementType = primaryExpansion.Type.GetSequenceType(); var outersourceParameter = Expression.Parameter(sourceElementType); var outerKey = outersourceParameter.CreateKeyValuesExpression( - !inverseNavigation.IsOnDependent - ? secondaryForeignKey.Properties - : secondaryForeignKey.PrincipalKey.Properties, - makeNullable: true); + !inverseNavigation.IsOnDependent + ? secondaryForeignKey.Properties + : secondaryForeignKey.PrincipalKey.Properties, + makeNullable: true); var innerSourceElementType = innerSource.Type.GetSequenceType(); var innerSourceParameter = Expression.Parameter(innerSourceElementType); var innerKey = innerSourceParameter.CreateKeyValuesExpression( - !inverseNavigation.IsOnDependent - ? secondaryForeignKey.PrincipalKey.Properties - : secondaryForeignKey.Properties, - makeNullable: true); + !inverseNavigation.IsOnDependent + ? secondaryForeignKey.PrincipalKey.Properties + : secondaryForeignKey.Properties, + makeNullable: true); // Selector body is IQueryable, we need to adjust the type to IEnumerable, to match the SelectMany signature // therefore the delegate type is specified explicitly @@ -298,8 +304,8 @@ protected Expression ExpandSkipNavigation( secondaryExpansion = Expression.Call( QueryableMethods.SelectManyWithoutCollectionSelector.MakeGenericMethod( sourceElementType, innerSourceElementType), - primaryExpansion, - Expression.Quote(selector)); + primaryExpansion, + Expression.Quote(selector)); } } @@ -388,12 +394,13 @@ private Expression ExpandForeignKey( var predicateBody = Expression.AndAlso( outerKey is NewArrayExpression newArrayExpression ? newArrayExpression.Expressions - .Select(e => - { - var left = (e as UnaryExpression)?.Operand ?? e; + .Select( + e => + { + var left = (e as UnaryExpression)?.Operand ?? e; - return Expression.NotEqual(left, Expression.Constant(null, left.Type)); - }) + return Expression.NotEqual(left, Expression.Constant(null, left.Type)); + }) .Aggregate((l, r) => Expression.AndAlso(l, r)) : Expression.NotEqual(outerKey, Expression.Constant(null, outerKey.Type)), Expression.Call(_objectEqualsMethodInfo, AddConvertToObject(outerKey), AddConvertToObject(innerKey))); @@ -467,7 +474,7 @@ private static Expression AddConvertToObject(Expression expression) /// /// Expands an include tree. This is separate and needed because we may need to reconstruct parts of - /// to apply includes. + /// to apply includes. /// private sealed class IncludeExpandingExpressionVisitor : ExpandingExpressionVisitor { @@ -483,8 +490,10 @@ public IncludeExpandingExpressionVisitor( : base(navigationExpandingExpressionVisitor, source) { _logger = navigationExpandingExpressionVisitor._queryCompilationContext.Logger; - _queryStateManager = navigationExpandingExpressionVisitor._queryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll - || navigationExpandingExpressionVisitor._queryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution; + _queryStateManager = navigationExpandingExpressionVisitor._queryCompilationContext.QueryTrackingBehavior + == QueryTrackingBehavior.TrackAll + || navigationExpandingExpressionVisitor._queryCompilationContext.QueryTrackingBehavior + == QueryTrackingBehavior.NoTrackingWithIdentityResolution; } protected override Expression VisitExtension(Expression extensionExpression) @@ -763,7 +772,8 @@ private Expression ExpandIncludesHelper(Expression root, EntityReference entityR Expression.Lambda( Expression.Call( _fetchJoinEntityMethodInfo.MakeGenericMethod(joinParameter.Type, targetParameter.Type), - Expression.MakeMemberAccess(transparentIdentifierParameter, transparentIdentifierOuterMemberInfo), + Expression.MakeMemberAccess( + transparentIdentifierParameter, transparentIdentifierOuterMemberInfo), transparentIdentifierInnerAccessor), transparentIdentifierParameter)); @@ -789,7 +799,8 @@ private Expression ExpandIncludesHelper(Expression root, EntityReference entityR } #pragma warning disable IDE0060 // Remove unused parameter - private static TTarget FetchJoinEntity(TJoin joinEntity, TTarget targetEntity) => targetEntity; + private static TTarget FetchJoinEntity(TJoin joinEntity, TTarget targetEntity) + => targetEntity; #pragma warning restore IDE0060 // Remove unused parameter private static Expression RemapFilterExpressionForJoinEntity( @@ -827,7 +838,7 @@ private static Expression RemapFilterExpressionForJoinEntity( } /// - /// remembers the pending selector so we don't expand + /// remembers the pending selector so we don't expand /// navigations unless we need to. This visitor applies them when we need to. /// private sealed class PendingSelectorExpandingExpressionVisitor : ExpressionVisitor @@ -836,7 +847,8 @@ private sealed class PendingSelectorExpandingExpressionVisitor : ExpressionVisit private readonly bool _applyIncludes; public PendingSelectorExpandingExpressionVisitor( - NavigationExpandingExpressionVisitor visitor, bool applyIncludes = false) + NavigationExpandingExpressionVisitor visitor, + bool applyIncludes = false) { _visitor = visitor; _applyIncludes = applyIncludes; @@ -928,7 +940,7 @@ public override Expression Visit(Expression expression) } /// - /// Marks as nullable when coming from a left join. + /// Marks as nullable when coming from a left join. /// Nullability is required to figure out if the navigation from this entity should be a left join or /// an inner join. /// @@ -969,8 +981,8 @@ protected override Expression VisitExtension(Expression extensionExpression) return extensionExpression is QueryRootExpression queryRootExpression && queryRootExpression.EntityType == _entityType - ? _navigationExpandingExpressionVisitor.CreateNavigationExpansionExpression(queryRootExpression, _entityType) - : base.VisitExtension(extensionExpression); + ? _navigationExpandingExpressionVisitor.CreateNavigationExpansionExpression(queryRootExpression, _entityType) + : base.VisitExtension(extensionExpression); } } @@ -985,11 +997,11 @@ public RemoveRedundantNavigationComparisonExpressionVisitor(IDiagnosticsLogger (binaryExpression.NodeType == ExpressionType.Equal - || binaryExpression.NodeType == ExpressionType.NotEqual) + || binaryExpression.NodeType == ExpressionType.NotEqual) && TryRemoveNavigationComparison( binaryExpression.NodeType, binaryExpression.Left, binaryExpression.Right, out var result) - ? result - : base.VisitBinary(binaryExpression); + ? result + : base.VisitBinary(binaryExpression); protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) { @@ -1086,7 +1098,7 @@ private Expression ProcessNavigationPath(Expression expression) return expression; case MethodCallExpression methodCallExpression - when methodCallExpression.TryGetEFPropertyArguments(out var source, out var navigationName): + when methodCallExpression.TryGetEFPropertyArguments(out var source, out var navigationName): return expression; default: @@ -1131,8 +1143,11 @@ public NavigationDataExpression(Expression current, NavigationDataExpression inn } } - public override Type Type => Current.Type; - public override ExpressionType NodeType => ExpressionType.Extension; + public override Type Type + => Current.Type; + + public override ExpressionType NodeType + => ExpressionType.Extension; public INavigation Navigation { get; } public Expression Current { get; } diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs index 4f362845915..f9afd57ca99 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.Expressions.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Utilities; @@ -23,13 +22,19 @@ public EntityReference(IEntityType entityType) } public IEntityType EntityType { get; } - public IDictionary<(IForeignKey, bool), Expression> ForeignKeyExpansionMap { get; } = new Dictionary<(IForeignKey, bool), Expression>(); + + public IDictionary<(IForeignKey, bool), Expression> ForeignKeyExpansionMap { get; } = + new Dictionary<(IForeignKey, bool), Expression>(); public bool IsOptional { get; private set; } public IncludeTreeNode IncludePaths { get; private set; } public IncludeTreeNode LastIncludeTreeNode { get; private set; } - public override ExpressionType NodeType => ExpressionType.Extension; - public override Type Type => EntityType.ClrType; + + public override ExpressionType NodeType + => ExpressionType.Extension; + + public override Type Type + => EntityType.ClrType; protected override Expression VisitChildren(ExpressionVisitor visitor) { @@ -46,9 +51,11 @@ public EntityReference Snapshot() return result; } - public void SetLastInclude(IncludeTreeNode lastIncludeTree) => LastIncludeTreeNode = lastIncludeTree; + public void SetLastInclude(IncludeTreeNode lastIncludeTree) + => LastIncludeTreeNode = lastIncludeTree; - public void MarkAsOptional() => IsOptional = true; + public void MarkAsOptional() + => IsOptional = true; void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { @@ -72,7 +79,7 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) } /// - /// A tree structure of includes for a given entity type in . + /// A tree structure of includes for a given entity type in . /// private sealed class IncludeTreeNode : Dictionary { @@ -130,10 +137,7 @@ public IncludeTreeNode AddNavigation(INavigationBase navigation) public IncludeTreeNode Snapshot(EntityReference entityReference) { - var result = new IncludeTreeNode(EntityType, entityReference) - { - FilterExpression = FilterExpression - }; + var result = new IncludeTreeNode(EntityType, entityReference) { FilterExpression = FilterExpression }; foreach (var kvp in this) { @@ -153,8 +157,11 @@ public void Merge(IncludeTreeNode includeTreeNode) } } - public void AssignEntityReference(EntityReference entityReference) => _entityReference = entityReference; - public void ApplyFilter(LambdaExpression filterExpression) => FilterExpression = filterExpression; + public void AssignEntityReference(EntityReference entityReference) + => _entityReference = entityReference; + + public void ApplyFilter(LambdaExpression filterExpression) + => FilterExpression = filterExpression; public override bool Equals(object obj) => obj != null @@ -181,7 +188,8 @@ private bool Equals(IncludeTreeNode includeTreeNode) return true; } - public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), EntityType); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), EntityType); } /// @@ -192,12 +200,16 @@ private sealed class NavigationExpansionExpression : Expression, IPrintableExpre { private readonly List<(MethodInfo OrderingMethod, Expression KeySelector)> _pendingOrderings = new List<(MethodInfo OrderingMethod, Expression KeySelector)>(); + private readonly string _parameterName; private NavigationTreeNode _currentTree; public NavigationExpansionExpression( - Expression source, NavigationTreeNode currentTree, Expression pendingSelector, string parameterName) + Expression source, + NavigationTreeNode currentTree, + Expression pendingSelector, + string parameterName) { Source = source; _parameterName = parameterName; @@ -206,7 +218,9 @@ public NavigationExpansionExpression( } public Expression Source { get; private set; } - public ParameterExpression CurrentParameter => CurrentTree.CurrentParameter; + + public ParameterExpression CurrentParameter + => CurrentTree.CurrentParameter; public NavigationTreeNode CurrentTree { @@ -220,14 +234,21 @@ private set public Expression PendingSelector { get; private set; } public MethodInfo CardinalityReducingGenericMethodInfo { get; private set; } - public Type SourceElementType => CurrentParameter.Type; - public IReadOnlyList<(MethodInfo OrderingMethod, Expression KeySelector)> PendingOrderings => _pendingOrderings; - public void UpdateSource(Expression source) => Source = source; + public Type SourceElementType + => CurrentParameter.Type; - public void UpdateCurrentTree(NavigationTreeNode currentTree) => CurrentTree = currentTree; + public IReadOnlyList<(MethodInfo OrderingMethod, Expression KeySelector)> PendingOrderings + => _pendingOrderings; - public void ApplySelector(Expression selector) => PendingSelector = selector; + public void UpdateSource(Expression source) + => Source = source; + + public void UpdateCurrentTree(NavigationTreeNode currentTree) + => CurrentTree = currentTree; + + public void ApplySelector(Expression selector) + => PendingSelector = selector; public void AddPendingOrdering(MethodInfo orderingMethod, Expression keySelector) { @@ -244,10 +265,14 @@ public void ClearPendingOrderings() public void ConvertToSingleResult(MethodInfo genericMethod) => CardinalityReducingGenericMethodInfo = genericMethod; - public override ExpressionType NodeType => ExpressionType.Extension; - public override Type Type => CardinalityReducingGenericMethodInfo == null - ? typeof(IQueryable<>).MakeGenericType(PendingSelector.Type) - : PendingSelector.Type; + public override ExpressionType NodeType + => ExpressionType.Extension; + + public override Type Type + => CardinalityReducingGenericMethodInfo == null + ? typeof(IQueryable<>).MakeGenericType(PendingSelector.Type) + : PendingSelector.Type; + protected override Expression VisitChildren(ExpressionVisitor visitor) { Check.NotNull(visitor, nameof(visitor)); @@ -278,8 +303,8 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// /// A leaf node on navigation tree, representing projection structures of - /// . Contains , - /// which can be or . + /// . Contains , + /// which can be or . /// private sealed class NavigationTreeExpression : NavigationTreeNode, IPrintableExpression { @@ -290,7 +315,7 @@ public NavigationTreeExpression(Expression value) } /// - /// Either or . + /// Either or . /// public Expression Value { get; private set; } @@ -303,7 +328,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) return this; } - public override Type Type => Value.Type; + public override Type Type + => Value.Type; void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) { @@ -355,10 +381,14 @@ private set public NavigationTreeNode Right { get; } public ParameterExpression CurrentParameter { get; private set; } - public void SetParameter(string parameterName) => CurrentParameter = Parameter(Type, parameterName); + public void SetParameter(string parameterName) + => CurrentParameter = Parameter(Type, parameterName); + + public override ExpressionType NodeType + => ExpressionType.Extension; - public override ExpressionType NodeType => ExpressionType.Extension; - public override Type Type => TransparentIdentifierFactory.Create(Left.Type, Right.Type); + public override Type Type + => TransparentIdentifierFactory.Create(Left.Type, Right.Type); public Expression GetExpression() { @@ -400,8 +430,11 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) public INavigation Navigation { get; } public EntityReference EntityReference { get; } - public override Type Type => Navigation.ClrType; - public override ExpressionType NodeType => ExpressionType.Extension; + public override Type Type + => Navigation.ClrType; + + public override ExpressionType NodeType + => ExpressionType.Extension; } } } diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs index 39583b93f73..45abd7413df 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.cs @@ -220,7 +220,8 @@ protected override Expression VisitMember(MemberExpression memberExpression) { // This is FirstOrDefault.Member // due to SubqueryMemberPushdown, this may be collection navigation which was not pushed down - navigationExpansionExpression = (NavigationExpansionExpression)_pendingSelectorExpandingExpressionVisitor.Visit(navigationExpansionExpression); + navigationExpansionExpression = + (NavigationExpansionExpression)_pendingSelectorExpandingExpressionVisitor.Visit(navigationExpansionExpression); var expandedExpression = new ExpandingExpressionVisitor(this, navigationExpansionExpression).Visit(updatedExpression); if (expandedExpression != updatedExpression) { @@ -538,8 +539,9 @@ when QueryableMethods.IsSumWithSelector(method): // DefaultIfEmpty with argument // Index based lambda overloads of Where, SkipWhile, TakeWhile, Select, SelectMany // IEqualityComparer overloads of Distinct, Contains, Join, Except, Intersect, Union, OrderBy, ThenBy, OrderByDescending, ThenByDescending, GroupBy - throw new InvalidOperationException(CoreStrings.TranslationFailed( - _reducingExpressionVisitor.Visit(methodCallExpression).Print())); + throw new InvalidOperationException( + CoreStrings.TranslationFailed( + _reducingExpressionVisitor.Visit(methodCallExpression).Print())); } } @@ -597,7 +599,9 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) } private Expression ProcessAllAnyCountLongCount( - NavigationExpansionExpression source, MethodInfo genericMethod, LambdaExpression predicate) + NavigationExpansionExpression source, + MethodInfo genericMethod, + LambdaExpression predicate) { if (predicate != null) { @@ -644,10 +648,12 @@ private Expression ProcessAverageMaxMinSum(NavigationExpansionExpression source, } private NavigationExpansionExpression ProcessCastOfType( - NavigationExpansionExpression source, MethodInfo genericMethod, Type castType) + NavigationExpansionExpression source, + MethodInfo genericMethod, + Type castType) { if (castType.IsAssignableFrom(source.PendingSelector.Type) - || castType == typeof(object)) + || castType == typeof(object)) { // Casting to base/implementing interface is redundant return source; @@ -715,7 +721,8 @@ private NavigationExpansionExpression ProcessDefaultIfEmpty(NavigationExpansionE if (!pendingSelector.Type.IsNullableType()) { pendingSelector = Expression.Coalesce( - Expression.Convert(pendingSelector, pendingSelector.Type.MakeNullable()), pendingSelector.Type.GetDefaultValueConstant()); + Expression.Convert(pendingSelector, pendingSelector.Type.MakeNullable()), + pendingSelector.Type.GetDefaultValueConstant()); } source.ApplySelector(pendingSelector); @@ -738,7 +745,9 @@ private NavigationExpansionExpression ProcessDistinct(NavigationExpansionExpress } private NavigationExpansionExpression ProcessSkipTake( - NavigationExpansionExpression source, MethodInfo genericMethod, Expression count) + NavigationExpansionExpression source, + MethodInfo genericMethod, + Expression count) { source.UpdateSource(Expression.Call(genericMethod.MakeGenericMethod(source.SourceElementType), source.Source, count)); @@ -746,7 +755,10 @@ private NavigationExpansionExpression ProcessSkipTake( } private NavigationExpansionExpression ProcessFirstSingleLastOrDefault( - NavigationExpansionExpression source, MethodInfo genericMethod, LambdaExpression predicate, Type returnType) + NavigationExpansionExpression source, + MethodInfo genericMethod, + LambdaExpression predicate, + Type returnType) { if (predicate != null) { @@ -884,11 +896,13 @@ private NavigationExpansionExpression ProcessInclude(NavigationExpansionExpressi throw new InvalidOperationException(CoreStrings.IncludeOnNonEntity); - static (Expression result, LambdaExpression filterExpression) ExtractIncludeFilter(Expression currentExpression, Expression includeExpression) + static (Expression result, LambdaExpression filterExpression) ExtractIncludeFilter( + Expression currentExpression, + Expression includeExpression) { if (currentExpression is MemberExpression) { - return (currentExpression, default(LambdaExpression)); + return (currentExpression, default); } if (currentExpression is MethodCallExpression methodCallExpression) @@ -906,10 +920,7 @@ private NavigationExpansionExpression ProcessInclude(NavigationExpansionExpressi filterExpression = Expression.Lambda(prm, prm); } - var arguments = new List - { - filterExpression.Body - }; + var arguments = new List { filterExpression.Body }; arguments.AddRange(methodCallExpression.Arguments.Skip(1)); filterExpression = Expression.Lambda( methodCallExpression.Update(methodCallExpression.Object, arguments), @@ -975,7 +986,8 @@ private NavigationExpansionExpression ProcessJoin( var source = Expression.Call( QueryableMethods.Join.MakeGenericMethod( - outerSource.SourceElementType, innerSource.SourceElementType, outerKeySelector.ReturnType, newResultSelector.ReturnType), + outerSource.SourceElementType, innerSource.SourceElementType, outerKeySelector.ReturnType, + newResultSelector.ReturnType), outerSource.Source, innerSource.Source, Expression.Quote(outerKeySelector), @@ -984,8 +996,8 @@ private NavigationExpansionExpression ProcessJoin( var currentTree = new NavigationTreeNode(outerSource.CurrentTree, innerSource.CurrentTree); var pendingSelector = new ReplacingExpressionVisitor( - new Expression[] { resultSelector.Parameters[0], resultSelector.Parameters[1] }, - new[] { outerSource.PendingSelector, innerSource.PendingSelector }) + new Expression[] { resultSelector.Parameters[0], resultSelector.Parameters[1] }, + new[] { outerSource.PendingSelector, innerSource.PendingSelector }) .Visit(resultSelector.Body); var parameterName = GetParameterName("ti"); @@ -1023,7 +1035,8 @@ private NavigationExpansionExpression ProcessLeftJoin( var source = Expression.Call( QueryableExtensions.LeftJoinMethodInfo.MakeGenericMethod( - outerSource.SourceElementType, innerSource.SourceElementType, outerKeySelector.ReturnType, newResultSelector.ReturnType), + outerSource.SourceElementType, innerSource.SourceElementType, outerKeySelector.ReturnType, + newResultSelector.ReturnType), outerSource.Source, innerSource.Source, Expression.Quote(outerKeySelector), @@ -1035,8 +1048,8 @@ private NavigationExpansionExpression ProcessLeftJoin( var currentTree = new NavigationTreeNode(outerSource.CurrentTree, innerSource.CurrentTree); var pendingSelector = new ReplacingExpressionVisitor( - new Expression[] { resultSelector.Parameters[0], resultSelector.Parameters[1] }, - new[] { outerSource.PendingSelector, innerPendingSelector }) + new Expression[] { resultSelector.Parameters[0], resultSelector.Parameters[1] }, + new[] { outerSource.PendingSelector, innerPendingSelector }) .Visit(resultSelector.Body); var parameterName = GetParameterName("ti"); @@ -1044,7 +1057,10 @@ private NavigationExpansionExpression ProcessLeftJoin( } private NavigationExpansionExpression ProcessOrderByThenBy( - NavigationExpansionExpression source, MethodInfo genericMethod, LambdaExpression keySelector, bool thenBy) + NavigationExpansionExpression source, + MethodInfo genericMethod, + LambdaExpression keySelector, + bool thenBy) { var lambdaBody = ReplacingExpressionVisitor.Replace( keySelector.Parameters[0], @@ -1107,7 +1123,9 @@ private NavigationExpansionExpression ProcessSelect(NavigationExpansionExpressio } private NavigationExpansionExpression ProcessSelectMany( - NavigationExpansionExpression source, LambdaExpression collectionSelector, LambdaExpression resultSelector) + NavigationExpansionExpression source, + LambdaExpression collectionSelector, + LambdaExpression resultSelector) { var collectionSelectorBody = ExpandNavigationsForSource(source, RemapLambdaExpression(source, collectionSelector)); if (collectionSelectorBody is MaterializeCollectionNavigationExpression materializeCollectionNavigationExpression) @@ -1158,8 +1176,8 @@ private NavigationExpansionExpression ProcessSelectMany( var pendingSelector = resultSelector == null ? innerTree : new ReplacingExpressionVisitor( - new Expression[] { resultSelector.Parameters[0], resultSelector.Parameters[1] }, - new[] { source.PendingSelector, innerTree }) + new Expression[] { resultSelector.Parameters[0], resultSelector.Parameters[1] }, + new[] { source.PendingSelector, innerTree }) .Visit(resultSelector.Body); var parameterName = GetParameterName("ti"); @@ -1171,7 +1189,9 @@ private NavigationExpansionExpression ProcessSelectMany( } private NavigationExpansionExpression ProcessSetOperation( - NavigationExpansionExpression outerSource, MethodInfo genericMethod, NavigationExpansionExpression innerSource) + NavigationExpansionExpression outerSource, + MethodInfo genericMethod, + NavigationExpansionExpression innerSource) { outerSource = (NavigationExpansionExpression)_pendingSelectorExpandingExpressionVisitor.Visit(outerSource); var outerTreeStructure = SnapshotExpression(outerSource.PendingSelector); @@ -1270,7 +1290,8 @@ private void ApplyPendingOrderings(NavigationExpansionExpression source) : orderingMethod; var keyPropertyLambda = GenerateLambda( - navigationTreeExpression.CreateEFPropertyExpression(primaryKeyProperties[i], entityReference.IsOptional), + navigationTreeExpression.CreateEFPropertyExpression( + primaryKeyProperties[i], entityReference.IsOptional), source.CurrentParameter); source.UpdateSource( @@ -1458,11 +1479,11 @@ private MethodCallExpression ConvertToEnumerable(MethodInfo queryableMethod, IEn ? queryableMethod.GetGenericArguments() : null; var enumerableArguments = arguments.Select( - arg => arg is UnaryExpression unaryExpression - && unaryExpression.NodeType == ExpressionType.Quote - && unaryExpression.Operand is LambdaExpression - ? unaryExpression.Operand - : arg) + arg => arg is UnaryExpression unaryExpression + && unaryExpression.NodeType == ExpressionType.Quote + && unaryExpression.Operand is LambdaExpression + ? unaryExpression.Operand + : arg) .ToList(); if (queryableMethod.Name == nameof(Enumerable.Min)) @@ -1573,7 +1594,9 @@ static bool IsNumericType(Type type) } } - private NavigationExpansionExpression CreateNavigationExpansionExpression([NotNull] Expression sourceExpression, [NotNull] IEntityType entityType) + private NavigationExpansionExpression CreateNavigationExpansionExpression( + [NotNull] Expression sourceExpression, + [NotNull] IEntityType entityType) { var entityReference = new EntityReference(entityType); PopulateEagerLoadedNavigations(entityReference.IncludePaths); @@ -1585,7 +1608,8 @@ private NavigationExpansionExpression CreateNavigationExpansionExpression([NotNu } private NavigationExpansionExpression CreateNavigationExpansionExpression( - Expression sourceExpression, OwnedNavigationReference ownedNavigationReference) + Expression sourceExpression, + OwnedNavigationReference ownedNavigationReference) { var parameterName = GetParameterName("o"); var entityReference = ownedNavigationReference.EntityReference; @@ -1664,12 +1688,12 @@ private Expression UnwrapCollectionMaterialization(Expression expression) return expression is OwnedNavigationReference ownedNavigationReference && ownedNavigationReference.Navigation.IsCollection - ? CreateNavigationExpansionExpression( - Expression.Call( - QueryableMethods.AsQueryable.MakeGenericMethod(ownedNavigationReference.Type.TryGetSequenceType()), - ownedNavigationReference), - ownedNavigationReference) - : expression; + ? CreateNavigationExpansionExpression( + Expression.Call( + QueryableMethods.AsQueryable.MakeGenericMethod(ownedNavigationReference.Type.TryGetSequenceType()), + ownedNavigationReference), + ownedNavigationReference) + : expression; } private string GetParameterName(string prefix) @@ -1757,7 +1781,8 @@ private IncludeTreeNode PopulateIncludeTree(IncludeTreeNode includeTreeNode, Exp return null; } - private Expression Reduce(Expression source) => _reducingExpressionVisitor.Visit(source); + private Expression Reduce(Expression source) + => _reducingExpressionVisitor.Visit(source); private Expression SnapshotExpression(Expression selector) { @@ -1818,7 +1843,8 @@ private sealed class Parameters : IParameterValues { private readonly IDictionary _parameterValues = new Dictionary(); - public IReadOnlyDictionary ParameterValues => (IReadOnlyDictionary)_parameterValues; + public IReadOnlyDictionary ParameterValues + => (IReadOnlyDictionary)_parameterValues; public void AddParameter(string name, object value) { diff --git a/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs b/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs index a7e1802cfa2..bedbb7b1b3d 100644 --- a/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/ParameterExtractingExpressionVisitor.cs @@ -351,8 +351,8 @@ public ContextParameterReplacingExpressionVisitor(Type contextType) public override Expression Visit(Expression expression) => expression?.Type != typeof(object) && expression?.Type.IsAssignableFrom(_contextType) == true - ? ContextParameterExpression - : base.Visit(expression); + ? ContextParameterExpression + : base.Visit(expression); } private static Expression RemoveConvert(Expression expression) @@ -466,7 +466,9 @@ private sealed class EvaluatableExpressionFindingExpressionVisitor : ExpressionV private IDictionary _evaluatableExpressions; public EvaluatableExpressionFindingExpressionVisitor( - IEvaluatableExpressionFilter evaluatableExpressionFilter, IModel model, bool parameterize) + IEvaluatableExpressionFilter evaluatableExpressionFilter, + IModel model, + bool parameterize) { _evaluatableExpressionFilter = evaluatableExpressionFilter; _model = model; @@ -627,7 +629,7 @@ protected override Expression VisitConstant(ConstantExpression constantExpressio private static bool IsEvaluatableNodeType(Expression expression) => expression.NodeType != ExpressionType.Extension || expression.CanReduce - && IsEvaluatableNodeType(expression.ReduceAndCheck()); + && IsEvaluatableNodeType(expression.ReduceAndCheck()); private static bool IsQueryableMethod(Expression expression) => expression is MethodCallExpression methodCallExpression diff --git a/src/EFCore/Query/Internal/QueryDebugView.cs b/src/EFCore/Query/Internal/QueryDebugView.cs index afeddb6b97b..fd4630a655a 100644 --- a/src/EFCore/Query/Internal/QueryDebugView.cs +++ b/src/EFCore/Query/Internal/QueryDebugView.cs @@ -41,7 +41,8 @@ public QueryDebugView( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual string Expression => _toExpressionString(); + public virtual string Expression + => _toExpressionString(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -49,6 +50,7 @@ public QueryDebugView( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual string Query => _toQueryString(); + public virtual string Query + => _toQueryString(); } } diff --git a/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs b/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs index 63c0d982773..8a0d88758a6 100644 --- a/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs @@ -19,10 +19,13 @@ public class QueryOptimizingExpressionVisitor : ExpressionVisitor { private static readonly MethodInfo _stringCompareWithComparisonMethod = typeof(string).GetRuntimeMethod(nameof(string.Compare), new[] { typeof(string), typeof(string), typeof(StringComparison) }); + private static readonly MethodInfo _stringCompareWithoutComparisonMethod = typeof(string).GetRuntimeMethod(nameof(string.Compare), new[] { typeof(string), typeof(string) }); + private static readonly MethodInfo _startsWithMethodInfo = typeof(string).GetRuntimeMethod(nameof(string.StartsWith), new[] { typeof(string) }); + private static readonly MethodInfo _endsWithMethodInfo = typeof(string).GetRuntimeMethod(nameof(string.EndsWith), new[] { typeof(string) }); @@ -262,7 +265,7 @@ private Expression TryOptimizeMemberAccessOverConditional(Expression expression) if (isLeftNullConstant != isRightNullConstant && ((binaryTest.NodeType == ExpressionType.Equal - && IsNullConstant(conditionalExpression.IfTrue)) + && IsNullConstant(conditionalExpression.IfTrue)) || (binaryTest.NodeType == ExpressionType.NotEqual && IsNullConstant(conditionalExpression.IfFalse)))) { @@ -279,6 +282,7 @@ private Expression TryOptimizeMemberAccessOverConditional(Expression expression) { nonNullExpression = Expression.Convert(nonNullExpression, nonNullExpression.Type.MakeNullable()); } + var nullExpression = Expression.Constant(null, nonNullExpression.Type); return Expression.Condition( diff --git a/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs b/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs index 8ee95d39cdf..713dcc4a923 100644 --- a/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs @@ -24,6 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal public class QueryableMethodNormalizingExpressionVisitor : ExpressionVisitor { private readonly QueryCompilationContext _queryCompilationContext; + private readonly SelectManyVerifyingExpressionVisitor _selectManyVerifyingExpressionVisitor = new SelectManyVerifyingExpressionVisitor(); @@ -143,6 +144,7 @@ private void VerifyReturnType(Expression expression, ParameterExpression lambdaP { VerifyReturnType(argument, lambdaParameter); } + break; case MemberInitExpression memberInitExpression: @@ -154,17 +156,19 @@ private void VerifyReturnType(Expression expression, ParameterExpression lambdaP VerifyReturnType(memberAssignment.Expression, lambdaParameter); } } + break; default: if (expression.Type.TryGetElementType(typeof(IOrderedEnumerable<>)) != null - || expression.Type.TryGetElementType(typeof(IQueryable<>)) != null) + || expression.Type.TryGetElementType(typeof(IQueryable<>)) != null) { throw new InvalidOperationException( CoreStrings.QueryInvalidMaterializationType( new ExpressionPrinter().Print(Expression.Lambda(expression, lambdaParameter)), expression.Type.ShortDisplayName())); } + break; } } @@ -383,7 +387,7 @@ private static bool ClientSource(Expression expression) || expression is MemberInitExpression || expression is NewExpression || expression is ParameterExpression parameter - && parameter.Name?.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal) == true; + && parameter.Name?.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal) == true; private static bool CanConvertEnumerableToQueryable(Type enumerableType, Type queryableType) { @@ -450,8 +454,9 @@ private Expression TryFlattenGroupJoinSelectMany(MethodCallExpression methodCall if (!correlatedCollectionSelector) { - inner = Visit(ReplacingExpressionVisitor.Replace( - groupJoinResultSelector.Parameters[1], inner, collectionSelectorBody)); + inner = Visit( + ReplacingExpressionVisitor.Replace( + groupJoinResultSelector.Parameters[1], inner, collectionSelectorBody)); if (inner is MethodCallExpression innerMethodCall && innerMethodCall.Method.IsGenericMethod diff --git a/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs b/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs index 764242ee7c1..4ec711c9f81 100644 --- a/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/SubqueryMemberPushdownExpressionVisitor.cs @@ -149,8 +149,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp var indexerExpression = Expression.Call( target, - methodCallExpression.Method, - new[] { methodCallExpression.Arguments[0] }); + methodCallExpression.Method, methodCallExpression.Arguments[0]); return nullable && !indexerExpression.Type.IsNullableType() ? Expression.Convert(indexerExpression, indexerExpression.Type.MakeNullable()) @@ -176,7 +175,9 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp } private Expression PushdownMember( - MethodCallExpression methodCallExpression, Func createSelector, Type returnType) + MethodCallExpression methodCallExpression, + Func createSelector, + Type returnType) { var source = methodCallExpression.Arguments[0]; var queryableType = source.Type.TryGetSequenceType(); @@ -198,7 +199,8 @@ private Expression PushdownMember( { var selector = sourceMethodCallExpression.Arguments[1].UnwrapLambdaFromQuote(); var selectorBody = selector.Body; - var memberAccessExpression = createSelector(selectorBody, methodCallExpression.Method.Name.EndsWith("OrDefault", StringComparison.Ordinal)); + var memberAccessExpression = createSelector( + selectorBody, methodCallExpression.Method.Name.EndsWith("OrDefault", StringComparison.Ordinal)); source = Expression.Call( QueryableMethods.Select.MakeGenericMethod( @@ -211,7 +213,8 @@ private Expression PushdownMember( else { var parameter = Expression.Parameter(queryableType, "s"); - var memberAccessExpression = createSelector(parameter, methodCallExpression.Method.Name.EndsWith("OrDefault", StringComparison.Ordinal)); + var memberAccessExpression = createSelector( + parameter, methodCallExpression.Method.Name.EndsWith("OrDefault", StringComparison.Ordinal)); source = Expression.Call( QueryableMethods.Select.MakeGenericMethod(queryableType, memberAccessExpression.Type), diff --git a/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs b/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs index 60f41f3b591..9e2b910296e 100644 --- a/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs +++ b/src/EFCore/Query/MaterializeCollectionNavigationExpression.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query { /// /// - /// An expression that represents materialization of a collection navigation in . + /// An expression that represents materialization of a collection navigation in . /// /// /// This type is typically used by database providers (and other extensions). It is generally @@ -38,15 +38,19 @@ public MaterializeCollectionNavigationExpression([NotNull] Expression subquery, /// The expression that returns the values from query used to create the collection. /// public virtual Expression Subquery { get; } + /// /// The navigation associated with this collection. /// public virtual INavigationBase Navigation { get; } /// - public sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; + /// - public override Type Type => Navigation.ClrType; + public override Type Type + => Navigation.ClrType; /// protected override Expression VisitChildren(ExpressionVisitor visitor) @@ -60,7 +64,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. /// - /// The property of the result. + /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual MaterializeCollectionNavigationExpression Update([NotNull] Expression subquery) { diff --git a/src/EFCore/Query/ProjectionBindingExpression.cs b/src/EFCore/Query/ProjectionBindingExpression.cs index f4317efe07c..669f5d07555 100644 --- a/src/EFCore/Query/ProjectionBindingExpression.cs +++ b/src/EFCore/Query/ProjectionBindingExpression.cs @@ -13,8 +13,8 @@ namespace Microsoft.EntityFrameworkCore.Query { /// /// - /// An expression that gets values from to be used in - /// while creating results. + /// An expression that gets values from to be used in + /// while creating results. /// /// /// This type is typically used by database providers (and other extensions). It is generally @@ -83,22 +83,28 @@ public ProjectionBindingExpression( /// The query expression to bind with. /// public virtual Expression QueryExpression { get; } + /// /// The projection member to bind if binding is via projection member. /// public virtual ProjectionMember ProjectionMember { get; } + /// /// The projection member to bind if binding is via projection index. /// public virtual int? Index { get; } + /// /// The projection member to bind if binding is via index map for a value buffer. /// public virtual IDictionary IndexMap { get; } + /// public override Type Type { get; } + /// - public sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// protected override Expression VisitChildren(ExpressionVisitor visitor) @@ -151,6 +157,7 @@ private bool Equals(ProjectionBindingExpression projectionBindingExpression) && IndexMap == projectionBindingExpression.IndexMap; /// - public override int GetHashCode() => HashCode.Combine(QueryExpression, ProjectionMember, Index, IndexMap); + public override int GetHashCode() + => HashCode.Combine(QueryExpression, ProjectionMember, Index, IndexMap); } } diff --git a/src/EFCore/Query/ProjectionMember.cs b/src/EFCore/Query/ProjectionMember.cs index b6f87b5c5d7..6d520c703a7 100644 --- a/src/EFCore/Query/ProjectionMember.cs +++ b/src/EFCore/Query/ProjectionMember.cs @@ -78,7 +78,8 @@ public ProjectionMember Prepend([NotNull] MemberInfo member) /// This method is generally used to get last memberInfo to generate an alias for projection. /// /// - public MemberInfo Last => _memberChain.LastOrDefault(); + public MemberInfo Last + => _memberChain.LastOrDefault(); /// public override int GetHashCode() diff --git a/src/EFCore/Query/QueryCompilationContext.cs b/src/EFCore/Query/QueryCompilationContext.cs index 6dfd33bac2b..0f1723eb0ff 100644 --- a/src/EFCore/Query/QueryCompilationContext.cs +++ b/src/EFCore/Query/QueryCompilationContext.cs @@ -38,7 +38,7 @@ public class QueryCompilationContext /// /// - /// ParameterExpression representing parameter in query expression. + /// ParameterExpression representing parameter in query expression. /// /// /// This property is typically used by database providers (and other extensions). It is generally @@ -98,13 +98,14 @@ public QueryCompilationContext( /// The model to use during query compilation. /// public virtual IModel Model { get; } + /// /// The ContextOptions to use during query compilation. /// public virtual IDbContextOptions ContextOptions { get; } /// - /// A value indicating of the query. + /// A value indicating of the query. /// public virtual QueryTrackingBehavior QueryTrackingBehavior { get; internal set; } @@ -112,35 +113,41 @@ public QueryCompilationContext( /// A value indicating whether it is tracking query. /// [Obsolete("Use " + nameof(QueryTrackingBehavior) + " instead.")] - public virtual bool IsTracking => QueryTrackingBehavior == QueryTrackingBehavior.TrackAll; + public virtual bool IsTracking + => QueryTrackingBehavior == QueryTrackingBehavior.TrackAll; /// /// A value indicating whether the underlying server query needs to pre-buffer all data. /// public virtual bool IsBuffering { get; } + /// /// A value indicating whether query filters are ignored in this query. /// public virtual bool IgnoreQueryFilters { get; internal set; } + /// /// A value indicating whether eager loaded navigations are ignored in this query. /// public virtual bool IgnoreAutoIncludes { get; internal set; } + /// /// The set of tags applied to this query. /// public virtual ISet Tags { get; } = new HashSet(); + /// /// The query logger to use during query compilation. /// public virtual IDiagnosticsLogger Logger { get; } + /// /// The CLR type of derived DbContext to use during query compilation. /// public virtual Type ContextType { get; } /// - /// Adds a tag to . + /// Adds a tag to . /// /// The tag to add. public virtual void AddTag([NotNull] string tag) @@ -155,7 +162,7 @@ public virtual void AddTag([NotNull] string tag) /// /// The result type of this query. /// The query to generate executor for. - /// Returns which can be invoked to get results of this query. + /// Returns which can be invoked to get results of this query. public virtual Func CreateQueryExecutor([NotNull] Expression query) { Check.NotNull(query, nameof(query)); diff --git a/src/EFCore/Query/QueryCompilationContextDependencies.cs b/src/EFCore/Query/QueryCompilationContextDependencies.cs index 2d52a39727f..e2b466c47b1 100644 --- a/src/EFCore/Query/QueryCompilationContextDependencies.cs +++ b/src/EFCore/Query/QueryCompilationContextDependencies.cs @@ -96,12 +96,14 @@ public QueryCompilationContextDependencies( /// /// The CLR type of DbContext. /// - public Type ContextType => _currentContext.Context.GetType(); + public Type ContextType + => _currentContext.Context.GetType(); /// /// The default query tracking behavior. /// - public QueryTrackingBehavior QueryTrackingBehavior => _currentContext.Context.ChangeTracker.QueryTrackingBehavior; + public QueryTrackingBehavior QueryTrackingBehavior + => _currentContext.Context.ChangeTracker.QueryTrackingBehavior; /// /// The model. diff --git a/src/EFCore/Query/QueryContext.cs b/src/EFCore/Query/QueryContext.cs index c0da585f905..dbe61d7d497 100644 --- a/src/EFCore/Query/QueryContext.cs +++ b/src/EFCore/Query/QueryContext.cs @@ -51,7 +51,8 @@ protected QueryContext( /// /// The current DbContext in using while executing the query. /// - public virtual DbContext Context => Dependencies.CurrentContext.Context; + public virtual DbContext Context + => Dependencies.CurrentContext.Context; /// /// Parameter object containing dependencies for this service. @@ -114,7 +115,7 @@ public virtual IReadOnlyDictionary ParameterValues => (IReadOnlyDictionary)_parameterValues; /// - /// Adds a parameter to for this query. + /// Adds a parameter to for this query. /// /// The name. /// The value. @@ -126,9 +127,9 @@ public virtual void AddParameter(string name, object value) } /// - /// Initializes the to be used with this QueryContext. + /// Initializes the to be used with this QueryContext. /// - /// Whether a stand-alone should be created to perform identity resolution. + /// Whether a stand-alone should be created to perform identity resolution. public virtual void InitializeStateManager(bool standAlone = false) { if (_stateManager != null) diff --git a/src/EFCore/Query/QueryContextDependencies.cs b/src/EFCore/Query/QueryContextDependencies.cs index 1a3d2f05ee2..b666d156474 100644 --- a/src/EFCore/Query/QueryContextDependencies.cs +++ b/src/EFCore/Query/QueryContextDependencies.cs @@ -91,13 +91,15 @@ public QueryContextDependencies( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [EntityFrameworkInternal] - public IStateManager StateManager => CurrentContext.GetDependencies().StateManager; + public IStateManager StateManager + => CurrentContext.GetDependencies().StateManager; /// /// Gets the query provider. /// [Obsolete("Use the service by getting it from " + nameof(CurrentContext) + ".")] - public IQueryProvider QueryProvider => CurrentContext.GetDependencies().QueryProvider; + public IQueryProvider QueryProvider + => CurrentContext.GetDependencies().QueryProvider; /// /// The execution strategy. @@ -126,6 +128,7 @@ public QueryContextDependencies( /// A new parameter object with the given service replaced. public QueryContextDependencies With([NotNull] ICurrentDbContext currentContext) => new QueryContextDependencies(currentContext, ExecutionStrategyFactory, ConcurrencyDetector, CommandLogger, QueryLogger); + /// /// Clones this dependency parameter object with one service replaced. /// diff --git a/src/EFCore/Query/QueryRootExpression.cs b/src/EFCore/Query/QueryRootExpression.cs index 62256cfdc5d..f180cf39bcb 100644 --- a/src/EFCore/Query/QueryRootExpression.cs +++ b/src/EFCore/Query/QueryRootExpression.cs @@ -22,8 +22,6 @@ namespace Microsoft.EntityFrameworkCore.Query /// public class QueryRootExpression : Expression, IPrintableExpression { - private readonly Type _type; - /// /// Creates a new instance of the class with associated query provider. /// @@ -36,7 +34,7 @@ public QueryRootExpression([NotNull] IAsyncQueryProvider asyncQueryProvider, [No QueryProvider = asyncQueryProvider; EntityType = entityType; - _type = typeof(IQueryable<>).MakeGenericType(entityType.ClrType); + Type = typeof(IQueryable<>).MakeGenericType(entityType.ClrType); } /// @@ -49,7 +47,7 @@ public QueryRootExpression([NotNull] IEntityType entityType) EntityType = entityType; QueryProvider = null; - _type = typeof(IQueryable<>).MakeGenericType(entityType.ClrType); + Type = typeof(IQueryable<>).MakeGenericType(entityType.ClrType); } /// @@ -66,18 +64,26 @@ public QueryRootExpression([NotNull] IEntityType entityType) /// Detaches the associated query provider from this query root expression. /// /// A new query root expression without query provider. - public virtual Expression DetachQueryProvider() => new QueryRootExpression(EntityType); + public virtual Expression DetachQueryProvider() + => new QueryRootExpression(EntityType); + /// - public override ExpressionType NodeType => ExpressionType.Extension; + public override ExpressionType NodeType + => ExpressionType.Extension; + /// - public override Type Type => _type; + public override Type Type { get; } + /// - public override bool CanReduce => false; + public override bool CanReduce + => false; + /// - protected override Expression VisitChildren(ExpressionVisitor visitor) => this; + protected override Expression VisitChildren(ExpressionVisitor visitor) + => this; /// - /// Creates a printable string representation of the given expression using . + /// Creates a printable string representation of the given expression using . /// /// The expression printer to use. protected virtual void Print([NotNull] ExpressionPrinter expressionPrinter) @@ -95,16 +101,18 @@ protected virtual void Print([NotNull] ExpressionPrinter expressionPrinter) } /// - void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) => Print(expressionPrinter); + void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) + => Print(expressionPrinter); /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is QueryRootExpression queryRootExpression + && (ReferenceEquals(this, obj) + || obj is QueryRootExpression queryRootExpression && EntityType == queryRootExpression.EntityType); /// - public override int GetHashCode() => EntityType.GetHashCode(); + public override int GetHashCode() + => EntityType.GetHashCode(); } } diff --git a/src/EFCore/Query/QueryTranslationPreprocessor.cs b/src/EFCore/Query/QueryTranslationPreprocessor.cs index 5b27453c70a..d819ec8f3ac 100644 --- a/src/EFCore/Query/QueryTranslationPreprocessor.cs +++ b/src/EFCore/Query/QueryTranslationPreprocessor.cs @@ -80,6 +80,6 @@ public virtual Expression Process([NotNull] Expression query) /// A query expression after normalization has been done. public virtual Expression NormalizeQueryableMethod([NotNull] Expression expression) => new QueryableMethodNormalizingExpressionVisitor(QueryCompilationContext) - .Visit(Check.NotNull(expression, nameof(expression))); + .Visit(Check.NotNull(expression, nameof(expression))); } } diff --git a/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs index 4a1a8721ab8..088298656af 100644 --- a/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs @@ -102,12 +102,13 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp ShapedQueryExpression CheckTranslated(ShapedQueryExpression translated) { - return translated ?? throw new InvalidOperationException( - TranslationErrorDetails == null - ? CoreStrings.TranslationFailed(methodCallExpression.Print()) - : CoreStrings.TranslationFailedWithDetails( - methodCallExpression.Print(), - TranslationErrorDetails)); + return translated + ?? throw new InvalidOperationException( + TranslationErrorDetails == null + ? CoreStrings.TranslationFailed(methodCallExpression.Print()) + : CoreStrings.TranslationFailedWithDetails( + methodCallExpression.Print(), + TranslationErrorDetails)); } var method = methodCallExpression.Method; @@ -485,8 +486,8 @@ when QueryableMethods.IsSumWithSelector(method): when genericMethod == QueryableMethods.Where: return CheckTranslated(TranslateWhere(shapedQueryExpression, GetLambdaExpressionFromArgument(1))); - LambdaExpression GetLambdaExpressionFromArgument(int argumentIndex) => - methodCallExpression.Arguments[argumentIndex].UnwrapLambdaFromQuote(); + LambdaExpression GetLambdaExpressionFromArgument(int argumentIndex) + => methodCallExpression.Arguments[argumentIndex].UnwrapLambdaFromQuote(); } } } @@ -521,9 +522,12 @@ protected virtual Expression MarkShaperNullable([NotNull] Expression shaperExpre } /// - /// Translates the result selector for join operation. + /// Translates the result selector for join operation. /// - /// The shaped query expression for outer source. The join on the query expression is already performed on outer query expression. + /// + /// The shaped query expression for outer source. The join on the query expression is already performed on outer query + /// expression. + /// /// The result selector lambda to translate. /// The shaper for inner source. /// The clr type of transparent identifier created from result. @@ -551,7 +555,7 @@ protected virtual ShapedQueryExpression TranslateResultSelectorForJoin( var replacement2 = AccessInnerTransparentField(transparentIdentifierType, transparentIdentifierParameter); var newResultSelector = Expression.Lambda( new ReplacingExpressionVisitor( - new[] { original1, original2 }, new[] { replacement1, replacement2 }) + new[] { original1, original2 }, new[] { replacement1, replacement2 }) .Visit(resultSelector.Body), transparentIdentifierParameter); @@ -640,27 +644,28 @@ public virtual ShapedQueryExpression TranslateSubquery([NotNull] Expression expr } /// - /// Creates a visitor customized to translate a subquery through . + /// Creates a visitor customized to translate a subquery through . /// /// A visitor to translate subquery. protected abstract QueryableMethodTranslatingExpressionVisitor CreateSubqueryVisitor(); /// - /// Creates a for the given type by finding its entity type in the model. + /// Creates a for the given type by finding its entity type in the model. /// /// The clr type of the entity type to look for. /// A shaped query expression for the given clr type. [Obsolete("Use overload which takes IEntityType.")] protected abstract ShapedQueryExpression CreateShapedQueryExpression([NotNull] Type elementType); + /// - /// Creates a for the given entity type. + /// Creates a for the given entity type. /// /// The the entity type. /// A shaped query expression for the given entity type. protected abstract ShapedQueryExpression CreateShapedQueryExpression([NotNull] IEntityType entityType); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. @@ -668,25 +673,29 @@ public virtual ShapedQueryExpression TranslateSubquery([NotNull] Expression expr protected abstract ShapedQueryExpression TranslateAll([NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression predicate); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. /// The shaped query after translation. - protected abstract ShapedQueryExpression TranslateAny([NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression predicate); + protected abstract ShapedQueryExpression TranslateAny( + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression predicate); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The selector supplied in the call. /// The result type after the operation. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateAverage( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression selector, [NotNull] Type resultType); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression selector, + [NotNull] Type resultType); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The type result is being casted to. @@ -694,16 +703,17 @@ protected abstract ShapedQueryExpression TranslateAverage( protected abstract ShapedQueryExpression TranslateCast([NotNull] ShapedQueryExpression source, [NotNull] Type castType); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The other source to perform concat. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateConcat( - [NotNull] ShapedQueryExpression source1, [NotNull] ShapedQueryExpression source2); + [NotNull] ShapedQueryExpression source1, + [NotNull] ShapedQueryExpression source2); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The item to search for. @@ -711,53 +721,58 @@ protected abstract ShapedQueryExpression TranslateConcat( protected abstract ShapedQueryExpression TranslateContains([NotNull] ShapedQueryExpression source, [NotNull] Expression item); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateCount( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression predicate); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression predicate); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The default value to use. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateDefaultIfEmpty( - [NotNull] ShapedQueryExpression source, [CanBeNull] Expression defaultValue); + [NotNull] ShapedQueryExpression source, + [CanBeNull] Expression defaultValue); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateDistinct([NotNull] ShapedQueryExpression source); /// - /// Translates method or - /// over the given source. + /// Translates method or + /// over the given source. /// /// The shaped query on which the operator is applied. /// The index of the element. /// A value indicating whether default should be returned or throw. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateElementAtOrDefault( - [NotNull] ShapedQueryExpression source, [NotNull] Expression index, bool returnDefault); + [NotNull] ShapedQueryExpression source, + [NotNull] Expression index, + bool returnDefault); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The other source to perform except with. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateExcept( - [NotNull] ShapedQueryExpression source1, [NotNull] ShapedQueryExpression source2); + [NotNull] ShapedQueryExpression source1, + [NotNull] ShapedQueryExpression source2); /// - /// Translates method or - /// and their other overloads over the given source. + /// Translates method or + /// and their other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. @@ -765,10 +780,13 @@ protected abstract ShapedQueryExpression TranslateExcept( /// A value indicating whether default should be returned or throw. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateFirstOrDefault( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression predicate, [NotNull] Type returnType, bool returnDefault); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression predicate, + [NotNull] Type returnType, + bool returnDefault); /// - /// Translates method and + /// Translates method and /// other overlods over the given source. /// /// The shaped query on which the operator is applied. @@ -783,7 +801,10 @@ protected abstract ShapedQueryExpression TranslateGroupBy( [CanBeNull] LambdaExpression resultSelector); /// - /// Translates method over the given source. + /// Translates + /// + /// method over the given source. /// /// The shaped query on which the operator is applied. /// The inner shaped query to perform join with. @@ -799,16 +820,20 @@ protected abstract ShapedQueryExpression TranslateGroupJoin( [NotNull] LambdaExpression resultSelector); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The other source to perform intersect with. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateIntersect( - [NotNull] ShapedQueryExpression source1, [NotNull] ShapedQueryExpression source2); + [NotNull] ShapedQueryExpression source1, + [NotNull] ShapedQueryExpression source2); /// - /// Translates method over the given source. + /// Translates + /// + /// method over the given source. /// /// The shaped query on which the operator is applied. /// The inner shaped query to perform join with. @@ -846,8 +871,8 @@ protected abstract ShapedQueryExpression TranslateLeftJoin( [NotNull] LambdaExpression resultSelector); /// - /// Translates method or - /// and their other overloads over the given source. + /// Translates method or + /// and their other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. @@ -855,39 +880,47 @@ protected abstract ShapedQueryExpression TranslateLeftJoin( /// A value indicating whether default should be returned or throw. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateLastOrDefault( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression predicate, [NotNull] Type returnType, bool returnDefault); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression predicate, + [NotNull] Type returnType, + bool returnDefault); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateLongCount( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression predicate); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression predicate); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The selector supplied in the call. /// The result type after the operation. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateMax( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression selector, [NotNull] Type resultType); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression selector, + [NotNull] Type resultType); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The selector supplied in the call. /// The result type after the operation. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateMin( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression selector, [NotNull] Type resultType); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression selector, + [NotNull] Type resultType); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The type of result which is being filtered with. @@ -895,8 +928,8 @@ protected abstract ShapedQueryExpression TranslateMin( protected abstract ShapedQueryExpression TranslateOfType([NotNull] ShapedQueryExpression source, [NotNull] Type resultType); /// - /// Translates or - /// method + /// Translates or + /// method /// over the given source. /// /// The shaped query on which the operator is applied. @@ -904,46 +937,57 @@ protected abstract ShapedQueryExpression TranslateMin( /// A value indicating whether the ordering is ascending or not. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateOrderBy( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression keySelector, bool ascending); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression keySelector, + bool ascending); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateReverse([NotNull] ShapedQueryExpression source); /// - /// Translates method over the given source. + /// Translates method over the + /// given source. /// /// The shaped query on which the operator is applied. /// The selector supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateSelect( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression selector); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression selector); /// - /// Translates method over the given source. + /// Translates + /// + /// method over the given source. /// /// The shaped query on which the operator is applied. /// The collection selector supplied in the call. /// The result selector supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateSelectMany( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression collectionSelector, [NotNull] LambdaExpression resultSelector); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression collectionSelector, + [NotNull] LambdaExpression resultSelector); /// - /// Translates method over the given source. + /// Translates + /// method over the given source. /// /// The shaped query on which the operator is applied. /// The selector supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateSelectMany( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression selector); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression selector); /// - /// Translates method or - /// and their other + /// Translates method or + /// and their other /// overloads over the given source. /// /// The shaped query on which the operator is applied. @@ -952,38 +996,46 @@ protected abstract ShapedQueryExpression TranslateSelectMany( /// A value indicating whether default should be returned or throw. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateSingleOrDefault( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression predicate, [NotNull] Type returnType, bool returnDefault); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression predicate, + [NotNull] Type returnType, + bool returnDefault); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The count supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateSkip( - [NotNull] ShapedQueryExpression source, [NotNull] Expression count); + [NotNull] ShapedQueryExpression source, + [NotNull] Expression count); /// - /// Translates method over the given source. + /// Translates method over the given + /// source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateSkipWhile( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression predicate); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression predicate); /// - /// Translates method and other overloads over the given source. + /// Translates method and other overloads over the given source. /// /// The shaped query on which the operator is applied. /// The selector supplied in the call. /// The result type after the operation. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateSum( - [NotNull] ShapedQueryExpression source, [CanBeNull] LambdaExpression selector, [NotNull] Type resultType); + [NotNull] ShapedQueryExpression source, + [CanBeNull] LambdaExpression selector, + [NotNull] Type resultType); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The count supplied in the call. @@ -991,17 +1043,19 @@ protected abstract ShapedQueryExpression TranslateSum( protected abstract ShapedQueryExpression TranslateTake([NotNull] ShapedQueryExpression source, [NotNull] Expression count); /// - /// Translates method over the given source. + /// Translates method over the given + /// source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateTakeWhile( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression predicate); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression predicate); /// - /// Translates or - /// method + /// Translates or + /// method /// over the given source. /// /// The shaped query on which the operator is applied. @@ -1009,24 +1063,28 @@ protected abstract ShapedQueryExpression TranslateTakeWhile( /// A value indicating whether the ordering is ascending or not. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateThenBy( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression keySelector, bool ascending); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression keySelector, + bool ascending); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The other source to perform union with. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateUnion( - [NotNull] ShapedQueryExpression source1, [NotNull] ShapedQueryExpression source2); + [NotNull] ShapedQueryExpression source1, + [NotNull] ShapedQueryExpression source2); /// - /// Translates method over the given source. + /// Translates method over the given source. /// /// The shaped query on which the operator is applied. /// The predicate supplied in the call. /// The shaped query after translation. protected abstract ShapedQueryExpression TranslateWhere( - [NotNull] ShapedQueryExpression source, [NotNull] LambdaExpression predicate); + [NotNull] ShapedQueryExpression source, + [NotNull] LambdaExpression predicate); } } diff --git a/src/EFCore/Query/QueryableMethods.cs b/src/EFCore/Query/QueryableMethods.cs index 0eea009dd84..96a0bcf81a5 100644 --- a/src/EFCore/Query/QueryableMethods.cs +++ b/src/EFCore/Query/QueryableMethods.cs @@ -78,7 +78,8 @@ public static class QueryableMethods public static MethodInfo CountWithoutPredicate { get; } /// - /// The for + /// The for + /// /// public static MethodInfo CountWithPredicate { get; } diff --git a/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs b/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs index 4501fcfa7ca..f132f729cfc 100644 --- a/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs +++ b/src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs @@ -12,7 +12,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; @@ -175,7 +174,6 @@ private static async Task SingleOrDefaultAsync( return result; } - /// /// Visits given shaped query expression to create an expression of enumerable. /// @@ -184,7 +182,7 @@ private static async Task SingleOrDefaultAsync( protected abstract Expression VisitShapedQuery([NotNull] ShapedQueryExpression shapedQueryExpression); /// - /// Inject entity materializers in given shaper expression. is replaced with materializer + /// Inject entity materializers in given shaper expression. is replaced with materializer /// expression for given entity. /// /// The expression to inject entity materializers. @@ -223,7 +221,7 @@ private bool ValidConstant(ConstantExpression constantExpression) return constantExpression.Value == null || _typeMappingSource.FindMapping(constantExpression.Type) != null || constantExpression.Value is Array array - && array.Length == 0; + && array.Length == 0; } protected override Expression VisitConstant(ConstantExpression constantExpression) @@ -449,20 +447,23 @@ private Expression ProcessEntityShaper(EntityShaperExpression entityShaperExpres { if (primaryKey != null) { - expressions.Add(Expression.IfThen( - primaryKey.Properties.Select( - p => Expression.NotEqual( - valueBufferExpression.CreateValueBufferReadValueExpression(typeof(object), p.GetIndex(), p), - Expression.Constant(null))) - .Aggregate((a, b) => Expression.AndAlso(a, b)), - MaterializeEntity( - entityShaperExpression, materializationContextVariable, concreteEntityTypeVariable, instanceVariable, null))); + expressions.Add( + Expression.IfThen( + primaryKey.Properties.Select( + p => Expression.NotEqual( + valueBufferExpression.CreateValueBufferReadValueExpression(typeof(object), p.GetIndex(), p), + Expression.Constant(null))) + .Aggregate((a, b) => Expression.AndAlso(a, b)), + MaterializeEntity( + entityShaperExpression, materializationContextVariable, concreteEntityTypeVariable, instanceVariable, + null))); } else { expressions.Add( MaterializeEntity( - entityShaperExpression, materializationContextVariable, concreteEntityTypeVariable, instanceVariable, null)); + entityShaperExpression, materializationContextVariable, concreteEntityTypeVariable, instanceVariable, + null)); } } @@ -496,7 +497,8 @@ private Expression MaterializeEntity( var valueBufferExpression = Expression.Call(materializationContextVariable, MaterializationContext.GetValueBufferMethod); var expressionContext = (returnType, materializationContextVariable, concreteEntityTypeVariable, shadowValuesVariable); expressions.Add( - Expression.Assign(concreteEntityTypeVariable, + Expression.Assign( + concreteEntityTypeVariable, ReplacingExpressionVisitor.Replace( entityShaperExpression.MaterializationCondition.Parameters[0], valueBufferExpression, @@ -580,7 +582,8 @@ private BlockExpression CreateFullMaterializeExpression( Expression.NewArrayInit( typeof(object), shadowProperties.Select( - p => valueBufferExpression.CreateValueBufferReadValueExpression(typeof(object), p.GetIndex(), p)))))); + p => valueBufferExpression.CreateValueBufferReadValueExpression( + typeof(object), p.GetIndex(), p)))))); } materializer = materializer.Type == returnType diff --git a/src/EFCore/Query/ShapedQueryExpression.cs b/src/EFCore/Query/ShapedQueryExpression.cs index 4f6bc31d905..84b9545fc58 100644 --- a/src/EFCore/Query/ShapedQueryExpression.cs +++ b/src/EFCore/Query/ShapedQueryExpression.cs @@ -27,14 +27,17 @@ public class ShapedQueryExpression : Expression, IPrintableExpression /// The query expression to get results from server. /// The shaper expression to create result objects from server results. public ShapedQueryExpression([NotNull] Expression queryExpression, [NotNull] Expression shaperExpression) - : this(Check.NotNull(queryExpression, nameof(queryExpression)), - Check.NotNull(shaperExpression, nameof(shaperExpression)), - ResultCardinality.Enumerable) + : this( + Check.NotNull(queryExpression, nameof(queryExpression)), + Check.NotNull(shaperExpression, nameof(shaperExpression)), + ResultCardinality.Enumerable) { } private ShapedQueryExpression( - [NotNull] Expression queryExpression, [NotNull] Expression shaperExpression, ResultCardinality resultCardinality) + [NotNull] Expression queryExpression, + [NotNull] Expression shaperExpression, + ResultCardinality resultCardinality) { QueryExpression = queryExpression; ShaperExpression = shaperExpression; @@ -57,23 +60,26 @@ private ShapedQueryExpression( public virtual Expression ShaperExpression { get; } /// - public override Type Type => ResultCardinality == ResultCardinality.Enumerable - ? typeof(IQueryable<>).MakeGenericType(ShaperExpression.Type) - : ShaperExpression.Type; + public override Type Type + => ResultCardinality == ResultCardinality.Enumerable + ? typeof(IQueryable<>).MakeGenericType(ShaperExpression.Type) + : ShaperExpression.Type; /// - public sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// protected override Expression VisitChildren(ExpressionVisitor visitor) - => throw new InvalidOperationException(CoreStrings.VisitIsNotAllowed($"{nameof(ShapedQueryExpression)}.{nameof(VisitChildren)}")); + => throw new InvalidOperationException( + CoreStrings.VisitIsNotAllowed($"{nameof(ShapedQueryExpression)}.{nameof(VisitChildren)}")); /// /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. /// - /// The property of the result. - /// The property of the result. + /// The property of the result. + /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public virtual ShapedQueryExpression Update([NotNull] Expression queryExpression, [NotNull] Expression shaperExpression) { @@ -89,7 +95,7 @@ public virtual ShapedQueryExpression Update([NotNull] Expression queryExpression /// Creates a new expression that is like this one, but using the supplied shaper expression. If shaper expression is the same, it will /// return this expression. /// - /// The property of the result. + /// 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([NotNull] Expression shaperExpression) { @@ -103,7 +109,7 @@ public virtual ShapedQueryExpression UpdateShaperExpression([NotNull] Expression /// /// Creates a new expression that is like this one, but with supplied result cardinality. /// - /// The property of the result. + /// The property of the result. /// An expression with the updated result cardinality. public virtual ShapedQueryExpression UpdateResultCardinality(ResultCardinality resultCardinality) => new ShapedQueryExpression(QueryExpression, ShaperExpression, resultCardinality); diff --git a/src/EFCore/SaveChangesFailedEventArgs.cs b/src/EFCore/SaveChangesFailedEventArgs.cs index e83c29317b9..54ab119661e 100644 --- a/src/EFCore/SaveChangesFailedEventArgs.cs +++ b/src/EFCore/SaveChangesFailedEventArgs.cs @@ -12,7 +12,7 @@ namespace Microsoft.EntityFrameworkCore public class SaveChangesFailedEventArgs : SaveChangesEventArgs { /// - /// Creates a new instance with the exception that was thrown. + /// Creates a new instance with the exception that was thrown. /// /// The value passed to SaveChanges. /// The exception thrown. @@ -23,7 +23,7 @@ public SaveChangesFailedEventArgs(bool acceptAllChangesOnSuccess, [NotNull] Exce } /// - /// The exception thrown during or . + /// The exception thrown during or . /// public virtual Exception Exception { get; } } diff --git a/src/EFCore/Storage/CoreTypeMapping.cs b/src/EFCore/Storage/CoreTypeMapping.cs index eb53b3b96d2..b3f741ee1f6 100644 --- a/src/EFCore/Storage/CoreTypeMapping.cs +++ b/src/EFCore/Storage/CoreTypeMapping.cs @@ -64,7 +64,8 @@ public CoreTypeMappingParameters( /// Supports custom comparisons between keys--e.g. PK to FK comparison. /// Supports structural snapshotting needed for mutable reference types. /// An optional factory for creating a specific . - [Obsolete("Use overload without 'structuralComparer'. Starting with EF Core 5.0, key comparers must implement structural comparisons and deep copies.")] + [Obsolete( + "Use overload without 'structuralComparer'. Starting with EF Core 5.0, key comparers must implement structural comparisons and deep copies.")] public CoreTypeMappingParameters( [NotNull] Type clrType, [CanBeNull] ValueConverter converter, @@ -106,7 +107,8 @@ public CoreTypeMappingParameters( /// The mapping structural comparer. /// [Obsolete("Use KeyComparer. Starting with EF Core 5.0, key comparers must implement structural comparisons and deep copies.")] - public ValueComparer StructuralComparer => KeyComparer; + public ValueComparer StructuralComparer + => KeyComparer; /// /// An optional factory for creating a specific to use with @@ -173,7 +175,8 @@ protected CoreTypeMapping(CoreTypeMappingParameters parameters) /// Converts types to and from the store whenever this mapping is used. /// May be null if no conversion is needed. /// - public virtual ValueConverter Converter => Parameters.Converter; + public virtual ValueConverter Converter + => Parameters.Converter; /// /// An optional factory for creating a specific to use with diff --git a/src/EFCore/Storage/DatabaseProvider.cs b/src/EFCore/Storage/DatabaseProvider.cs index b0a2e1d7260..280ad0bb575 100644 --- a/src/EFCore/Storage/DatabaseProvider.cs +++ b/src/EFCore/Storage/DatabaseProvider.cs @@ -43,13 +43,14 @@ public DatabaseProvider([NotNull] DatabaseProviderDependencies dependencies) /// The unique name used to identify the database provider. This should be the same as the NuGet package name /// for the providers runtime. /// - public virtual string Name => typeof(TOptionsExtension).Assembly.GetName().Name; + public virtual string Name + => typeof(TOptionsExtension).Assembly.GetName().Name; /// /// Gets a value indicating whether this database provider has been selected for a given context. /// /// The options for the context. - /// if the database provider has been selected, otherwise . + /// if the database provider has been selected, otherwise . public virtual bool IsConfigured(IDbContextOptions options) => Check.NotNull(options, nameof(options)).Extensions.OfType().Any(); } diff --git a/src/EFCore/Storage/ExecutionStrategy.cs b/src/EFCore/Storage/ExecutionStrategy.cs index d7d4035c5b3..16240197fa0 100644 --- a/src/EFCore/Storage/ExecutionStrategy.cs +++ b/src/EFCore/Storage/ExecutionStrategy.cs @@ -126,7 +126,8 @@ protected static bool Suspended /// /// Indicates whether this might retry the execution after a failure. /// - public virtual bool RetriesOnFailure => !Suspended; + public virtual bool RetriesOnFailure + => !Suspended; /// /// Executes the specified operation and returns the result. @@ -391,7 +392,8 @@ protected internal virtual bool ShouldVerifySuccessOn([NotNull] Exception except /// The result from . /// public static TResult CallOnWrappedException( - [NotNull] Exception exception, [NotNull] Func exceptionHandler) + [NotNull] Exception exception, + [NotNull] Func exceptionHandler) => exception is DbUpdateException dbUpdateException ? CallOnWrappedException(dbUpdateException.InnerException, exceptionHandler) : exceptionHandler(exception); diff --git a/src/EFCore/Storage/ExecutionStrategyExtensions.cs b/src/EFCore/Storage/ExecutionStrategyExtensions.cs index 66a7b98f09e..f6e81f0ac44 100644 --- a/src/EFCore/Storage/ExecutionStrategyExtensions.cs +++ b/src/EFCore/Storage/ExecutionStrategyExtensions.cs @@ -283,7 +283,7 @@ public static TResult Execute( [NotNull] this IExecutionStrategy strategy, [CanBeNull] TState state, [NotNull] Func operation) - => strategy.Execute(state, operation, verifySucceeded: null); + => strategy.Execute(state, operation, verifySucceeded: null); /// /// Executes the specified asynchronous operation and returns the result. diff --git a/src/EFCore/Storage/IDatabase.cs b/src/EFCore/Storage/IDatabase.cs index 88fa8b27d54..1cb7881f714 100644 --- a/src/EFCore/Storage/IDatabase.cs +++ b/src/EFCore/Storage/IDatabase.cs @@ -51,12 +51,12 @@ Task SaveChangesAsync( CancellationToken cancellationToken = default); /// - /// Compiles the given query to generate a . + /// Compiles the given query to generate a . /// /// The type of query result. /// The query to compile. /// A value indicating whether this is an async query. - /// A which can be invoked to get results of the query. + /// A which can be invoked to get results of the query. Func CompileQuery([NotNull] Expression query, bool async); } } diff --git a/src/EFCore/Storage/IDatabaseCreator.cs b/src/EFCore/Storage/IDatabaseCreator.cs index cc44d69ab63..eccebf7ad20 100644 --- a/src/EFCore/Storage/IDatabaseCreator.cs +++ b/src/EFCore/Storage/IDatabaseCreator.cs @@ -27,7 +27,7 @@ public interface IDatabaseCreator /// the model for this context. /// /// - /// if the database is deleted, if it did not exist. + /// if the database is deleted, if it did not exist. bool EnsureDeleted(); /// @@ -42,8 +42,8 @@ public interface IDatabaseCreator /// /// A to observe while waiting for the task to complete. /// - /// A task that represents the asynchronous save operation. The task result contains if the database is deleted, - /// if it did not exist. + /// A task that represents the asynchronous save operation. The task result contains if the database is deleted, + /// if it did not exist. /// Task EnsureDeletedAsync(CancellationToken cancellationToken = default); @@ -52,7 +52,7 @@ public interface IDatabaseCreator /// exist then the database and all its schema are created. If the database exists, then no effort is made /// to ensure it is compatible with the model for this context. /// - /// if the database is created, if it already existed. + /// if the database is created, if it already existed. bool EnsureCreated(); /// @@ -62,8 +62,8 @@ public interface IDatabaseCreator /// /// A to observe while waiting for the task to complete. /// - /// A task that represents the asynchronous save operation. The task result contains if the database is created, - /// if it already existed. + /// A task that represents the asynchronous save operation. The task result contains if the database is created, + /// if it already existed. /// Task EnsureCreatedAsync(CancellationToken cancellationToken = default); diff --git a/src/EFCore/Storage/IDatabaseProvider.cs b/src/EFCore/Storage/IDatabaseProvider.cs index a5f01c6b2fc..b4ac112a074 100644 --- a/src/EFCore/Storage/IDatabaseProvider.cs +++ b/src/EFCore/Storage/IDatabaseProvider.cs @@ -34,7 +34,7 @@ public interface IDatabaseProvider /// Gets a value indicating whether this database provider has been configured for a given context. /// /// The options for the context. - /// if the database provider has been configured, otherwise . + /// if the database provider has been configured, otherwise . bool IsConfigured([NotNull] IDbContextOptions options); } } diff --git a/src/EFCore/Storage/IDbContextTransaction.cs b/src/EFCore/Storage/IDbContextTransaction.cs index 163632eb78a..cfc0ab93988 100644 --- a/src/EFCore/Storage/IDbContextTransaction.cs +++ b/src/EFCore/Storage/IDbContextTransaction.cs @@ -55,7 +55,8 @@ public interface IDbContextTransaction : IDisposable, IAsyncDisposable /// savepoint. /// /// The name of the savepoint to be created. - void CreateSavepoint([NotNull] string name) => throw new NotSupportedException(); + void CreateSavepoint([NotNull] string name) + => throw new NotSupportedException(); /// /// Creates a savepoint in the transaction. This allows all commands that are executed after the savepoint @@ -72,7 +73,8 @@ Task CreateSavepointAsync([NotNull] string name, CancellationToken cancellationT /// Rolls back all commands that were executed after the specified savepoint was established. /// /// The name of the savepoint to roll back to. - void RollbackToSavepoint([NotNull] string name) => throw new NotSupportedException(); + void RollbackToSavepoint([NotNull] string name) + => throw new NotSupportedException(); /// /// Rolls back all commands that were executed after the specified savepoint was established. @@ -101,16 +103,17 @@ Task ReleaseSavepointAsync([NotNull] string name, CancellationToken cancellation => Task.CompletedTask; /// - /// Gets a value that indicates whether this instance supports - /// database savepoints. If , the methods , - /// - /// and as well as their synchronous counterparts are expected to throw - /// . + /// Gets a value that indicates whether this instance supports + /// database savepoints. If , the methods , + /// + /// and as well as their synchronous counterparts are expected to throw + /// . /// /// - /// if this instance supports database savepoints; + /// if this instance supports database savepoints; /// otherwise, . /// - bool SupportsSavepoints => false; + bool SupportsSavepoints + => false; } } diff --git a/src/EFCore/Storage/IDbContextTransactionManager.cs b/src/EFCore/Storage/IDbContextTransactionManager.cs index 5a7050dd5c1..ffd36a8bd50 100644 --- a/src/EFCore/Storage/IDbContextTransactionManager.cs +++ b/src/EFCore/Storage/IDbContextTransactionManager.cs @@ -1,10 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Threading; using System.Threading.Tasks; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.DependencyInjection; diff --git a/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs b/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs index 3a5c40f32db..bdaa7dcdc2f 100644 --- a/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs +++ b/src/EFCore/Storage/Internal/ExecutionStrategyFactory.cs @@ -43,6 +43,7 @@ public ExecutionStrategyFactory([NotNull] ExecutionStrategyDependencies dependen /// Creates a new . /// /// An instance of . - public virtual IExecutionStrategy Create() => new NonRetryingExecutionStrategy(Dependencies); + public virtual IExecutionStrategy Create() + => new NonRetryingExecutionStrategy(Dependencies); } } diff --git a/src/EFCore/Storage/NonRetryingExecutionStrategy.cs b/src/EFCore/Storage/NonRetryingExecutionStrategy.cs index ee7f1001835..7c62f41895a 100644 --- a/src/EFCore/Storage/NonRetryingExecutionStrategy.cs +++ b/src/EFCore/Storage/NonRetryingExecutionStrategy.cs @@ -18,7 +18,8 @@ public sealed class NonRetryingExecutionStrategy : IExecutionStrategy /// /// Always returns false, since the does not perform retries. /// - public bool RetriesOnFailure => false; + public bool RetriesOnFailure + => false; /// /// Constructs a new with the given service dependencies. @@ -42,7 +43,9 @@ public NonRetryingExecutionStrategy([NotNull] ExecutionStrategyDependencies depe /// The operation has not succeeded after the configured number of retries. /// public TResult Execute( - TState state, Func operation, Func> verifySucceeded) + TState state, + Func operation, + Func> verifySucceeded) => operation(Dependencies.CurrentContext.Context, state); /// @@ -68,8 +71,11 @@ public TResult Execute( /// The operation has not succeeded after the configured number of retries. /// public Task ExecuteAsync( - TState state, Func> operation, Func>> verifySucceeded, CancellationToken cancellationToken = default) + TState state, + Func> operation, + Func>> verifySucceeded, + CancellationToken cancellationToken = default) => operation(Dependencies.CurrentContext.Context, state, cancellationToken); } } diff --git a/src/EFCore/Storage/ValueBuffer.cs b/src/EFCore/Storage/ValueBuffer.cs index 720c9cdc267..9ecd40e28de 100644 --- a/src/EFCore/Storage/ValueBuffer.cs +++ b/src/EFCore/Storage/ValueBuffer.cs @@ -58,12 +58,14 @@ internal static readonly MethodInfo GetValueMethod /// /// Gets the number of values in this buffer. /// - public int Count => _values.Length; + public int Count + => _values.Length; /// /// Gets a value indicating whether the value buffer is empty. /// - public bool IsEmpty => _values == null; + public bool IsEmpty + => _values == null; /// /// Determines if this value buffer is equivalent to a given object (i.e. if they are both value buffers and contain the same values). @@ -72,7 +74,7 @@ internal static readonly MethodInfo GetValueMethod /// The object to compare this value buffer to. /// /// - /// if the object is a and contains the same values, otherwise . + /// if the object is a and contains the same values, otherwise . /// public override bool Equals(object obj) => !(obj is null) diff --git a/src/EFCore/Storage/ValueConversion/CastingConverter.cs b/src/EFCore/Storage/ValueConversion/CastingConverter.cs index 83e8c299187..1a05db2eb17 100644 --- a/src/EFCore/Storage/ValueConversion/CastingConverter.cs +++ b/src/EFCore/Storage/ValueConversion/CastingConverter.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Storage.ValueConversion { /// - /// Converts to and from using simple casts from one type + /// Converts to and from using simple casts from one type /// to the other. /// public class CastingConverter : ValueConverter diff --git a/src/EFCore/Storage/ValueConversion/ValueConverterInfo.cs b/src/EFCore/Storage/ValueConversion/ValueConverterInfo.cs index 8e9bbc722d9..53474962d6a 100644 --- a/src/EFCore/Storage/ValueConversion/ValueConverterInfo.cs +++ b/src/EFCore/Storage/ValueConversion/ValueConverterInfo.cs @@ -60,6 +60,7 @@ public ValueConverterInfo( /// /// Creates an instance of the . /// - public ValueConverter Create() => _factory(this); + public ValueConverter Create() + => _factory(this); } } diff --git a/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs b/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs index 8c58476ea02..42b0593d06f 100644 --- a/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs +++ b/src/EFCore/Storage/ValueConversion/ValueConverterSelector.cs @@ -348,7 +348,8 @@ public virtual IEnumerable Select( } private IEnumerable ForChar( - Type underlyingModelType, Type underlyingProviderType) + Type underlyingModelType, + Type underlyingProviderType) { if (underlyingProviderType == null || underlyingProviderType == typeof(string)) @@ -369,7 +370,8 @@ private IEnumerable ForChar( } private IEnumerable CharToBytes( - Type underlyingModelType, Type underlyingProviderType) + Type underlyingModelType, + Type underlyingProviderType) { if (underlyingProviderType == null || underlyingProviderType == typeof(byte[])) @@ -381,7 +383,8 @@ private IEnumerable CharToBytes( } private IEnumerable EnumToStringOrBytes( - Type underlyingModelType, Type underlyingProviderType) + Type underlyingModelType, + Type underlyingProviderType) { if (underlyingProviderType == null || underlyingProviderType == typeof(string)) @@ -421,7 +424,8 @@ private IEnumerable EnumToStringOrBytes( } private IEnumerable NumberToStringOrBytes( - Type underlyingModelType, Type underlyingProviderType) + Type underlyingModelType, + Type underlyingProviderType) { if (underlyingProviderType == null || underlyingProviderType == typeof(string)) diff --git a/src/EFCore/Storage/ValueConversion/ValueConverter`.cs b/src/EFCore/Storage/ValueConversion/ValueConverter`.cs index 9271af79072..03a6342079c 100644 --- a/src/EFCore/Storage/ValueConversion/ValueConverter`.cs +++ b/src/EFCore/Storage/ValueConversion/ValueConverter`.cs @@ -87,11 +87,13 @@ public override Func ConvertFromProvider /// /// The CLR type used in the EF model. /// - public override Type ModelClrType => typeof(TModel); + public override Type ModelClrType + => typeof(TModel); /// /// The CLR type used when reading and writing from the store. /// - public override Type ProviderClrType => typeof(TProvider); + public override Type ProviderClrType + => typeof(TProvider); } } diff --git a/src/EFCore/Update/IUpdateEntry.cs b/src/EFCore/Update/IUpdateEntry.cs index 08284876a5c..d020b67ba2c 100644 --- a/src/EFCore/Update/IUpdateEntry.cs +++ b/src/EFCore/Update/IUpdateEntry.cs @@ -51,21 +51,21 @@ public interface IUpdateEntry /// to the property should be saved to the database. /// /// The property to be checked. - /// if the property is modified, otherwise . + /// if the property is modified, otherwise . bool IsModified([NotNull] IProperty property); /// /// Gets a value indicating if the specified property has a temporary value. /// /// The property to be checked. - /// if the property has a temporary value, otherwise . + /// if the property has a temporary value, otherwise . bool HasTemporaryValue([NotNull] IProperty property); /// /// Gets a value indicating if the specified property should have a value generated by the database. /// /// The property to be checked. - /// if the property should have a value generated by the database, otherwise . + /// if the property should have a value generated by the database, otherwise . bool IsStoreGenerated([NotNull] IProperty property); /// @@ -131,7 +131,7 @@ public interface IUpdateEntry /// Checks whether the property is conceptually set to null even if the property type is not nullable. /// /// The property to check. - /// if the property is conceptually null; otherwise. + /// if the property is conceptually null; otherwise. bool IsConceptualNull([NotNull] IProperty property); } } diff --git a/src/EFCore/Update/UpdateEntryExtensions.cs b/src/EFCore/Update/UpdateEntryExtensions.cs index 33cbad705c7..9ec16fa098f 100644 --- a/src/EFCore/Update/UpdateEntryExtensions.cs +++ b/src/EFCore/Update/UpdateEntryExtensions.cs @@ -45,7 +45,7 @@ public static object GetCurrentProviderValue([NotNull] this IUpdateEntry updateE /// /// - /// Creates a human-readable representation of the given . + /// Creates a human-readable representation of the given . /// /// /// Warning: Do not rely on the format of the returned string. diff --git a/src/EFCore/ValueGeneration/BinaryValueGenerator.cs b/src/EFCore/ValueGeneration/BinaryValueGenerator.cs index 913a09f6b75..071d8e9ec69 100644 --- a/src/EFCore/ValueGeneration/BinaryValueGenerator.cs +++ b/src/EFCore/ValueGeneration/BinaryValueGenerator.cs @@ -16,12 +16,14 @@ public class BinaryValueGenerator : ValueGenerator /// Gets a value indicating whether the values generated are temporary or permanent. This implementation /// always returns false, meaning the generated values will be saved to the database. /// - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; /// /// Gets a value to be assigned to a property. /// /// The value to be assigned to a property. - public override byte[] Next(EntityEntry entry) => Guid.NewGuid().ToByteArray(); + public override byte[] Next(EntityEntry entry) + => Guid.NewGuid().ToByteArray(); } } diff --git a/src/EFCore/ValueGeneration/GuidValueGenerator.cs b/src/EFCore/ValueGeneration/GuidValueGenerator.cs index 19ed62f18c8..65b48551820 100644 --- a/src/EFCore/ValueGeneration/GuidValueGenerator.cs +++ b/src/EFCore/ValueGeneration/GuidValueGenerator.cs @@ -17,12 +17,14 @@ public class GuidValueGenerator : ValueGenerator /// /// The change tracking entry of the entity for which the value is being generated. /// The value to be assigned to a property. - public override Guid Next(EntityEntry entry) => Guid.NewGuid(); + public override Guid Next(EntityEntry entry) + => Guid.NewGuid(); /// /// Gets a value indicating whether the values generated are temporary or permanent. This implementation /// always returns false, meaning the generated values will be saved to the database. /// - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } } diff --git a/src/EFCore/ValueGeneration/HiLoValueGenerator.cs b/src/EFCore/ValueGeneration/HiLoValueGenerator.cs index 55e1cb484b0..e3da34b5760 100644 --- a/src/EFCore/ValueGeneration/HiLoValueGenerator.cs +++ b/src/EFCore/ValueGeneration/HiLoValueGenerator.cs @@ -42,7 +42,8 @@ protected HiLoValueGenerator([NotNull] HiLoValueGeneratorState generatorState) /// /// The change tracking entry of the entity for which the value is being generated. /// The value to be assigned to a property. - public override TValue Next(EntityEntry entry) => _generatorState.Next(GetNewLowValue); + public override TValue Next(EntityEntry entry) + => _generatorState.Next(GetNewLowValue); /// /// Gets a value to be assigned to a property. @@ -51,7 +52,8 @@ protected HiLoValueGenerator([NotNull] HiLoValueGeneratorState generatorState) /// A to observe while waiting for the task to complete. /// The value to be assigned to a property. public override ValueTask NextAsync( - EntityEntry entry, CancellationToken cancellationToken = default) + EntityEntry entry, + CancellationToken cancellationToken = default) => _generatorState.NextAsync(GetNewLowValueAsync); /// diff --git a/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs b/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs index cb0dc541355..9492508e9a0 100644 --- a/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs +++ b/src/EFCore/ValueGeneration/HiLoValueGeneratorState.cs @@ -149,7 +149,8 @@ public HiLoValue(long low, long high) public long High { get; } - public HiLoValue NextValue() => new HiLoValue(Low + 1, High); + public HiLoValue NextValue() + => new HiLoValue(Low + 1, High); } } } diff --git a/src/EFCore/ValueGeneration/Internal/DiscriminatorValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/DiscriminatorValueGenerator.cs index e5f02b6ff22..ee0ffa3360c 100644 --- a/src/EFCore/ValueGeneration/Internal/DiscriminatorValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/DiscriminatorValueGenerator.cs @@ -44,7 +44,8 @@ public DiscriminatorValueGenerator([NotNull] object discriminator) /// 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. /// - protected override object NextValue(EntityEntry entry) => _discriminator; + protected override object NextValue(EntityEntry entry) + => _discriminator; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -52,6 +53,7 @@ public DiscriminatorValueGenerator([NotNull] object discriminator) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryByteValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryByteValueGenerator.cs index 1859ea54b8c..5e7d2f68ba4 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryByteValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryByteValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryByteValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override byte Next(EntityEntry entry) => (byte)Interlocked.Decrement(ref _current); + public override byte Next(EntityEntry entry) + => (byte)Interlocked.Decrement(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryCharValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryCharValueGenerator.cs index b12110ceffb..df1855e176c 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryCharValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryCharValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryCharValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override char Next(EntityEntry entry) => (char)Interlocked.Decrement(ref _current); + public override char Next(EntityEntry entry) + => (char)Interlocked.Decrement(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryDecimalValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryDecimalValueGenerator.cs index 4468fb81593..064d3196b85 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryDecimalValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryDecimalValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryDecimalValueGenerator : TemporaryNumberValueGenerator - public override decimal Next(EntityEntry entry) => Interlocked.Increment(ref _current); + public override decimal Next(EntityEntry entry) + => Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryDoubleValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryDoubleValueGenerator.cs index 3c0408f1561..b8ce28faf71 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryDoubleValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryDoubleValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryDoubleValueGenerator : TemporaryNumberValueGenerator - public override double Next(EntityEntry entry) => Interlocked.Increment(ref _current); + public override double Next(EntityEntry entry) + => Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryFloatValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryFloatValueGenerator.cs index b2eed8742fa..30811e5a8f2 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryFloatValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryFloatValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryFloatValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override float Next(EntityEntry entry) => Interlocked.Increment(ref _current); + public override float Next(EntityEntry entry) + => Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryIntValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryIntValueGenerator.cs index 5c78e81ef55..6042afe8b78 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryIntValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryIntValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryIntValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override int Next(EntityEntry entry) => Interlocked.Increment(ref _current); + public override int Next(EntityEntry entry) + => Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryLongValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryLongValueGenerator.cs index 002d137fdc9..dae15e0f497 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryLongValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryLongValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryLongValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override long Next(EntityEntry entry) => Interlocked.Increment(ref _current); + public override long Next(EntityEntry entry) + => Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryNumberValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryNumberValueGenerator.cs index 4a2578324b7..a15e201c95b 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryNumberValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryNumberValueGenerator.cs @@ -17,6 +17,7 @@ public abstract class TemporaryNumberValueGenerator : ValueGenerator - public override bool GeneratesTemporaryValues => true; + public override bool GeneratesTemporaryValues + => true; } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporarySByteValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporarySByteValueGenerator.cs index eb0157b1a60..5649e594548 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporarySByteValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporarySByteValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporarySByteValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override sbyte Next(EntityEntry entry) => (sbyte)Interlocked.Increment(ref _current); + public override sbyte Next(EntityEntry entry) + => (sbyte)Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryShortValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryShortValueGenerator.cs index f012b3f8af2..e6e9eecb99c 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryShortValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryShortValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryShortValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override short Next(EntityEntry entry) => (short)Interlocked.Increment(ref _current); + public override short Next(EntityEntry entry) + => (short)Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryUIntValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryUIntValueGenerator.cs index 89fcbd1ea0c..285e89e3784 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryUIntValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryUIntValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryUIntValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override uint Next(EntityEntry entry) => (uint)Interlocked.Increment(ref _current); + public override uint Next(EntityEntry entry) + => (uint)Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryULongValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryULongValueGenerator.cs index 40fdf0a9ab6..b7c1d881ab8 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryULongValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryULongValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryULongValueGenerator : TemporaryNumberValueGenerator /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public override ulong Next(EntityEntry entry) => (ulong)Interlocked.Increment(ref _current); + public override ulong Next(EntityEntry entry) + => (ulong)Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/Internal/TemporaryUShortValueGenerator.cs b/src/EFCore/ValueGeneration/Internal/TemporaryUShortValueGenerator.cs index fa2bfc6d5aa..3bf9aecd77a 100644 --- a/src/EFCore/ValueGeneration/Internal/TemporaryUShortValueGenerator.cs +++ b/src/EFCore/ValueGeneration/Internal/TemporaryUShortValueGenerator.cs @@ -22,6 +22,7 @@ public class TemporaryUShortValueGenerator : TemporaryNumberValueGenerator - public override ushort Next(EntityEntry entry) => (ushort)Interlocked.Increment(ref _current); + public override ushort Next(EntityEntry entry) + => (ushort)Interlocked.Increment(ref _current); } } diff --git a/src/EFCore/ValueGeneration/SequentialGuidValueGenerator.cs b/src/EFCore/ValueGeneration/SequentialGuidValueGenerator.cs index 099216e0b5e..a8bda212848 100644 --- a/src/EFCore/ValueGeneration/SequentialGuidValueGenerator.cs +++ b/src/EFCore/ValueGeneration/SequentialGuidValueGenerator.cs @@ -57,6 +57,7 @@ public override Guid Next(EntityEntry entry) /// Gets a value indicating whether the values generated are temporary or permanent. This implementation /// always returns false, meaning the generated values will be saved to the database. /// - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } } diff --git a/src/EFCore/ValueGeneration/StringValueGenerator.cs b/src/EFCore/ValueGeneration/StringValueGenerator.cs index 58929604e77..66f002fabdd 100644 --- a/src/EFCore/ValueGeneration/StringValueGenerator.cs +++ b/src/EFCore/ValueGeneration/StringValueGenerator.cs @@ -16,12 +16,14 @@ public class StringValueGenerator : ValueGenerator /// Gets a value indicating whether the values generated are temporary or permanent. This implementation /// always returns false, meaning the generated values will be saved to the database. /// - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; /// /// Gets a value to be assigned to a property. /// /// The value to be assigned to a property. - public override string Next(EntityEntry entry) => Guid.NewGuid().ToString(); + public override string Next(EntityEntry entry) + => Guid.NewGuid().ToString(); } } diff --git a/src/EFCore/ValueGeneration/TemporaryGuidValueGenerator.cs b/src/EFCore/ValueGeneration/TemporaryGuidValueGenerator.cs index 21575fde7ea..c4d9ed88445 100644 --- a/src/EFCore/ValueGeneration/TemporaryGuidValueGenerator.cs +++ b/src/EFCore/ValueGeneration/TemporaryGuidValueGenerator.cs @@ -16,6 +16,7 @@ public class TemporaryGuidValueGenerator : GuidValueGenerator /// Gets a value to be assigned to a property. /// /// The value to be assigned to a property. - public override bool GeneratesTemporaryValues => true; + public override bool GeneratesTemporaryValues + => true; } } diff --git a/src/EFCore/ValueGeneration/ValueGeneratorCache.cs b/src/EFCore/ValueGeneration/ValueGeneratorCache.cs index a13269a0755..1f6e3855b29 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorCache.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorCache.cs @@ -59,7 +59,8 @@ public bool Equals(CacheKey other) public override bool Equals(object obj) => obj is CacheKey cacheKey && Equals(cacheKey); - public override int GetHashCode() => HashCode.Combine(Property, EntityType); + public override int GetHashCode() + => HashCode.Combine(Property, EntityType); } /// @@ -74,7 +75,9 @@ public override bool Equals(object obj) /// Factory to create a new value generator if one is not present in the cache. /// The existing or newly created value generator. public virtual ValueGenerator GetOrAdd( - IProperty property, IEntityType entityType, Func factory) + IProperty property, + IEntityType entityType, + Func factory) { Check.NotNull(property, nameof(property)); Check.NotNull(factory, nameof(factory)); diff --git a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs index 3ac3d90c970..2e46e538b51 100644 --- a/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs +++ b/src/EFCore/ValueGeneration/ValueGeneratorSelector.cs @@ -31,7 +31,8 @@ public class ValueGeneratorSelector : IValueGeneratorSelector /// /// The cache being used to store value generator instances. /// - public virtual IValueGeneratorCache Cache => Dependencies.Cache; + public virtual IValueGeneratorCache Cache + => Dependencies.Cache; /// /// Initializes a new instance of the class.