-
Notifications
You must be signed in to change notification settings - Fork 932
Add check to ensure that IUserCollectionType.Instantiate returns uninitialized collection #415
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
Conversation
|
Interestingly , I ran into this issue a short time ago and I in my case it was because a generic IList could not be cast to a non-generic IList. The reference code lies In PersistentGenericList.cs: 42. That is from the source code for Build 3.3.4.GA. |
|
After some debugging I found out that this line, in the test, is the cause: Because the persistent collection is already given a wrapped collection, the persistent collection considers itself as initialized. Later on it is asked to check if it dirty, where it nullrefs because it hasn't got a snapshot (because it is considered initialized). This is confusing API behavior, and probably a check needs to written that |
|
Added the proposed check to the pull request and amended the test for this check. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Took even longer to return here. Can you please enable Allow edits from maintainers option on this PR? The documentation on nhibernate-core/src/NHibernate/UserTypes/IUserCollectionType.cs Lines 10 to 13 in dc71c7d
|
hazzik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code need to be aligned with the NHibernate's conventions.
I have a cleanup fix in place, I'll push it when option mentioned earlier be enabled.
This comment has been minimized.
This comment has been minimized.
…Instantiate returns an initialized collection. Add failing test for NH-3772.
hazzik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased and code cleaned up
8b63946 to
2f354bf
Compare
|
|
||
| namespace NHibernate.Test.NHSpecificTest.NH3772 | ||
| { | ||
| public class Fixture : TestCaseMappingByCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lacking TestFixture attribute, causing it to not generate an async counterpart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not generate async code because action delegate is declared outside of Assert.That(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but it still should have the attribute for consistency with other tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the attribute
The documentation on
IUserCollection.Instantiatealready says that the collection needs to be uninitialized:nhibernate-core/src/NHibernate/UserTypes/IUserCollectionType.cs
Lines 10 to 13 in dc71c7d
It would be nice to have a programmatic check that this assumption shall be true to prevent possible invalid or error-prone behaviour downstream.