stronginject
stronginject copied to clipboard
Retrieving design-time info about registrations
I was wondering if I could use StrongInject to retrieve registrations at design time. At the moment I am writing a small Blazor game engine and I often need static information about implementations, for example: BaseEntity -MarioEntity -LuigiEntity
So if I register both entities, I could retrieve the list of all implementations using StrongInject, at compile/design time. Is this possible? Thanks in advance!
I would like to understand more about what you mean at compile time? What would you like StrongInject to generate?
Thank you for your fast reply! As StrongInject is aware of the registrations, I was wondering if I could retrieve the registrations of a certain interface/base class at design time. Does it have an API where I can ask: Give me all registrations of this interface/base class? For example: Container.GetRegistrationOf<BaseEntity>(). which autocompletes all the registrations so you can access their static members.
I'm afraid it doesn't have anything like that no. I'm interested in better understanding the use case to see if this might be something I would consider adding.
A really good use case is producing dependency diagrams for documentation and analysis. I often do these myself when code is relatively complex. I use an online editor like this one
The problem is that they get outdated really easily. And the microsoft diagram tools are really heavy and slowww. My suggestion would be to produce an optional JSON files with dependencies. And an API to process the file into any output. That way custom partial diagrams could be automatically generated and maintained automatically. I could see a developer adding a criteria such that only specific edges are included in a particular diagram. Possibly including dynamic cases.
I am actually looking at using strong inject in a project. Having this diagram would make the decision much easier.
If you wish I can help out on this. I doubt it would be too difficult. If anything the trick is what API would be best to offer.
https://mermaid-js.github.io is the markdown of graphs and it's supported natively on sites such as GitHub, so it may be worth a thought.