ProxyInterfaceSourceGenerator icon indicating copy to clipboard operation
ProxyInterfaceSourceGenerator copied to clipboard

No source generation when annotated interface is explicitly internal

Open madp4ul opened this issue 2 years ago • 1 comments

Hi Stef,

i wanted to start a similar project today but aborted it since i found this and it perfectly fits the use case i had. It is really awesome, keep it up!

I found a small issue when trying it out: The source generation only runs when the annotated interface is "public partial" or just "partial", but not when it is "internal partial". In any case it generates a public part for the interface which exposes the proxied class through a property, which means that it can also not generate proxies for internal classes. Then it tries to expose the internal class via the generated public property in the generated public interface which gives a compile error.

For the typical use case this should not be an issue, as proxies are mostly needed for classes from third party libraries, which are public anyway. And since we usually need the interface for mocking in unit tests, it also generally has to be public. Still i though i might let you know about it.

I do much appreciate this library and am thinking about suggesting to use it at work soon. I think stuff like this deserves some more attention, thank you very much for this!

madp4ul avatar Jun 21 '23 20:06 madp4ul

Hello @madp4ul,

If you have time, you can create a PR to support internal.

And if you have more ideas, just create an issue.

StefH avatar Jun 22 '23 13:06 StefH