Conversation
|
For some reason, the test failed after I merged the main branch to my branch :( Update: this configuration no longer works. |
| /// <see cref="TData"/> needs to have an accessible ctor with the parameters 0 to n-1 to be of type <see cref="ITypeSymbol"/>. | ||
| /// <see cref="TData"/> needs to have exactly the same constructors as <see cref="TAttribute"/> with additional type arguments. | ||
| /// </summary> | ||
| /// <param name="attributes">The attributes data.</param> |
There was a problem hiding this comment.
Add the new param in the xml docs.
| } | ||
|
|
||
| internal static TData Access<TAttribute, TData>(AttributeData attrData, SymbolAccessor? symbolAccessor = null) | ||
| internal static TData Access<TAttribute, TData>(AttributeData attrData, SymbolAccessor? symbolAccessor = null, bool rever = false) |
There was a problem hiding this comment.
Type rever should probably be reverse...
| public class ReverseMappingTest | ||
| { | ||
| [Fact] | ||
| public Task BasicReverseMappingShouldWork() |
There was a problem hiding this comment.
Please also add an integration test.
| public class ReverseMappingTest | ||
| { | ||
| [Fact] | ||
| public Task BasicReverseMappingShouldWork() |
There was a problem hiding this comment.
IMO this test can be removed as it doesn't add real value to ReverseMappingWithMultiplePropertiesShouldWork
| } | ||
|
|
||
| [Fact] | ||
| public Task ReverseMappingWithUseConverterShouldWork() |
There was a problem hiding this comment.
I don't think we use the term Converter
| [Fact(Skip = "Didn't add a check")] | ||
| public Task ReverseMappingShouldReportCircularReference() | ||
| { | ||
| var source = TestSourceBuilder.MapperWithBodyAndTypes( | ||
| """ | ||
| [MapProperty(nameof(Product.Price), nameof(ProductDTO.PriceInEuro))] | ||
| [IncludeMappingConfiguration(nameof(ToProduct), Reverse = true)] | ||
| public static partial ProductDTO ToDTO(this Product source); | ||
|
|
||
| [IncludeMappingConfiguration(nameof(ToDTO), Reverse = true)] | ||
| public static partial void ToProduct(this ProductDTO source, Product target); | ||
| """, | ||
| "class Product { public decimal Price { get; set; } }", | ||
| "class ProductDTO { public decimal PriceInEuro { get; set; } }" | ||
| ); | ||
|
|
||
| return TestHelper.VerifyGenerator(source); | ||
| } | ||
|
|
||
| [Fact( | ||
| Skip = "It should work similarly to mapping nested properties. However, the MapNestedProperties class only works with the source." | ||
| )] | ||
| // ProductDTO.Id = Product.Info.Id | ||
| // Reverse | ||
| // Product.Info.Id = ProductDTO.Id | ||
| public Task ReverseMappingWithMapNestedPropertiesShouldWork() |
There was a problem hiding this comment.
Could you provide more info here? Why are these ignored?
| } | ||
|
|
||
| [Fact] | ||
| // Reverse Target to Source to calm down report |
There was a problem hiding this comment.
What does calm down report mean?
| ); | ||
| } | ||
|
|
||
| private EnumMappingConfiguration BuildEnumConfig(MappingConfigurationReference configRef) |
There was a problem hiding this comment.
Is there a specific reason for reordering the members? It creates a lot of noise in the diff, making it difficult to review the actual logic changes. I haven't reviewed this file yet.
Add Reverse Mapping Support
Description
Implements reverse mapping functionality for Mapperly with a new
Reverseproperty onIncludeMappingConfigurationAttribute. Automatically swaps source/target types and reverses member configurations for bidirectional mapping.Key changes:
IReversible<T>interface patternFixes # (issue)
Checklist
Example
#1250