Skip to content

Conversation

ValResnick
Copy link
Contributor

@ValResnick ValResnick commented Sep 8, 2025

Fixes #3622

private readonly string entityName;
private readonly System.Type mappedClass;

private readonly string[] originalUninitializedFields;
Copy link
Member

@hazzik hazzik Sep 22, 2025

Choose a reason for hiding this comment

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

This seems to be same as uninitializedFieldsReadOnly

It is possible to update content of read-only set by updating underlying collection.

It is expected that some tests will fail because they depend on that behavior.
this.entityName = entityName;
this.mappedClass = mappedClass;
this.uninitializedFieldsReadOnly = uninitializedFields != null ? new ReadOnlySet<string>(uninitializedFields) : null;
this.uninitializedFieldsReadOnly = uninitializedFields != null ? new ReadOnlySet<string>(new HashSet<string>(uninitializedFields)) : null;
Copy link
Member

@hazzik hazzik Sep 22, 2025

Choose a reason for hiding this comment

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

There was a bug that ReadOnlySet is not really read-only

It was possible to update content of read-only set by updating underlying collection.

Some tests were depend on that behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is definitely an improvement, but I'd like to know more before I change it. So I added an extra variable.

public ISet<string> GetUninitializedFields()
{
return uninitializedFieldsReadOnly ?? CollectionHelper.EmptySet<string>();
return uninitializedFields ?? CollectionHelper.EmptySet<string>();
Copy link
Member

@hazzik hazzik Sep 22, 2025

Choose a reason for hiding this comment

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

Needed to return uninitializedFields, because some tests were depending on the of ReadOnlySet.

@hazzik hazzik changed the title Fixes issue 3622: ISession.Refresh updates initialized lazy properties Fix ISession.Refresh does not update initialized lazy properties Sep 22, 2025
@hazzik hazzik added the t: Fix label Sep 22, 2025
@hazzik hazzik changed the title Fix ISession.Refresh does not update initialized lazy properties Fix ISession.Refresh not updating initialized lazy properties Sep 22, 2025
@hazzik hazzik enabled auto-merge (squash) September 22, 2025 06:18
@hazzik hazzik added this to the 5.6 milestone Sep 22, 2025
@hazzik hazzik merged commit 86e05bf into nhibernate:master Sep 22, 2025
27 checks passed
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.

ISession.Refresh does not update lazy properties
2 participants