Skip to content

Commit

Permalink
fixed CA1868: Unnecessary call to 'Contains' for sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmys20 committed Nov 19, 2023
1 parent fec2d32 commit 07d223b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public static IEnumerable<Customer> GetCustomers()
{
return new List<Customer>()
{
new Customer { Id = 1, Name = "Jim", Index = 0 },
new Customer { Id = 2, Name = "George", Index = 2 },
new Customer { Id = 3, Name = "John", Index = 5 },
new Customer { Id = 4, Name = "Lisa", Index = 9 },
new() { Id = 1, Name = "Jim", Index = 0 },
new() { Id = 2, Name = "George", Index = 2 },
new() { Id = 3, Name = "John", Index = 5 },
new() { Id = 4, Name = "Lisa", Index = 9 },
};
}
}
10 changes: 4 additions & 6 deletions src/Jimmys20.BlazorComponents/GridLayout/JmGridLayout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public partial class JmGridLayout<T>

private int Capacity => _columns.Count * _rows.Count;

private readonly List<JmGridLayoutColumn<T>> _columns = new();
private readonly List<JmGridLayoutRow<T>> _rows = new();
private readonly List<JmGridLayoutColumn<T>> _columns = [];
private readonly List<JmGridLayoutRow<T>> _rows = [];

protected override void OnParametersSet()
{
Expand All @@ -102,18 +102,16 @@ internal void AddRow(JmGridLayoutRow<T> gridLayoutRow)

internal void RemoveColumn(JmGridLayoutColumn<T> gridLayoutColumn)
{
if (_columns.Contains(gridLayoutColumn))
if (_columns.Remove(gridLayoutColumn))
{
_columns.Remove(gridLayoutColumn);
StateHasChanged();
}
}

internal void RemoveRow(JmGridLayoutRow<T> gridLayoutRow)
{
if (_rows.Contains(gridLayoutRow))
if (_rows.Remove(gridLayoutRow))
{
_rows.Remove(gridLayoutRow);
StateHasChanged();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>1.1.4</Version>
<Version>1.1.5</Version>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Description>Collection of various Blazor components.</Description>
Expand Down

0 comments on commit 07d223b

Please sign in to comment.