Skip to content
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

Limit change tracking proxies to only changing _and_ changed strategies #22278

Merged
merged 3 commits into from
Aug 28, 2020

Conversation

ajcvickers
Copy link
Member

Fixes #21920

@ajcvickers ajcvickers requested a review from a team August 27, 2020 20:09
@ajcvickers
Copy link
Member Author

@Pilchie RC1

@ajcvickers
Copy link
Member Author

/cc @JonPSmith FYI

break;
if (!_notifyPropertyChangingInterface.IsAssignableFrom(entityType.ClrType))
{
interfacesToProxy.Add(_notifyPropertyChangingInterface);
Copy link
Member

Choose a reason for hiding this comment

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

If interfacesToProxy is empty we shouldn't create a proxy for change tracking

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do this in another PR

Copy link
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

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

Additional things to fix in the next PR:

  • Currently context.CreateProxy<Dictionary<string, object>>() throws "The entity type '{entityType}' was not found. Ensure that the entity type has been added to the model.". If the type is shared or weak we should instead suggest calling context.Set<T>("TypeName").CreateProxy()
  • If change tracking proxies are enabled and there are entity types using Dictionary<string, object> with non-PK properties we should throw in ProxyChangeTrackingConvention.OnModelFinalized

@AndriySvyryd
Copy link
Member

We should also validate that if the entity type is set up to use proxies then CreateProxy is used to create the instance to be tracked. (The type of the entity should at least differ from the CLR type specified in the entity type)

@ajcvickers
Copy link
Member Author

@AndriySvyryd Yes, we require all properties to be virtual, but we're missing checking indexer properties--that was one of the issues I mentioned on the call earlier. This is the only reason our tests are passing right now. No foot shooting allowed.

For lazy-loading proxies, you don't have to create a proxy instance, but for change tracking proxies we don't allow you to use a non-proxy instance. This can be a pain, but prevents some serious foot shooting.

@Pilchie
Copy link
Member

Pilchie commented Aug 27, 2020

Approved for RC1

@ajcvickers ajcvickers merged commit 250912d into release/5.0 Aug 28, 2020
@ajcvickers ajcvickers deleted the RiddleMeAProxy0826 branch August 28, 2020 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit change tracking proxies to only changing _and_ changed strategies
3 participants