Unseal attributes to allow extension #401
Replies: 5 comments 12 replies
-
Unsealing doesn't help much here. Since Mapperly is a source generator it reads the syntax / symbols of the code and extracts the configuration from it. This current implementation doesn't take inherited attributes into account. The thing you are trying to achieve was discussed here: #317 |
Beta Was this translation helpful? Give feedback.
-
Unsealing/Inheritable would allow us to derive our own MapperXYZ attributes with more flexible constructors, so instead of having to write this:
We would be writing this
Otherwise my team won't consider switching to Mapperly :) |
Beta Was this translation helpful? Give feedback.
-
Yeah, I saw in AttributeDataAccessor where it's instantiating the attribute so I did a quick POC to pickup my custom attribute name and it's all good. |
Beta Was this translation helpful? Give feedback.
-
Would using [MapProperty(StringOf(nameof(Car.Make.Id)), StringOf(nameof(CarDto.MakeId"))]
// or rename StringOf to Mem, Fno, S etc
[MapProperty(Mem(nameof(Car.Make.Id)), Mem(nameof(CarDto.MakeId"))] |
Beta Was this translation helpful? Give feedback.
-
This is now available in |
Beta Was this translation helpful? Give feedback.
-
One of the most annoying things in c# is the lack of a "fullnameof" operator, so we end up with code like this:
$"{nameof(Root)}.{nameof(Root.Parent)}.{nameof(Root.Parent.Child)}.{nameof(Root.Parent.Child.Id)}"
Thanks to the new [CallerArgumentExpression] attribute, there is a DRY workaround but it requires inheriting from an attribute to introduce a new constructor (or have the functionality exist in the base attribute already)
See: dotnet/csharplang#701 (comment)
Beta Was this translation helpful? Give feedback.
All reactions