Skip to content

Refactor InternalEntityEntry in preparation for complex collection support #36165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndriySvyryd
Copy link
Member

Extract InternalEntryBase
Remove IInternalEntry.Object
Move common change-tracking code to TypeBase
Fix some model building issues related to complex types

Part of #31237

@AndriySvyryd AndriySvyryd requested a review from Copilot May 30, 2025 19:18
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner May 30, 2025 19:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the internal change-tracking infrastructure to prepare for complex collection support by extracting InternalEntryBase, removing IInternalEntry.Object, and moving common change-tracking code to TypeBase.

  • Updates method signatures and parameter types to use IInternalEntry for better abstraction.
  • Introduces new state management via InternalEntryBase.StateData and adjusts snapshot and relationship handling.
  • Adjusts EF Core scaffolding and collection entry code to support complex types and collections.

Reviewed Changes

Copilot reviewed 208 out of 208 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/EFCore/ChangeTracking/Internal/ShadowValuesFactoryFactory.cs Adjusts GetPropertyCount signature and uses new indexer syntax for shadow values.
src/EFCore/ChangeTracking/Internal/RelationshipSnapshotFactoryFactory.cs Changes GetPropertyCount signature and safely casts structuralType where necessary.
src/EFCore/ChangeTracking/Internal/OriginalValuesFactoryFactory.cs Updates GetPropertyCount to use structuralType.Counts.OriginalValueCount.
src/EFCore/ChangeTracking/Internal/InternalEntryBase.StateData.cs New file adding bit-level state management and property flag handling.
src/EFCore/ChangeTracking/Internal/InternalEntryBase.SidecarValues.cs Updates signature by renaming to InternalEntryBase.
src/EFCore/ChangeTracking/Internal/InternalEntryBase.OriginalValues.cs Updates parameter types to use InternalEntryBase and revised OriginalValues factory.
src/EFCore/ChangeTracking/Internal/InternalEntityEntryNotifier.cs Changes method signatures to use IInternalEntry.
src/EFCore/ChangeTracking/Internal/IInternalEntry.cs Removes IInternalEntry.Object and adds properties/methods to support the new design.
src/EFCore/ChangeTracking/Internal/IChangeDetector.cs Updates change notification methods to use IInternalEntry.
src/EFCore/ChangeTracking/Internal/EmptyShadowValuesFactoryFactory.cs Signature updates for GetPropertyCount consistent with new types.
src/EFCore/ChangeTracking/Internal/ChangeDetector.cs Updates change detection logic and method signatures to use IInternalEntry with necessary casts.
src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs Uses new collection expression syntax for initializing properties.
src/EFCore/ChangeTracking/ComplexPropertyEntry`.cs Updates constructor parameter from InternalEntityEntry to IInternalEntry and property access.
src/EFCore/ChangeTracking/ComplexPropertyEntry.cs Similar constructor and IsModified changes for complex properties.
src/EFCore/ChangeTracking/CollectionEntry`.cs Adjusts property access and collection query logic to use InternalEntityEntry consistently.
src/EFCore/ChangeTracking/CollectionEntry.cs Updates collection entry code to work with the refactored change-tracking types.
src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs Introduces support for complex collections and updates generated counts accordingly.
Comments suppressed due to low confidence (3)

src/EFCore/ChangeTracking/ComplexPropertyEntry`.cs:34

  • The file name contains an unexpected backtick (`). Consider renaming the file to remove the backtick for consistency.
public ComplexPropertyEntry(IInternalEntry internalEntry, IComplexProperty complexProperty)

src/EFCore/ChangeTracking/CollectionEntry`.cs:62

  • The file name includes an extraneous backtick (`); consider renaming the file to remove it for consistency with project naming conventions.
=> new(InternalEntityEntry);

src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs:111

  • The use of the collection expression syntax initializes _properties as an array rather than a List as before. Verify that downstream code expecting a List is updated or that the array behavior is acceptable.
=> _properties ??= [.. EntityType.GetFlattenedProperties()];

@AndriySvyryd AndriySvyryd force-pushed the Issue31237_Refactor branch from 2e36662 to 4ff6876 Compare May 30, 2025 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant