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

Fix for the optimizer when an entity has a collection property that references itself. #27350

Merged
merged 2 commits into from
Feb 4, 2022

Conversation

leniency
Copy link
Contributor

@leniency leniency commented Feb 2, 2022

Fix for the optimizer when an entity has a collection property that references itself. An example would be a Json.Net's JArray. It implements IEnumerable<JToken>, which in turn implements IEnumerable<JToken>. This caused an infinite loop and stack overflow exception in CSharpRuntimeModelCodeGenerator.AddNamespace

  • Added a check if the sequence type matches the parameter type to break the inifinite loop.
  • Added unit test with self-referential collection type. If the unit test doesn't stack overflow, can be considered successful.

Fixes #27301

…e T that implements a IEnumerable<T> (such as Json.net's JArray) causes and infinity loop when adding namespaces. Added a check for the sequence type's namespace so it won't attempt to re-add.
@dnfadmin
Copy link

dnfadmin commented Feb 2, 2022

CLA assistant check
All CLA requirements met.

@leniency leniency changed the title Issue27301 Issue 27301 - Optimizer hangs on properties implementing a referential collection Feb 2, 2022
@smitpatel smitpatel closed this Feb 3, 2022
@smitpatel smitpatel reopened this Feb 3, 2022
@AndriySvyryd AndriySvyryd changed the title Issue 27301 - Optimizer hangs on properties implementing a referential collection Fix for the optimizer when an entity has a collection property that references itself. Feb 4, 2022
@AndriySvyryd AndriySvyryd merged commit 80bb7b3 into dotnet:main Feb 4, 2022
@AndriySvyryd
Copy link
Member

Thanks for your contribution!

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.

Optimize hangs and stops responding.
4 participants