Just wondering if it's a flaw in the analyzer or it's on purpose. While following the docs to get a
code behind experience. The analyzer is throwing the warning to make the parameters of the component Private, however if we want to use the parameters in the .cshtml they have to be public.
MyButton.cshtml
@inherits MyButton
<button>
@Text
</button>
MyButton.cs
public class MyButton : BlazorComponent
{
[Parameter] public string Text { get; set; }
}
Then again, which road are we heading towards, more Code Behind exp. or rather mixing both via Functions, which is preferred?
Thx!
A workaround i use is to make the property protected instead of public.
@zefubachs is correct - use protected.
But it's not really a "workaround", it's the expected and standard way to share otherwise private state with a derived class.
Most helpful comment
A workaround i use is to make the property
protectedinstead ofpublic.