Open jjonescz opened 3 months ago
@jjonescz Does this still occur when using AddComponentParameter
instead of AddAttribute
?
@chsienki It's not possible to use AddComponentParameter, that's only for components, this is about normal HTML elements.
@jjonescz Gotcha, thanks for the clarification.
In a
.razor
component:Note that passing
null
to an attribute is a supported scenario: https://learn.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-7.0#conditional-attribute-rendering. Although perhaps it doesn't make much sense to pass a literal@null
but rather via some variable.It also works fine in
.cshtml
.Related:
I think compiler cannot do much here, we don't analyze the user-written C# code. At most we could offer an analyzer to fix this by casting.