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: incorrect initialization for nullable nested memberpath unflattening #591

Merged
merged 1 commit into from Jul 25, 2023

Conversation

TimothyMakkison
Copy link
Collaborator

@TimothyMakkison TimothyMakkison commented Jul 24, 2023

Fix incorrect initialzation code for nested nullable members when unflattening

Description

When using MapProperty to map to deeply nested nullable members, Mapperly will generate a series of identical statements initializing the same field. This is because all the MemberNullAssignmentInitializerMapping mistakenly use the same IReadOnlyCollection so will all update the same path.

Added a ToArray to ObjectPathNullableSubPaths to collect the paths into separate collections.

Example bug

var target = new global::B();
target.Value.Nested ??= new();
target.Value.Nested ??= new();
target.Value.Nested ??= new();
target.Value.Nested.Id = source.MyValueId;
target.Value.Nested.Id2 = source.MyValueId2;
return target;

Checklist

  • The existing code style is followed
  • The commit message follows our guidelines
  • Performed a self-review of my code
  • Unit tests are added/updated

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Merging #591 (746c793) into main (208e8b4) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #591   +/-   ##
=======================================
  Coverage   90.59%   90.59%           
=======================================
  Files         173      173           
  Lines        5921     5921           
  Branches      757      757           
=======================================
  Hits         5364     5364           
  Misses        397      397           
  Partials      160      160           
Files Changed Coverage Δ
src/Riok.Mapperly/Symbols/MemberPath.cs 83.13% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@latonz latonz enabled auto-merge (squash) July 25, 2023 16:18
@latonz latonz merged commit 9b74e8f into riok:main Jul 25, 2023
14 checks passed
@TimothyMakkison TimothyMakkison deleted the nest_null_unflatten branch July 25, 2023 16:28
@github-actions
Copy link

🎉 This PR is included in version 2.9.0-next.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

None yet

2 participants