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

Prevent Collection was modified; enumeration operation may not execute. #8959

Merged
merged 1 commit into from
Jun 26, 2017

Conversation

ajcvickers
Copy link
Contributor

Issue #8101

Happens when entities are inconsistently fixed up and do shenanigans in setters. (May also happen in other scenarios, but I was able to repro it this way.) Fix is to do defensive copy.

@@ -607,7 +607,7 @@ private void DeleteFixup(InternalEntityEntry entry)
{
if (principalToDependent.IsCollection())
{
var dependents = ((IEnumerable)navigationValue).Cast<object>();
var dependents = ((IEnumerable)navigationValue).Cast<object>().ToList();
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using ArrayList here to avoid allocating during Cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ArrayList requires an ICollection, but we only have an IEnumerable

Copy link
Contributor

Choose a reason for hiding this comment

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

Typical!

Issue #8101

Happens when entities are inconsistently fixed up and do shenanigans in setters. (May also happen in other scenarios, but I was able to repro it this way.) Fix is to do defensive copy.
@ajcvickers ajcvickers force-pushed the WhoMovedTheCheese0623 branch from 4007aac to 1a223ae Compare June 26, 2017 19:17
@ajcvickers ajcvickers merged commit 1a223ae into dev Jun 26, 2017
@bricelam bricelam deleted the WhoMovedTheCheese0623 branch June 27, 2017 15:58
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.

3 participants