Mapster icon indicating copy to clipboard operation
Mapster copied to clipboard

Source Generators with IMapper Interface

Open ismkdc opened this issue 1 year ago • 4 comments

Hello, I am using mapster with fec and I am very happy :) But i am curious about something.. Is there any way for using source generators which is Mapster.Tool and IMapper interface?

So I want to still inject IMapper interface to my classes but I want use source generated mappings.

ismkdc avatar Aug 19 '23 20:08 ismkdc

I too was searching for it. It would certainly be great to have!

EmreAka avatar Aug 19 '23 20:08 EmreAka

If there is Source Generator supports for IMapper, that would take Mapster a few steps up. It would be the most common library for AOT base apps. I'd like to contribute to this development tho!

salihcantekin avatar Aug 20 '23 09:08 salihcantekin

I think this is a great suggestion, however there may be a showstopper. Currently only netstandard2.0 assemblies can be used as source generators. Since Mapster and its constituent components are all net6.0/net7.0/net8.0 currently, I think it's currently not possible to run a source generator from Mapster. I might be wrong, this is just based on a quick readup on requirements for source generators, so I'm eager to hear your thoughts on this. It might be theoretically possible to bring netstandard2.0 back into Mapster, but it requires quite a few code changes since Mapster now relies on features not available in netstandard2.0.

andrerav avatar Sep 26 '23 21:09 andrerav

I think that this is not an issue anymore

luizfbicalho avatar Feb 07 '24 17:02 luizfbicalho