feat: forward additional mapping method parameters#2193
Open
feat: forward additional mapping method parameters#2193
Conversation
3105679 to
01e20d0
Compare
…ilderContext Always allow additional parameters in BuildUserImplementedMapping (remove allowAdditionalParameters parameter — was true at all call sites)
… parameter tracking
- MapPropertyFromSource(Use=...) unsatisfiable params → RMG097 - MapValue(Use=...) partially matching params → RMG096 + RMG082 - Nested mapping with multiple additional params - MappingTarget + MapProperty(Use=...) with params - Param consumed only by Use method → no false RMG082 - Param consumed only by nested mapping → no false RMG082 - Multiple unused params → multiple RMG082 - Init-only and constructor params from additional parameters - Nested projection inlining with additional params - Collection mapping test for additional parameter forwarding
fix: move diagnostics to AnalyzerReleases.Shipped.md and add diagnostic docs Per contributing guidelines: - Move RMG096/RMG097 from Unshipped to Shipped (Mapperly does not use Unshipped) - Add RMG096.mdx and RMG097.mdx diagnostic documentation pages
…nal parameters Projections with additional parameters now only pick up MapProperty/ MapPropertyFromSource configurations from element mappings whose additional parameters match. No fallback to default element mappings that ignore the parameters. Projections without additional parameters continue to use the default element mapping as before.
…meters feat: support additional parameters on external and MapPropertyFromSource Use methods - Remove IsExternal guard from BuildArguments in UserImplementedMethodMapping and UserImplementedExistingTargetMethodMapping — external mapper methods now forward additional parameters like internal ones - Always allow additional parameters in BuildUserImplementedMapping (remove allowAdditionalParameters parameter — was true at all call sites) - Enable MapPropertyFromSource(Use=...) with additional parameters by discovering user-implemented methods with extra params during initial extraction
…nd TryUseParameters
09facb6 to
4d0ce3d
Compare
… ParameterScope When a non-empty scope is passed, Find performs a parameterized-only lookup; otherwise it does the regular dictionary lookup. This removes the separate FindUserMappingWithParameters method from the entire chain.
…eterizedUserMapping Mark parameters as used directly in FindByParameters, eliminating the need for a separate FindParameterizedUserMapping wrapper. This simplifies FindOrBuildMapping and FindOrBuildLooseNullableMapping cascades.
…ficient parameterized lookup
…n SourceValueBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Additional parameters on mapping methods (beyond source/target/referenceHandler) are now forwarded to user-defined nested mapping methods,
MapValue(Use=...),MapProperty(Use=...), andMapPropertyFromSource(Use=...)methods.Works with queryable projections - additional parameters become captured variables in the generated expression.
Parameters are matched by name, but mappings to map them when types don't match are not generated. It is more complex to support that. Should I add type checks while that is not supported? Currently, parameter
string ctxwill matchint ctxbut will produce a non-compilable code.Besides unit tests, I have tested it on real project and parameterized mapping methods and projections were generated correctly.
Note: I have used Claude, but I was steering is constantly - no vibecoding
Fixes #1472
Fixes #1765 (user needs to define mappings with parameters)
Supersedes #1946
Checklist