Update error for "generic ViewComponents" to explain what a valid view component is #5380
Comments
I'm not entirely sure if we want to support generic ViewComponents due to how you can invoke a ViewComponent. IE At worst we should at least create a more readable error. |
After discussion with @NTaylorMullen @dougbu and @rynowak we decided to just update the error message to be more like:
Where X, Y, and Z are an indication of the criteria for being a view component, e.g.:
(I don't recall the exact rules.) |
Hi, from the code ( https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewComponentConventions.cs#L76 ), I think the rules is :
So the message could be :
|
@Eilon thoughts on this: Where {0}: nameof(MyViewComponent) |
Looks great! For (1) and (3) I would just change it to say |
Given the following example:
Trying to run this like so:
Results in the following:
The text was updated successfully, but these errors were encountered: