Open
Description
Is your feature request related to a problem? Please describe.
This is related to my question here #16874 (comment)
I think it would be a good idea to expose the current Renderer instances publicly so we can change the instance and write decorator around it.
Why is that needed ?
In the past few month I needed it for 2 reasons :
- Implement MiniProfiler for Blazor, I cannot find any hook for measuring all the rendering. I did it with a base component class but this is far from being right or clean IMO.
- When I tried to implement my own Form validation I wanted to access the component hierarchy (so in an input component I could easily get the parent form component), but couldn't find anyway to do this. You did it with cascading parameter.
Describe the solution you'd like
I see multiple ways for doing this :
- Instead of building those by hand and keeping the instance around, rely on DI container. Even if injecting decorator with Microsoft.Extensions.DependencyInjection is not easy but doable (https://andrewlock.net/adding-decorated-classes-to-the-asp.net-core-di-container-using-scrutor/)
- Expose a class (like RendererRegistry) but for all Renderer types and enable the replacing of a renderer.
- Expose hooks on component creation and rendering for library author to use
Additional context
Renderer and ComponentState are huge classes and I would understand why you don't want to expose it (more documentation needed, more issues ...), maybe we can find a common ground with my third solution, this would be a great addition for library authors IMHO ? If we validate a design I can work on a PR.