Check for RequiredAttribute when rendering fragment #584
linkdotnet
started this conversation in
Ideas
Replies: 1 comment 4 replies
-
Hi Steven, The EditorRequired works only at design time (e.g. in a supported editor afaik), which is why I decided not to add explicit support for it, since bUnit would be doing checks that Blazor doesn't do at runtime. Also, you could argue that you should be writing tests covering the cases where the "editor required" parameters are null. That said, I'm not opposed to adding that flag to the RenderComponent and Render methods, but I need to understand the use case a bit more. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
.NET 6 introduced the usage of the
RequiredAttribute
which gives you a nice little warning when the required parameter was not provided for your component. Due to the nature of how the component is built in unit tests, this falls short.Therefore it would be nice to get an exception if not provided. At least the explicitly enable this behavior if wished.
A small reference implementation (without the optional toggle) can be found here (including a test).
A bit more context can be found on the official Microsoft site.
Beta Was this translation helpful? Give feedback.
All reactions