MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.23k stars 325 forks source link

Source Generators with IMapper Interface #622

Open ismkdc opened 10 months ago

ismkdc commented 10 months ago

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.

EmreAka commented 10 months ago

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

salihcantekin commented 10 months ago

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!

andrerav commented 9 months ago

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.

luizfbicalho commented 5 months ago

I think that this is not an issue anymore