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

feat: make targetMembers case sensitive #1077

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TimothyMakkison
Copy link
Collaborator

@TimothyMakkison TimothyMakkison commented Jan 21, 2024

Description

Having two members with case insensitive similar names would cause mapperly to fail. value & Value

  • Make TargetMember case sensitive
  • Added case insensitive member removal for constructors
  • Added a test

Fixes #1076

Checklist

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

Copy link

codecov bot commented Jan 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e606f93) 91.18% compared to head (1854967) 91.18%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1077      +/-   ##
==========================================
- Coverage   91.18%   91.18%   -0.01%     
==========================================
  Files         220      220              
  Lines        7203     7201       -2     
  Branches      915      915              
==========================================
- Hits         6568     6566       -2     
  Misses        418      418              
  Partials      217      217              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@latonz latonz left a comment

Choose a reason for hiding this comment

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

Thank you for this PR!

return BuilderContext
.SymbolAccessor.GetAllAccessibleMappableMembers(Mapping.TargetType)
.ToDictionary(x => x.Name, StringComparer.OrdinalIgnoreCase);
return BuilderContext.SymbolAccessor.GetAllAccessibleMappableMembers(Mapping.TargetType).ToDictionary(x => x.Name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't
src\Riok.Mapperly\Descriptors\MappingBodyBuilders\BuilderContext\NewInstanceBuilderContext.cs:10 and src\Riok.Mapperly\Descriptors\MappingBodyBuilders\BuilderContext\NewInstanceContainerBuilderContext.cs:17 have the same problems for configurations?

@@ -235,7 +235,7 @@ private static void BuildConstructorMapping(INewInstanceBuilderContext<IMapping>
continue;
}

ctx.TargetMembers.RemoveRange(mappedTargetMemberNames);
ctx.TargetMembers.RemoveRange(ctx.TargetMembers.Keys.Intersect(mappedTargetMemberNames, StringComparer.OrdinalIgnoreCase));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we should adjust this to use a similar approach to RootTargetNameCasingMapping, wdyt?

  • Create a case mapping dictionary
  • Use that dictionary to resolve correct casing in AddConstructorParameterMapping and remove from TargetMembers dictionary accordingly

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.

None yet

2 participants