Skip to content

Commit 4743594

Browse files
authored
fix: Address nullability issues and suppress warnings in various components (#1406)
1 parent 8211454 commit 4743594

13 files changed

Lines changed: 22 additions & 19 deletions

File tree

‎blazorbootstrap/Components/Accordion/AccordionItem.razor.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ protected override void OnParametersSet()
3030
private async Task OnCollapseHiddenAsync()
3131
{
3232
if (Parent is not null && Parent.OnHidden.HasDelegate)
33-
await Parent.OnHidden.InvokeAsync(new AccordionEventArgs(Name, Title));
33+
await Parent.OnHidden.InvokeAsync(new AccordionEventArgs(Name!, Title!));
3434
}
3535

3636
private async Task OnCollapseHidingAsync()
3737
{
3838
isCollapsed = true;
3939

4040
if (Parent is not null && Parent.OnHiding.HasDelegate)
41-
await Parent.OnHiding.InvokeAsync(new AccordionEventArgs(Name, Title));
41+
await Parent.OnHiding.InvokeAsync(new AccordionEventArgs(Name!, Title!));
4242
}
4343

4444
private async Task OnCollapseShowingAsync()
4545
{
4646
isCollapsed = false;
4747

4848
if (Parent is not null && Parent.OnShowing.HasDelegate)
49-
await Parent.OnShowing.InvokeAsync(new AccordionEventArgs(Name, Title));
49+
await Parent.OnShowing.InvokeAsync(new AccordionEventArgs(Name!, Title!));
5050
}
5151

5252
private async Task OnCollapseShownAsync()
5353
{
5454
if (Parent is not null && Parent.OnShown.HasDelegate)
55-
await Parent.OnShown.InvokeAsync(new AccordionEventArgs(Name, Title));
55+
await Parent.OnShown.InvokeAsync(new AccordionEventArgs(Name!, Title!));
5656
}
5757

5858
private async Task ToggleAsync() => await collapse.ToggleAsync();

‎blazorbootstrap/Components/Form/AutoComplete/AutoComplete.razor.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected override async Task OnInitializedAsync()
6262

6363
AdditionalAttributes ??= new Dictionary<string, object>();
6464

65-
fieldIdentifier = FieldIdentifier.Create(ValueExpression);
65+
fieldIdentifier = FieldIdentifier.Create(ValueExpression!);
6666

6767
// check the default value is assigned.
6868
if (Value is not null && Value.Length > 0)
@@ -173,7 +173,7 @@ private async Task FilterDataAsync(CancellationToken cancellationToken = default
173173
if (string.IsNullOrWhiteSpace(searchKey))
174174
return;
175175

176-
var request = new AutoCompleteDataProviderRequest<TItem> { Filter = new FilterItem(PropertyName, searchKey, GetFilterOperator(), StringComparison), CancellationToken = cancellationToken };
176+
var request = new AutoCompleteDataProviderRequest<TItem> { Filter = new FilterItem(PropertyName!, searchKey, GetFilterOperator(), StringComparison), CancellationToken = cancellationToken };
177177

178178
if (DataProvider != null)
179179
{

‎blazorbootstrap/Components/Grid/Grid.razor‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
}
323323
else if (column.SummaryType != GridSummaryColumnType.None)
324324
{
325-
<td class="@column.TextAlignment.ToTextAlignmentClass()">@GetColumnSummaryValue(column.SummaryType, column.PropertyName, column.SummaryValueDisplayFormat, column.SummaryValuePrefix)</td>
325+
<td class="@column.TextAlignment.ToTextAlignmentClass()">@GetColumnSummaryValue(column.SummaryType, column.PropertyName!, column.SummaryValueDisplayFormat, column.SummaryValuePrefix)</td>
326326
}
327327
}
328328
}

‎blazorbootstrap/Components/Grid/Grid.razor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public async Task ExportToCsvAsync()
232232
.Where(column => column.Filterable && column.GetFilterOperator() != FilterOperator.None && !string.IsNullOrWhiteSpace(column.GetFilterValue()))
233233
?.Select(column => new FilterItem(column.PropertyName!, column.GetFilterValue(), column.GetFilterOperator(), column.StringComparison));
234234

235-
private string GetColumnSummaryValue(GridSummaryColumnType type, string propertyName, string format, string prefix)
235+
private string GetColumnSummaryValue(GridSummaryColumnType type, string propertyName, string? format, string? prefix)
236236
{
237237
double value = 0;
238238

‎blazorbootstrap/Components/Markdown/Markdown.razor‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
@inherits BlazorBootstrapComponentBase
33

44
<div @ref="@Element" id="@Id" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes">
5-
@((MarkupString)html)
5+
@((MarkupString)(html ?? string.Empty))
66
</div>

‎blazorbootstrap/Components/Markdown/Markdown.razor.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,9 @@ private List<string> GetLines()
589589
var builder = new RenderTreeBuilder();
590590
ChildContent.Invoke(builder);
591591

592+
// The markdown source is read from the rendered ChildContent markup frames.
593+
// Blazor exposes no public API for that, so BL0006 is suppressed for this block only.
594+
#pragma warning disable BL0006
592595
var frames = builder.GetFrames().Array;
593596

594597
foreach (var frame in frames)
@@ -599,6 +602,7 @@ private List<string> GetLines()
599602
if (lines.Any())
600603
inputs.AddRange(lines);
601604
}
605+
#pragma warning restore BL0006
602606
}
603607

604608
if (inputs.Any())

‎blazorbootstrap/Components/Progress/ProgressBar.razor.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public void SetWidth(double width)
101101
// FIX: Toast progressbar not showing: https://github.com/vikramlearning/blazorbootstrap/issues/155
102102
($"width:{width.ToString(CultureInfo.InvariantCulture)}%", width is >= 0 and <= 100));
103103

104+
// Color, Type and Width re-render the bar when SetColor, SetWidth, IncreaseWidth and DecreaseWidth
105+
// change them, so they keep their setters. BL0007 is suppressed for these three parameters only.
106+
#pragma warning disable BL0007
107+
104108
/// <summary>
105109
/// Gets or sets the progress color.
106110
/// <para>
@@ -172,6 +176,7 @@ public double Width
172176
StateHasChanged();
173177
}
174178
}
179+
#pragma warning restore BL0007
175180

176181
#endregion
177182
}

‎blazorbootstrap/Components/Ribbon/Ribbon.razor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private async Task ShowTabAsync(RibbonTab tab)
278278
await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.tabs.show", tab.Id);
279279

280280
if (tab?.OnClick.HasDelegate ?? false)
281-
await tab.OnClick.InvokeAsync(new TabEventArgs(tab!.Name, tab.Title));
281+
await tab.OnClick.InvokeAsync(new TabEventArgs(tab.Name!, tab.Title!));
282282
}
283283

284284
#endregion

‎blazorbootstrap/Components/Ribbon/RibbonTab.razor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected override void OnInitialized()
9393
/// Gets or sets the parent ribbon.
9494
/// </summary>
9595
[CascadingParameter(Name = "Ribbon1")]
96-
internal Ribbon? Parent { get; set; }
96+
internal Ribbon Parent { get; set; } = default!;
9797

9898
/// <summary>
9999
/// Gets or sets the tab title.

‎blazorbootstrap/Components/SortableList/SortableList.razor.cs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ public partial class SortableList<TItem> : BlazorBootstrapComponentBase
88
{
99
#region Fields and Constants
1010

11-
/// <summary>
12-
/// A cancellation token source for managing asynchronous operations.
13-
/// </summary>
14-
private CancellationTokenSource cancellationTokenSource = default!;
15-
1611
/// <summary>
1712
/// A CSS selector used to filter disabled items.
1813
/// </summary>

0 commit comments

Comments
 (0)