After updating to net.7 we are getting Warnings for our Blazor Components.
Heres an example
Warning BL0007: Component parameter 'WebCenter.Layout.Shared.Components.InfoCheckbox.Checked' should be auto property
I know how to handle the warning when i have a method inside of the Component
you can call CheckedChanged.InvokeAsync(); inside of the method.
But in this component i have no method that is being called.
Is there a way to get around the warning? Like another way to bind to the <DxCheckBox> or something like that?
If i just convert the property Checked to an auto property the caller does not get the correct value.
any help would be great…
Razor<div class="wrapper mb-2">
<DxCheckBox @bind-Checked="Checked" CssClass="stretch-TextBox">@Label</DxCheckBox>
<button class="btn btn-secondary button-min-31 m-l-5" type="button" data-toggle="collapse" data-target="@_idd" aria-expanded="false" aria-controls="collapseExample">
<span class="fas fa-info">
</span>
</button>
</div>
<div class="collapse" id="@_id">
<div class="card card-body">
@ChildContent
</div>
</div>
@code {
[Parameter]
public string Label { get; set; } = default!;
// Raises Warning BL0007
[Parameter]
public bool Checked
{
get => _checked;
set
{
if (_checked == value) return;
_checked = value;
CheckedChanged.InvokeAsync(value);
}
}
[Parameter]
public RenderFragment ChildContent { get; set; } = default!;
[Parameter]
public EventCallback<bool> CheckedChanged { get; set; }
private bool _checked;
protected override void OnInitialized()
{
_id = $"spinner{Guid.NewGuid():N}";
_idd = $"#{_id}";
}
private string _id = default!;
private string _idd = default!;
}
example of a caller
Razor<DxFormLayoutItem Caption="@Resources.App.DisplayFQDN" ColSpanMd="12" CssClass="m-b-5">
<Template>
<InfoCheckbox @bind-Checked="settings.ValidateIPAddressOnPrintServerImport" Label="@Resources.App.DisplayFQDN">
@this.Raw(Resources.App.ValidateIPAddressOnPrintServerImportDescription)
</InfoCheckbox>
</Template>
</DxFormLayoutItem>
We have the same problem with DxSpinEdit