Injectio icon indicating copy to clipboard operation
Injectio copied to clipboard

Feature request: Control the visibility of `DiscoveredServicesExtensions`

Open alexrp opened this issue 2 years ago • 2 comments

Hi!

Thanks for putting this project together. It's saved me a fair bit of boilerplate. 🙂

I was wondering if it would be possible to add an MSBuild property to control the visibility of the generated DiscoveredServicesExtensions class? Specifically, here:

https://github.com/loresoft/Injectio/blob/89941f30bd4de823c4ca16c31bc3cddb1352548b/src/Injectio.Generators/ServiceRegistrationWriter.cs#L50-L54

In my solution, I have a few different projects for different areas of the application. Each such project already exposes a <Project>ServiceCollectionExtensions class with methods to register everything. This class needs to stay because, even when using Injectio, there are various essential services defined outside the assembly that also need to be added (e.g. ASP.NET Core stuff, AddOptions<T>(), etc...). So I figure I'll just call Injectio's generated method from there. That means exposing DiscoveredServicesExtensions publicly isn't necessary (and kind of a trap since it lacks those essential service registrations).

I figure this feature could just look something like <InjectioVisibility>internal</InjectioVisibility> (defaulting to public).

alexrp avatar Aug 22 '23 09:08 alexrp

seems reasonable, I'll add it to list of things todo. thanks for the suggestion.

pwelter34 avatar Aug 23 '23 14:08 pwelter34

Any update on this request? I'd benefit from this greatly as I have a similar setup within some of my projects.

I'd be happy to author and submit a pull request to add this if that is preferable.

MysterDru avatar Sep 09 '24 13:09 MysterDru

This feature is implemented InjectioInternal property

pwelter34 avatar Feb 16 '25 14:02 pwelter34