Comments (7)
π This issue has been resolved in version 2.7.0-next.2 π
The release is available on:
- GitHub release
v2.7.0-next.2
Your semantic-release bot π¦π
from mapperly.
Thank you for this report. This is definitely something which needs improvement.
from mapperly.
I was trying to find a stop gap solution for this same exact problem (also doing gRPC mappings) and found the following generate code that seems right, but sadly the parent generator doesn't seem to find the void mapping methods:
private partial void MapToFooBars(List<FooBarModel>? source, RepeatedField<FooBarMessage> target)
Generates:
if (source == null)
return;
target.Capacity = source.Capacity;
target.this[] = MapToFooBar(source.this[]);
from mapperly.
Its similar for dictionaries in generated grpc code. Those are MapFields which also only have a getter. Basically you have to copy the contents from one to the other.
There is a convenience method for this on the MapField however: .Add(IDictionary<string, string>)
so in this case I'd expect that the mapper calls this. Is there any way to tell the mapper to deal with a certain field by providing a void method that takes the mapped and to map object?
from mapperly.
Hoping to open a PR for this asap, but it looks like right now mapperly won't map any readonly properties, but I think it would be fairly safe to default to a model of mapping readonly properties for reference types via existing ref mappers (map(source, target)) and leave open the possibility of doing the same for value types in the future via (map(source, ref target)), which means we may as well do both types using ref. Trying my hand at it to see how complex this is.
from mapperly.
Mapperly currently only supports object to object mappings in void mapping methods (thats why the implementation for private partial void MapToFooBars(List<FooBarModel>? source, RepeatedField<FooBarMessage> target)
is generated as it is. For such cases the diagnostics should definitely be improved and indexed properties should not be mapped.). Mapperly only generates an implementation for void mapping methods, but does not consider them when looking for / generating a mapping for one type to another.
The main problem here is that Mapperly maps to a property by calling the setter of a property and therefore only takes target properties with an accessible setter into account. As described by @heggi, for collection properties this needs to be adjusted to map to read only collection properties by calling Add/AddRange. Would be very happy to accept any PR implementing this.
from mapperly.
π This issue has been resolved in version 2.7.0 π
The release is available on:
- GitHub release
v2.7.0
Your semantic-release bot π¦π
from mapperly.
Related Issues (20)
- Support additional parameter value during mapping HOT 1
- Support AutoMapperβs `IMapper` to simplify migration HOT 4
- Show analyzer messages in rider during development HOT 1
- How can I obtain the changed field values after mapping two entities? HOT 1
- Can we map Google.Protobuf.WellKnownTypes to equivalent C# type HOT 2
- How to use constructor mapping and properties' mapping simultaneously HOT 7
- Local (mapping method level) for AllowNullPropertyAssignment
- feat: forward null values into the mapping function (if supported) when specified on property level HOT 3
- Reverse mappings HOT 3
- MapProperty.Use: Default + non-default user mappings generate wrong (chained) mapping code HOT 3
- Disabled nullability and MapPropertyAttribute.Use results in invalid generated code HOT 5
- Compile error when switching from 3.5.1-next.1 to 3.5.1-next.2 or 3.5.1 HOT 4
- Not discovering map when parent takes generic type and is located on different assembly HOT 6
- Use UserMapping as global configuration HOT 1
- Support generic mappings HOT 2
- Unexpected IQueryable mapping when project's Nullable flag is set to "disable" HOT 3
- Use existing mapping rules from an "existing target object" map on a "new instance" map HOT 2
- Using source object as source property and/or coalesce 2+ source props HOT 2
- Many to many relationship mapping makes the app crash and exit with "Access violation" HOT 2
- Allow the usage of external methods with `MapProperty.Use` and `MapPropertyFromSource.Use` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapperly.