diff --git a/All.sln.DotSettings b/All.sln.DotSettings index ce72e4db697..cc0f9910226 100644 --- a/All.sln.DotSettings +++ b/All.sln.DotSettings @@ -32,7 +32,74 @@ WARNING True - <?xml version="1.0" encoding="utf-16"?><Profile name="EntityFramework"><HtmlReformatCode>True</HtmlReformatCode><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSUseAutoProperty>True</CSUseAutoProperty><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><XMLReformatCode>True</XMLReformatCode><CSUpdateFileHeader>True</CSUpdateFileHeader><CSharpFormatDocComments>True</CSharpFormatDocComments><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSArrangeQualifiers>True</CSArrangeQualifiers><CSEnforceVarKeywordUsageSettings>True</CSEnforceVarKeywordUsageSettings><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="False" AddMissingParentheses="False" ArrangeBraces="False" ArrangeAttributes="True" ArrangeArgumentsStyle="False" /></Profile> + <?xml version="1.0" encoding="utf-16"?><Profile name="EntityFramework"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>CAN_CHANGE_TO_IMPLICIT</BehavourStyle><LocalVariableStyle>ALWAYS_IMPLICIT</LocalVariableStyle><ForeachVariableStyle>ALWAYS_IMPLICIT</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><XMLReformatCode>True</XMLReformatCode><CSUpdateFileHeader>True</CSUpdateFileHeader><CSharpFormatDocComments>True</CSharpFormatDocComments><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSArrangeQualifiers>True</CSArrangeQualifiers><CSEnforceVarKeywordUsageSettings>True</CSEnforceVarKeywordUsageSettings><CSFixBuiltinTypeReferences>True</CSFixBuiltinTypeReferences><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="False" AddMissingParentheses="False" ArrangeBraces="False" ArrangeAttributes="True" ArrangeArgumentsStyle="False" /><IDEA_SETTINGS>&lt;profile version="1.0"&gt; + &lt;option name="myName" value="EntityFramework" /&gt; + &lt;inspection_tool class="ES6ShorthandObjectProperty" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="JSArrowFunctionBracesCanBeRemoved" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="JSPrimitiveTypeWrapperUsage" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="JSRemoveUnnecessaryParentheses" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="JSUnnecessarySemicolon" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="TypeScriptExplicitMemberType" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="UnnecessaryContinueJS" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="UnnecessaryLabelJS" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="UnnecessaryLabelOnBreakStatementJS" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="UnnecessaryLabelOnContinueStatementJS" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="UnnecessaryReturnJS" enabled="false" level="WARNING" enabled_by_default="false" /&gt; + &lt;inspection_tool class="WrongPropertyKeyValueDelimiter" enabled="false" level="WEAK WARNING" enabled_by_default="false" /&gt; +&lt;/profile&gt;</IDEA_SETTINGS><RIDER_SETTINGS>&lt;profile&gt; + &lt;Language id="CSS"&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;Rearrange&gt;false&lt;/Rearrange&gt; + &lt;/Language&gt; + &lt;Language id="EditorConfig"&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="HTML"&gt; + &lt;OptimizeImports&gt;false&lt;/OptimizeImports&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;Rearrange&gt;false&lt;/Rearrange&gt; + &lt;/Language&gt; + &lt;Language id="HTTP Request"&gt; + &lt;Reformat&gt;true&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="Handlebars"&gt; + &lt;Reformat&gt;true&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="Ini"&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="JSON"&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="Jade"&gt; + &lt;Reformat&gt;true&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="JavaScript"&gt; + &lt;OptimizeImports&gt;false&lt;/OptimizeImports&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;Rearrange&gt;false&lt;/Rearrange&gt; + &lt;/Language&gt; + &lt;Language id="Markdown"&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="Properties"&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="RELAX-NG"&gt; + &lt;Reformat&gt;true&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="SQL"&gt; + &lt;Reformat&gt;true&lt;/Reformat&gt; + &lt;/Language&gt; + &lt;Language id="XML"&gt; + &lt;OptimizeImports&gt;false&lt;/OptimizeImports&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;Rearrange&gt;false&lt;/Rearrange&gt; + &lt;/Language&gt; + &lt;Language id="yaml"&gt; + &lt;Reformat&gt;false&lt;/Reformat&gt; + &lt;/Language&gt; +&lt;/profile&gt;</RIDER_SETTINGS></Profile> EntityFramework EntityFramework @@ -75,6 +142,7 @@ 2 NEVER False + ALWAYS NEVER NEVER False diff --git a/src/EFCore/ChangeTracking/ChangeTracker.cs b/src/EFCore/ChangeTracking/ChangeTracker.cs index ed70c049c9f..725d39f74b4 100644 --- a/src/EFCore/ChangeTracking/ChangeTracker.cs +++ b/src/EFCore/ChangeTracking/ChangeTracker.cs @@ -279,16 +279,16 @@ public virtual void TrackGraph( rootEntity, callback, n => - { - if (n.Entry.State != EntityState.Detached) { - return false; - } + if (n.Entry.State != EntityState.Detached) + { + return false; + } - n.NodeState!(n); + n.NodeState!(n); - return n.Entry.State != EntityState.Detached; - }); + return n.Entry.State != EntityState.Detached; + }); /// /// @@ -457,7 +457,7 @@ public virtual void Clear() public virtual DebugView DebugView => new( () => this.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault), - () => this.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault)); + () => this.ToDebugString()); #region Hidden System.Object members diff --git a/src/EFCore/ChangeTracking/CollectionEntry.cs b/src/EFCore/ChangeTracking/CollectionEntry.cs index d716ea534b6..411f476bd36 100644 --- a/src/EFCore/ChangeTracking/CollectionEntry.cs +++ b/src/EFCore/ChangeTracking/CollectionEntry.cs @@ -248,7 +248,7 @@ public override void Load() /// /// A to observe while waiting for the task to complete. /// A task that represents the asynchronous save operation. - /// If the is canceled. + /// If the is canceled. public override Task LoadAsync(CancellationToken cancellationToken = default) { EnsureInitialized(); diff --git a/src/EFCore/ChangeTracking/EntityEntry.cs b/src/EFCore/ChangeTracking/EntityEntry.cs index 2e553d46139..bc78e0ecc84 100644 --- a/src/EFCore/ChangeTracking/EntityEntry.cs +++ b/src/EFCore/ChangeTracking/EntityEntry.cs @@ -162,7 +162,7 @@ public virtual MemberEntry Member(string propertyName) if (navigation != null) { return navigation.IsCollection - ? (MemberEntry)new CollectionEntry(InternalEntry, propertyName) + ? new CollectionEntry(InternalEntry, propertyName) : new ReferenceEntry(InternalEntry, propertyName); } @@ -201,7 +201,7 @@ public virtual NavigationEntry Navigation(string propertyName) if (navigation != null) { return navigation.IsCollection - ? (NavigationEntry)new CollectionEntry(InternalEntry, propertyName) + ? new CollectionEntry(InternalEntry, propertyName) : new ReferenceEntry(InternalEntry, propertyName); } @@ -399,7 +399,7 @@ public virtual PropertyValues OriginalValues /// /// /// Queries the database for copies of the values of the tracked entity as they currently - /// exist in the database. If the entity is not found in the database, then is returned. + /// exist in the database. If the entity is not found in the database, then is returned. /// /// /// Note that changing the values in the returned dictionary will not update the values @@ -409,7 +409,7 @@ public virtual PropertyValues OriginalValues /// /// See Accessing tracked entities in EF Core for more information. /// - /// The store values, or if the entity does not exist in the database. + /// The store values, or if the entity does not exist in the database. public virtual PropertyValues? GetDatabaseValues() { var values = Finder.GetDatabaseValues(InternalEntry); @@ -439,7 +439,7 @@ public virtual PropertyValues OriginalValues /// A task that represents the asynchronous operation. The task result contains the store values, /// or if the entity does not exist in the database. /// - /// If the is canceled. + /// If the is canceled. public virtual async Task GetDatabaseValuesAsync(CancellationToken cancellationToken = default) { var values = await Finder.GetDatabaseValuesAsync(InternalEntry, cancellationToken).ConfigureAwait(false); @@ -482,7 +482,7 @@ public virtual void Reload() /// /// A to observe while waiting for the task to complete. /// A task that represents the asynchronous operation. - /// If the is canceled. + /// If the is canceled. public virtual async Task ReloadAsync(CancellationToken cancellationToken = default) => Reload(await GetDatabaseValuesAsync(cancellationToken).ConfigureAwait(false)); @@ -530,7 +530,7 @@ public override string ToString() public virtual DebugView DebugView => new( () => InternalEntry.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault), - () => InternalEntry.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault)); + () => InternalEntry.ToDebugString()); #region Hidden System.Object members diff --git a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs index fa513a1ce36..69547e90f8d 100644 --- a/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs +++ b/src/EFCore/ChangeTracking/EntityEntryGraphNode.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Utilities; - namespace Microsoft.EntityFrameworkCore.ChangeTracking { /// diff --git a/src/EFCore/ChangeTracking/GeometryValueComparer.cs b/src/EFCore/ChangeTracking/GeometryValueComparer.cs index 924714897da..371914e9bcd 100644 --- a/src/EFCore/ChangeTracking/GeometryValueComparer.cs +++ b/src/EFCore/ChangeTracking/GeometryValueComparer.cs @@ -52,7 +52,7 @@ public GeometryValueComparer() Expression.IsFalse(yNull), Expression.Call( x, - typeof(TGeometry).GetRequiredRuntimeMethod("EqualsExact", new[] { typeof(TGeometry) }), + typeof(TGeometry).GetRequiredRuntimeMethod("EqualsExact", typeof(TGeometry)), y))))), left, right); diff --git a/src/EFCore/ChangeTracking/IEntityEntryGraphIterator.cs b/src/EFCore/ChangeTracking/IEntityEntryGraphIterator.cs index 228432bd5c5..e548da6df69 100644 --- a/src/EFCore/ChangeTracking/IEntityEntryGraphIterator.cs +++ b/src/EFCore/ChangeTracking/IEntityEntryGraphIterator.cs @@ -41,7 +41,7 @@ void TraverseGraph( /// A to observe while waiting for the task to complete. /// The type of the state object. /// A task that represents the asynchronous operation. - /// If the is canceled. + /// If the is canceled. Task TraverseGraphAsync( EntityEntryGraphNode node, Func, CancellationToken, Task> handleNode, diff --git a/src/EFCore/ChangeTracking/Internal/CompositePrincipalKeyValueFactory.cs b/src/EFCore/ChangeTracking/Internal/CompositePrincipalKeyValueFactory.cs index f938ef59447..accf0b19bb8 100644 --- a/src/EFCore/ChangeTracking/Internal/CompositePrincipalKeyValueFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/CompositePrincipalKeyValueFactory.cs @@ -117,6 +117,7 @@ private object[] CreateFromEntry( { return default!; } + values[index++] = value; } diff --git a/src/EFCore/ChangeTracking/Internal/CompositeValueFactory.cs b/src/EFCore/ChangeTracking/Internal/CompositeValueFactory.cs index 9a107689918..918d00bdaaf 100644 --- a/src/EFCore/ChangeTracking/Internal/CompositeValueFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/CompositeValueFactory.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Update; - namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { /// @@ -153,7 +152,7 @@ protected static IEqualityComparer CreateEqualityComparer(IReadOnlyLis return comparers.All(c => c != null) ? new CompositeCustomComparer(comparers!) : properties.Any(p => typeof(IStructuralEquatable).IsAssignableFrom(p.ClrType)) - ? (IEqualityComparer)new StructuralCompositeComparer() + ? new StructuralCompositeComparer() : new CompositeComparer(); } diff --git a/src/EFCore/ChangeTracking/Internal/DependentsMap.cs b/src/EFCore/ChangeTracking/Internal/DependentsMap.cs index 084ee408f0c..f810bc2252f 100644 --- a/src/EFCore/ChangeTracking/Internal/DependentsMap.cs +++ b/src/EFCore/ChangeTracking/Internal/DependentsMap.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Update; - namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { /// diff --git a/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs b/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs index b52caacce51..d2303c1cf1d 100644 --- a/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs +++ b/src/EFCore/ChangeTracking/Internal/EntityGraphAttacher.cs @@ -150,7 +150,7 @@ await internalEntityEntry.SetEntityStateAsync( ? (isGenerated ? storeGenTargetState : targetState) : EntityState.Added, // Key can only be not-set if it is store-generated acceptChanges: true, - forceStateWhenUnknownKey: force ? (EntityState?)targetState : null, + forceStateWhenUnknownKey: force ? targetState : null, cancellationToken: cancellationToken) .ConfigureAwait(false); diff --git a/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs b/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs index 0e6e5dba116..102b4e54973 100644 --- a/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs +++ b/src/EFCore/ChangeTracking/Internal/EntityReferenceMap.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; - namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { /// @@ -178,7 +177,11 @@ public virtual bool TryGet( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual int GetCountForState( - bool added, bool modified, bool deleted, bool unchanged, bool countDeletedSharedIdentity) + bool added, + bool modified, + bool deleted, + bool unchanged, + bool countDeletedSharedIdentity) { var count = 0; @@ -226,7 +229,11 @@ public virtual int GetCountForState( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IEnumerable GetEntriesForState( - bool added, bool modified, bool deleted, bool unchanged, bool returnDeletedSharedIdentity) + bool added, + bool modified, + bool deleted, + bool unchanged, + bool returnDeletedSharedIdentity) { // Perf sensitive diff --git a/src/EFCore/ChangeTracking/Internal/IdentityMapFactoryFactory.cs b/src/EFCore/ChangeTracking/Internal/IdentityMapFactoryFactory.cs index 0321e9b1291..17cb83c2ca6 100644 --- a/src/EFCore/ChangeTracking/Internal/IdentityMapFactoryFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/IdentityMapFactoryFactory.cs @@ -35,8 +35,8 @@ private static Func CreateFactory(IKey key) var factory = key.GetPrincipalKeyValueFactory(); return typeof(TKey).IsNullableType() - ? (Func)(sensitiveLoggingEnabled => - new NullableKeyIdentityMap(key, factory, sensitiveLoggingEnabled)) + ? sensitiveLoggingEnabled => + new NullableKeyIdentityMap(key, factory, sensitiveLoggingEnabled) : sensitiveLoggingEnabled => new IdentityMap(key, factory, sensitiveLoggingEnabled); } } diff --git a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs index 4abf0c7f8fa..815a782cdd2 100644 --- a/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs +++ b/src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; @@ -681,7 +680,7 @@ private CurrentValueType GetValueType( return CurrentValueType.Normal; } - @equals ??= ValuesEqualFunc(property); + equals ??= ValuesEqualFunc(property); var defaultValue = property.ClrType.GetDefaultValue(); var value = ReadPropertyValue(property); if (!equals(value, defaultValue)) @@ -1030,7 +1029,7 @@ public void SetOriginalValue( // If setting the original value results in the current value being different from the // original value, then mark the property as modified. if ((EntityState == EntityState.Unchanged - || (EntityState == EntityState.Modified && !IsModified(property))) + || (EntityState == EntityState.Modified && !IsModified(property))) && !_stateData.IsPropertyFlagged(property.GetIndex(), PropertyFlag.Unknown)) { ((StateManager as StateManager)?.ChangeDetector as ChangeDetector)?.DetectValueChange(this, property); @@ -1352,6 +1351,7 @@ private void SetProperty( { SetOriginalValue(propertyBase, value); } + _stateData.FlagProperty(propertyIndex, PropertyFlag.Unknown, isFlagged: false); } } @@ -1377,7 +1377,7 @@ private void SetProperty( /// public void HandleNullForeignKey( IProperty property, - bool setModified = false, + bool setModified = false, bool isCascadeDelete = false) { if (EntityState != EntityState.Deleted @@ -1946,7 +1946,7 @@ public override string ToString() public DebugView DebugView => new( () => this.ToDebugString(ChangeTrackerDebugStringOptions.ShortDefault), - () => this.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault)); + () => this.ToDebugString()); IUpdateEntry? IUpdateEntry.SharedIdentityEntry => SharedIdentityEntry; diff --git a/src/EFCore/ChangeTracking/Internal/KeyPropagator.cs b/src/EFCore/ChangeTracking/Internal/KeyPropagator.cs index 489cab1fd64..67414c2d9b9 100644 --- a/src/EFCore/ChangeTracking/Internal/KeyPropagator.cs +++ b/src/EFCore/ChangeTracking/Internal/KeyPropagator.cs @@ -64,7 +64,7 @@ public KeyPropagator( generationProperty == property ? entry.EntityType : generationProperty?.DeclaringEntityType); - + if (valueGenerator != null) { var value = valueGenerator.Next(new EntityEntry(entry)); @@ -112,7 +112,7 @@ public KeyPropagator( generationProperty == property ? entry.EntityType : generationProperty?.DeclaringEntityType); - + if (valueGenerator != null) { var value = await valueGenerator.NextAsync(new EntityEntry(entry), cancellationToken) diff --git a/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs b/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs index bb1d66c3f91..37271183dd1 100644 --- a/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs +++ b/src/EFCore/ChangeTracking/Internal/NavigationFixer.cs @@ -340,8 +340,8 @@ public virtual void NavigationCollectionChanged( if (navigationBase is ISkipNavigation skipNavigation) { - FindOrCreateJoinEntry(( - entry, newTargetEntry, skipNavigation, FromQuery: false, SetModified: true)); + FindOrCreateJoinEntry( + (entry, newTargetEntry, skipNavigation, FromQuery: false, SetModified: true)); Check.DebugAssert( skipNavigation.Inverse.IsCollection, @@ -757,7 +757,7 @@ private void InitialFixup( { var toDependent = foreignKey.PrincipalToDependent; if (CanOverrideCurrentValue(entry, toDependent, dependentEntry, fromQuery) - && !IsAmbiguous(dependentEntry)) + && !IsAmbiguous(dependentEntry)) { SetNavigation(entry, toDependent, dependentEntry, fromQuery); SetNavigation(dependentEntry, foreignKey.DependentToPrincipal, entry, fromQuery); @@ -917,10 +917,10 @@ private void InitialFixup( private static bool IsAmbiguous(InternalEntityEntry dependentEntry) => (dependentEntry.EntityState == EntityState.Detached - || dependentEntry.EntityState == EntityState.Deleted) + || dependentEntry.EntityState == EntityState.Deleted) && (dependentEntry.SharedIdentityEntry != null || dependentEntry.EntityType.HasSharedClrType - && dependentEntry.StateManager.TryGetEntry(dependentEntry.Entity, throwOnNonUniqueness: false) != dependentEntry); + && dependentEntry.StateManager.TryGetEntry(dependentEntry.Entity, throwOnNonUniqueness: false) != dependentEntry); private void DelayedFixup( InternalEntityEntry entry, @@ -990,16 +990,19 @@ private void FixupSkipNavigations(InternalEntityEntry entry, IForeignKey foreign private void FindOrCreateJoinEntry( (InternalEntityEntry Entry, - InternalEntityEntry OtherEntry, - ISkipNavigation SkipNavigation, - bool FromQuery, - bool SetModified) arguments) + InternalEntityEntry OtherEntry, + ISkipNavigation SkipNavigation, + bool FromQuery, + bool SetModified) arguments) { var joinEntry = FindJoinEntry(arguments.Entry, arguments.OtherEntry, arguments.SkipNavigation); if (joinEntry != null) { - SetForeignKeyProperties(joinEntry, arguments.Entry, arguments.SkipNavigation.ForeignKey, arguments.SetModified, arguments.FromQuery); - SetForeignKeyProperties(joinEntry, arguments.OtherEntry, arguments.SkipNavigation.Inverse.ForeignKey, arguments.SetModified, arguments.FromQuery); + SetForeignKeyProperties( + joinEntry, arguments.Entry, arguments.SkipNavigation.ForeignKey, arguments.SetModified, arguments.FromQuery); + SetForeignKeyProperties( + joinEntry, arguments.OtherEntry, arguments.SkipNavigation.Inverse.ForeignKey, arguments.SetModified, + arguments.FromQuery); } else if (!_inAttachGraph) { @@ -1009,8 +1012,11 @@ private void FindOrCreateJoinEntry( joinEntry = arguments.Entry.StateManager.GetOrCreateEntry(joinEntity, joinEntityType); - SetForeignKeyProperties(joinEntry, arguments.Entry, arguments.SkipNavigation.ForeignKey, arguments.SetModified, arguments.FromQuery); - SetForeignKeyProperties(joinEntry, arguments.OtherEntry, arguments.SkipNavigation.Inverse.ForeignKey, arguments.SetModified, arguments.FromQuery); + SetForeignKeyProperties( + joinEntry, arguments.Entry, arguments.SkipNavigation.ForeignKey, arguments.SetModified, arguments.FromQuery); + SetForeignKeyProperties( + joinEntry, arguments.OtherEntry, arguments.SkipNavigation.Inverse.ForeignKey, arguments.SetModified, + arguments.FromQuery); joinEntry.SetEntityState( arguments.SetModified @@ -1022,7 +1028,7 @@ private void FindOrCreateJoinEntry( else { _danglingJoinEntities ??= new List(); - + _danglingJoinEntities.Add(() => FindOrCreateJoinEntry(arguments)); } } @@ -1332,14 +1338,19 @@ private void ConditionallyNullForeignKeyProperties( break; case EntityState.Unchanged: case EntityState.Modified: - dependentEntry.SetEntityState(dependentEntry.SharedIdentityEntry != null ? EntityState.Detached : EntityState.Deleted); + dependentEntry.SetEntityState( + dependentEntry.SharedIdentityEntry != null ? EntityState.Detached : EntityState.Deleted); DeleteFixup(dependentEntry); break; } } } - private static bool CanOverrideCurrentValue(InternalEntityEntry entry, INavigationBase? navigation, InternalEntityEntry value, bool fromQuery) + private static bool CanOverrideCurrentValue( + InternalEntityEntry entry, + INavigationBase? navigation, + InternalEntityEntry value, + bool fromQuery) { if (fromQuery) { diff --git a/src/EFCore/ChangeTracking/Internal/SimpleFullyNullableDependentKeyValueFactory.cs b/src/EFCore/ChangeTracking/Internal/SimpleFullyNullableDependentKeyValueFactory.cs index 0567dcb4fee..681abeba243 100644 --- a/src/EFCore/ChangeTracking/Internal/SimpleFullyNullableDependentKeyValueFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/SimpleFullyNullableDependentKeyValueFactory.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Update; - namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { /// diff --git a/src/EFCore/ChangeTracking/Internal/SimpleNonNullableDependentKeyValueFactory.cs b/src/EFCore/ChangeTracking/Internal/SimpleNonNullableDependentKeyValueFactory.cs index 3138698091f..592ad2a5130 100644 --- a/src/EFCore/ChangeTracking/Internal/SimpleNonNullableDependentKeyValueFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/SimpleNonNullableDependentKeyValueFactory.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Update; - namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { /// diff --git a/src/EFCore/ChangeTracking/Internal/SimpleNullablePrincipalDependentKeyValueFactory.cs b/src/EFCore/ChangeTracking/Internal/SimpleNullablePrincipalDependentKeyValueFactory.cs index b1a535e310f..f815cf36468 100644 --- a/src/EFCore/ChangeTracking/Internal/SimpleNullablePrincipalDependentKeyValueFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/SimpleNullablePrincipalDependentKeyValueFactory.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Update; - namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { // The methods here box, but this is only used when the primary key is nullable, but the FK is non-nullable, diff --git a/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs b/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs index 839b54dd400..cc157b16e37 100644 --- a/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/SimplePrincipalKeyValueFactory.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Update; - namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal { /// @@ -41,7 +40,7 @@ public SimplePrincipalKeyValueFactory(IProperty property) = comparer != null ? new NoNullsCustomEqualityComparer(comparer) : typeof(IStructuralEquatable).IsAssignableFrom(typeof(TKey)) - ? (IEqualityComparer)new NoNullsStructuralEqualityComparer() + ? new NoNullsStructuralEqualityComparer() : EqualityComparer.Default; } diff --git a/src/EFCore/ChangeTracking/Internal/Snapshot.cs b/src/EFCore/ChangeTracking/Internal/Snapshot.cs index f27cb1cf853..b9a0bdb0cba 100644 --- a/src/EFCore/ChangeTracking/Internal/Snapshot.cs +++ b/src/EFCore/ChangeTracking/Internal/Snapshot.cs @@ -89,39 +89,39 @@ public static Delegate[] CreateReaders() /// public static Type CreateSnapshotType(Type[] types) => types.Length switch - { - 1 => typeof(Snapshot<>).MakeGenericType(types), - 2 => typeof(Snapshot<,>).MakeGenericType(types), - 3 => typeof(Snapshot<,,>).MakeGenericType(types), - 4 => typeof(Snapshot<,,,>).MakeGenericType(types), - 5 => typeof(Snapshot<,,,,>).MakeGenericType(types), - 6 => typeof(Snapshot<,,,,,>).MakeGenericType(types), - 7 => typeof(Snapshot<,,,,,,>).MakeGenericType(types), - 8 => typeof(Snapshot<,,,,,,,>).MakeGenericType(types), - 9 => typeof(Snapshot<,,,,,,,,>).MakeGenericType(types), - 10 => typeof(Snapshot<,,,,,,,,,>).MakeGenericType(types), - 11 => typeof(Snapshot<,,,,,,,,,,>).MakeGenericType(types), - 12 => typeof(Snapshot<,,,,,,,,,,,>).MakeGenericType(types), - 13 => typeof(Snapshot<,,,,,,,,,,,,>).MakeGenericType(types), - 14 => typeof(Snapshot<,,,,,,,,,,,,,>).MakeGenericType(types), - 15 => typeof(Snapshot<,,,,,,,,,,,,,,>).MakeGenericType(types), - 16 => typeof(Snapshot<,,,,,,,,,,,,,,,>).MakeGenericType(types), - 17 => typeof(Snapshot<,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 18 => typeof(Snapshot<,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 19 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 20 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 21 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 22 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 23 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 24 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 25 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 26 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 27 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 28 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 29 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - 30 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), - _ => throw new IndexOutOfRangeException(), - }; + { + 1 => typeof(Snapshot<>).MakeGenericType(types), + 2 => typeof(Snapshot<,>).MakeGenericType(types), + 3 => typeof(Snapshot<,,>).MakeGenericType(types), + 4 => typeof(Snapshot<,,,>).MakeGenericType(types), + 5 => typeof(Snapshot<,,,,>).MakeGenericType(types), + 6 => typeof(Snapshot<,,,,,>).MakeGenericType(types), + 7 => typeof(Snapshot<,,,,,,>).MakeGenericType(types), + 8 => typeof(Snapshot<,,,,,,,>).MakeGenericType(types), + 9 => typeof(Snapshot<,,,,,,,,>).MakeGenericType(types), + 10 => typeof(Snapshot<,,,,,,,,,>).MakeGenericType(types), + 11 => typeof(Snapshot<,,,,,,,,,,>).MakeGenericType(types), + 12 => typeof(Snapshot<,,,,,,,,,,,>).MakeGenericType(types), + 13 => typeof(Snapshot<,,,,,,,,,,,,>).MakeGenericType(types), + 14 => typeof(Snapshot<,,,,,,,,,,,,,>).MakeGenericType(types), + 15 => typeof(Snapshot<,,,,,,,,,,,,,,>).MakeGenericType(types), + 16 => typeof(Snapshot<,,,,,,,,,,,,,,,>).MakeGenericType(types), + 17 => typeof(Snapshot<,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 18 => typeof(Snapshot<,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 19 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 20 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 21 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 22 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 23 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 24 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 25 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 26 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 27 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 28 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 29 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + 30 => typeof(Snapshot<,,,,,,,,,,,,,,,,,,,,,,,,,,,,,>).MakeGenericType(types), + _ => throw new IndexOutOfRangeException(), + }; } /// @@ -5050,15 +5050,15 @@ public T GetValue(int index) public object? this[int index] { get => index switch - { - 0 => _value0, - _ => throw new IndexOutOfRangeException(), - }; + { + 0 => _value0, + _ => throw new IndexOutOfRangeException(), + }; set => _value0 = index switch - { - 0 => (T0)value!, - _ => throw new IndexOutOfRangeException(), - }; + { + 0 => (T0)value!, + _ => throw new IndexOutOfRangeException(), + }; } } } diff --git a/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs b/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs index aca7852abfe..a39f65bb3d5 100644 --- a/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs +++ b/src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs @@ -33,8 +33,8 @@ public virtual Func CreateEmpty(IEntityType entityType) return GetPropertyCount(entityType) == 0 ? (() => Snapshot.Empty) : Expression.Lambda>( - // TODO-Nullable: This whole code path is null unsafe. We are passing null parameter but later using parameter - // as if always exists. + // TODO-Nullable: This whole code path is null unsafe. We are passing null parameter but later using parameter + // as if always exists. CreateConstructorExpression(entityType, null!)) .Compile(); } diff --git a/src/EFCore/ChangeTracking/Internal/StateManager.cs b/src/EFCore/ChangeTracking/Internal/StateManager.cs index 9225ffa4668..948068ef400 100644 --- a/src/EFCore/ChangeTracking/Internal/StateManager.cs +++ b/src/EFCore/ChangeTracking/Internal/StateManager.cs @@ -82,6 +82,7 @@ public StateManager(StateManagerDependencies dependencies) UpdateLogger = dependencies.UpdateLogger; _changeTrackingLogger = dependencies.ChangeTrackingLogger; } + /// /// 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 @@ -731,7 +732,7 @@ public virtual void BeginAttachGraph() /// public virtual void CompleteAttachGraph() => Dependencies.NavigationFixer.CompleteAttachGraph(); - + /// /// 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 @@ -1175,9 +1176,10 @@ protected virtual async Task SaveChangesAsync( public virtual int SaveChanges(bool acceptAllChangesOnSuccess) => !Context.Database.AutoTransactionsEnabled ? SaveChanges(this, acceptAllChangesOnSuccess) - : Dependencies.ExecutionStrategy.Execute((StateManager: this, AcceptAllChangesOnSuccess: acceptAllChangesOnSuccess), - static (_, t) => SaveChanges(t.StateManager, t.AcceptAllChangesOnSuccess), - null); + : Dependencies.ExecutionStrategy.Execute( + (StateManager: this, AcceptAllChangesOnSuccess: acceptAllChangesOnSuccess), + static (_, t) => SaveChanges(t.StateManager, t.AcceptAllChangesOnSuccess), + null); private static int SaveChanges(StateManager stateManager, bool acceptAllChangesOnSuccess) { diff --git a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs index 84d07c99394..168f90dbe4b 100644 --- a/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs +++ b/src/EFCore/ChangeTracking/Internal/ValueGenerationManager.cs @@ -191,9 +191,9 @@ private static void SetGeneratedValue(InternalEntityEntry entry, IProperty prope } private static void MarkKeyUnknown( - InternalEntityEntry entry, - bool includePrimaryKey, - IProperty property, + InternalEntityEntry entry, + bool includePrimaryKey, + IProperty property, ValueGenerator valueGenerator) { if (includePrimaryKey diff --git a/src/EFCore/ChangeTracking/NavigationEntry.cs b/src/EFCore/ChangeTracking/NavigationEntry.cs index 831e236a85f..cbec6fae20f 100644 --- a/src/EFCore/ChangeTracking/NavigationEntry.cs +++ b/src/EFCore/ChangeTracking/NavigationEntry.cs @@ -127,7 +127,7 @@ private static INavigationBase GetNavigation(InternalEntityEntry internalEntry, /// /// A to observe while waiting for the task to complete. /// A task that represents the asynchronous operation. - /// If the is canceled. + /// If the is canceled. public abstract Task LoadAsync(CancellationToken cancellationToken = default); /// diff --git a/src/EFCore/ChangeTracking/ReferenceEntry.cs b/src/EFCore/ChangeTracking/ReferenceEntry.cs index d877302961d..c7d6bc93459 100644 --- a/src/EFCore/ChangeTracking/ReferenceEntry.cs +++ b/src/EFCore/ChangeTracking/ReferenceEntry.cs @@ -122,7 +122,7 @@ public override void Load() /// /// A to observe while waiting for the task to complete. /// A task that represents the asynchronous operation. - /// If the is canceled. + /// If the is canceled. public override Task LoadAsync(CancellationToken cancellationToken = default) => IsLoaded ? Task.CompletedTask diff --git a/src/EFCore/ChangeTracking/ValueComparer.cs b/src/EFCore/ChangeTracking/ValueComparer.cs index 9d0fce6103e..d336fc5a05c 100644 --- a/src/EFCore/ChangeTracking/ValueComparer.cs +++ b/src/EFCore/ChangeTracking/ValueComparer.cs @@ -5,7 +5,6 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Query; @@ -33,22 +32,22 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking public abstract class ValueComparer : IEqualityComparer, IEqualityComparer { private static readonly MethodInfo _doubleEqualsMethodInfo - = typeof(double).GetRequiredRuntimeMethod(nameof(double.Equals), new[] { typeof(double) }); + = typeof(double).GetRequiredRuntimeMethod(nameof(double.Equals), typeof(double)); private static readonly MethodInfo _floatEqualsMethodInfo - = typeof(float).GetRequiredRuntimeMethod(nameof(float.Equals), new[] { typeof(float) }); + = typeof(float).GetRequiredRuntimeMethod(nameof(float.Equals), typeof(float)); internal static readonly MethodInfo ArrayCopyMethod - = typeof(Array).GetRequiredRuntimeMethod(nameof(Array.Copy), new[] { typeof(Array), typeof(Array), typeof(int) }); + = typeof(Array).GetRequiredRuntimeMethod(nameof(Array.Copy), typeof(Array), typeof(Array), typeof(int)); internal static readonly MethodInfo EqualityComparerHashCodeMethod - = typeof(IEqualityComparer).GetRequiredRuntimeMethod(nameof(IEqualityComparer.GetHashCode), new[] { typeof(object) }); + = typeof(IEqualityComparer).GetRequiredRuntimeMethod(nameof(IEqualityComparer.GetHashCode), typeof(object)); internal static readonly MethodInfo EqualityComparerEqualsMethod - = typeof(IEqualityComparer).GetRequiredRuntimeMethod(nameof(IEqualityComparer.Equals), new[] { typeof(object), typeof(object) }); + = typeof(IEqualityComparer).GetRequiredRuntimeMethod(nameof(IEqualityComparer.Equals), typeof(object), typeof(object)); internal static readonly MethodInfo ObjectEqualsMethod - = typeof(object).GetRequiredRuntimeMethod(nameof(object.Equals), new[] { typeof(object), typeof(object) }); + = typeof(object).GetRequiredRuntimeMethod(nameof(object.Equals), typeof(object), typeof(object)); internal static readonly MethodInfo ObjectGetHashCodeMethod = typeof(object).GetRequiredRuntimeMethod(nameof(object.GetHashCode), Type.EmptyTypes); diff --git a/src/EFCore/ChangeTracking/ValueComparer`.cs b/src/EFCore/ChangeTracking/ValueComparer`.cs index 422d00a7bc0..5f0e6b3bf3a 100644 --- a/src/EFCore/ChangeTracking/ValueComparer`.cs +++ b/src/EFCore/ChangeTracking/ValueComparer`.cs @@ -26,7 +26,7 @@ namespace Microsoft.EntityFrameworkCore.ChangeTracking /// /// /// - /// See EF Core value comparers for more information. + /// See EF Core value comparers for more information. /// /// The type. public class ValueComparer : ValueComparer, IEqualityComparer diff --git a/src/EFCore/DbContext.cs b/src/EFCore/DbContext.cs index c4f45e3df03..e2a7d71cb03 100644 --- a/src/EFCore/DbContext.cs +++ b/src/EFCore/DbContext.cs @@ -55,7 +55,7 @@ namespace Microsoft.EntityFrameworkCore /// /// /// See DbContext lifetime, configuration, and initialization, - /// Querying data with EF Core, + /// Querying data with EF Core, /// Changing tracking, and /// Saving data with EF Core for more information. /// @@ -323,7 +323,7 @@ object IDbSetCache.GetOrAddSet(IDbSetSource source, string entityTypeName, Type /// /// /// - /// See Querying data with EF Core and + /// See Querying data with EF Core and /// Changing tracking for more information. /// /// The type of entity for which a set should be returned. @@ -342,7 +342,7 @@ public virtual DbSet Set() /// /// /// - /// See Querying data with EF Core, + /// See Querying data with EF Core, /// Changing tracking, and /// Shared entity types for more information. /// @@ -487,7 +487,7 @@ protected internal virtual void OnConfiguring(DbContextOptionsBuilder optionsBui /// /// Override this method to set defaults and configure conventions before they run. This method is invoked before - /// . + /// . /// /// /// If a model is explicitly set on the options for this context (via ) @@ -2141,6 +2141,7 @@ public virtual IQueryable FromExpression(Expression