-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add helper methods for constructing a RazorComponentResult #47094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for contacting us. We're moving this issue to the |
I'm quoting from the PR and commenting here to avoid clogging up the work you are doing. From #47023:
We designed the Even though the framework is taking advantage of the feature here, it still strikes me as the best place to put the creator method, all things considered. The alternatives mentioned aren't super discoverable and run the risk of masking the feature. What was the weirdness with using the |
The fact that it feels like a place for 2nd-class APIs that aren't really native to the system. Overall though, is there a reason why we guide people to write code like If it were my choice I'd prefer to recommend code like: endpoints.Map("/mypage", () => new RazorComponentResult<MyPageComponent>()) ... rather than: endpoints.Map("/mypage", () => Results.Extensions.RazorComponent<MyPageComponent>()) However it's not a big deal! If the developers working on Minimal API have a vision of a particular aesthetic then it seems like that's what we should really go for. |
At the moment, the concrete result types don't have public constructors. There's not an overwhelmingly strong reason to not have public constructs for them. In fact, we've discussed having public constructors in .NET 7 but ultimately stuck with the static creation methods since that was what was historically supported and there were questions about the value of constructors for certain types that didn't have any extension data. See #40802. cc: @halter73 who can share additional context on the API review that occurred for public
Yep, this is an understandable reservation. I'd like to think a static method being on the
My preference for this is #2, #1, #3, #4. Open to other thoughts or proposals that might not be the 4 listed above. Edit: Option #5 is taking advantage of the upcoming extensions feature in C# to support this scenario. |
I think the main thing is discoverability. Another benefit of methods over constructors is that the generic argument can sometimes be inferred from the argument types. With constructors, you always have to specify the type parameter(s). |
OK, thanks for the info @captainsafia and @halter73! The discovery rationale definitely makes sense.
True, but anyone authoring a result type is always free to define their own static factory methods that offer the same type inference. For now I'm just not going to prioritize creating any special helpers for this and we can see how the situation evolves. Maybe we can use an upcoming C# language feature. Or maybe people will be fine with |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
thanks to RazorComponentResult its open blazor to wildest scenario and more easier... |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
This is to follow up on #47023 (comment) and #47023 (comment)
Currently, you have to construct a RazorComponentResult manually, e.g.:
For consistency with other built-in result types, we probably also want helpers so you can do things like:
The text was updated successfully, but these errors were encountered: