Open m-wild opened 3 years ago
I did some research and it looks like the way to accomplish this in AspNet Core is via ActionDescriptors.
See: https://stackoverflow.com/questions/41908957/get-all-registered-routes-in-asp-net-core Implementation: https://github.com/kobake/AspNetCore.RouteAnalyzer/blob/master/AspNetCore.RouteAnalyzer/Inner/RouteAnalyzerImpl.cs
I'm leaning towards creating a readonly collection similar to ActionDescriptionCollectionProvider.
I'll try a few things over the next week to see what makes the most sense.
Probably goes without saying, but I would not recommend the reflection route because there is no guarantee that will work into the future (though I have no plans to rewrite the internals on the roadmap right now).
Thanks @avishnyak ! Exposing it via a readonly collection sounds great.
We will not proceed with the reflection-based approach - this was just a proof of concept to see if we had enough information provided by MQTTnet.AspNetCore.AttributeRouting :)
Hi again @avishnyak Would you be happy to accept a PR if I were to implement this feature?
Thanks
Absolutely. My only request would be to ensure that you don't expose the internal routetable implementation. Rather, I would propose that we create a ReadOnly collection with a customer-friendly API.
When thinking about your usecase, my concern was you are asking for me to expose the pointer to the actual action as well as the metadata. In the customer-friendly API, I would propose that we only surface a property which will use reflection to return a MethodImpl and let the consumer take it from there rather than exposing our internal plumbing.
Hello everyone,
I am the maintainer of Saunter (https://github.com/tehmantra/saunter) - an AsyncAPI documentation generator (https://www.asyncapi.com/). Saunter works similarly to MQTTnet.AspNetCore.AttributeRouting, the user adds attributes to their code which describe the publishing or subscribing behavior which the code will implement.
I'd like to be able to provide an integration between Saunter and MQTTnet.AspNetCore.AttributeRouting so that we can re-use the attributes provided by MQTTnet.AspNetCore.AttributeRouting to produce the AsyncAPI document. This will allow the user to simply add Saunter to their project and have documentation produced without having to duplicate attributes like
[MqttController]
and[MqttRoute]
.To do this I need
public
access to theMqttRouteTable
(or some public interface on top of the implementation).I've currently implemented a proof-of-concept of this feature using reflection and, while ugly, it works. Please see this issue for details: https://github.com/tehmantra/saunter/issues/101#issuecomment-885444185
Is this something you would consider adding to the project?
/cc @Rikj000