ekonbenefits / impromptu-interface

Static interface to dynamic implementation (duck casting). Uses the DLR combined with Reflect.Emit.
Apache License 2.0
654 stars 67 forks source link

Source generators #45

Open nicomoya123 opened 3 years ago

nicomoya123 commented 3 years ago

I want to implement something similar to this package using the new source generators package, Do you think it will be possible ?

jbtule commented 3 years ago

Yeah I think it's possible, for the explicit generic argument ActLike.

As making the proxies is trivial source wise. just an object implementing an interface where each method is just forwarding the call to a dynamic typed _target. Just have to identify each place you use it.

goyzhang commented 3 years ago

What if a method is not implemented in the target class. In that case, ActLike can compile and run as long as you don't call it. But the source generator won't compile and you need to have an exact match?