All keys in local storage:
- @foreach (var key in keys)
+ @foreach (var key in Keys)
{
@key
}
@@ -56,22 +56,22 @@
@code {
- string NameFromLocalStorage { get; set; }
+ string? NameFromLocalStorage { get; set; }
int ItemsInLocalStorage { get; set; }
- string Name { get; set; }
+ string? Name { get; set; }
bool ItemExist { get; set; }
- IEnumerable keys { get; set; } = new List();
+ IEnumerable Keys { get; set; } = new List();
protected override async Task OnAfterRenderAsync(bool firstRender)
{
- keys = await localStorage.KeysAsync();
+ Keys = await localStorage.KeysAsync();
if (firstRender)
{
await GetNameFromLocalStorage();
await GetLocalStorageLength();
- localStorage.Changed += (sender, e) =>
+ localStorage.Changed += (_, e) =>
{
Console.WriteLine($"Value for key {e.Key} changed from {e.OldValue} to {e.NewValue}");
};
@@ -89,7 +89,7 @@
Name = "";
- keys = await localStorage.KeysAsync();
+ Keys = await localStorage.KeysAsync();
}
async Task GetNameFromLocalStorage()
diff --git a/samples/BlazorServer/Shared/NavMenu.razor b/samples/BlazorServer/Shared/NavMenu.razor
index dfeb93e..af3b2ed 100644
--- a/samples/BlazorServer/Shared/NavMenu.razor
+++ b/samples/BlazorServer/Shared/NavMenu.razor
@@ -16,12 +16,12 @@
@code {
- bool collapseNavMenu = true;
+ bool _collapseNavMenu = true;
- string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
+ string? NavMenuCssClass => _collapseNavMenu ? "collapse" : null;
void ToggleNavMenu()
{
- collapseNavMenu = !collapseNavMenu;
+ _collapseNavMenu = !_collapseNavMenu;
}
}
diff --git a/samples/BlazorWebAssembly/BlazorWebAssembly.csproj b/samples/BlazorWebAssembly/BlazorWebAssembly.csproj
index bcf4a6d..845189b 100644
--- a/samples/BlazorWebAssembly/BlazorWebAssembly.csproj
+++ b/samples/BlazorWebAssembly/BlazorWebAssembly.csproj
@@ -1,13 +1,13 @@
- net6.0
+ net7.0
-
-
-
+
+
+
diff --git a/samples/bUnitExample/bUnitExample.csproj b/samples/bUnitExample/bUnitExample.csproj
index fd0055b..53f6401 100644
--- a/samples/bUnitExample/bUnitExample.csproj
+++ b/samples/bUnitExample/bUnitExample.csproj
@@ -1,19 +1,19 @@
- net6.0
+ net7.0
-
-
-
-
-
+
+
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
diff --git a/src/Blazored.LocalStorage.TestExtensions/Blazored.LocalStorage.TestExtensions.csproj b/src/Blazored.LocalStorage.TestExtensions/Blazored.LocalStorage.TestExtensions.csproj
index b224316..a907a80 100644
--- a/src/Blazored.LocalStorage.TestExtensions/Blazored.LocalStorage.TestExtensions.csproj
+++ b/src/Blazored.LocalStorage.TestExtensions/Blazored.LocalStorage.TestExtensions.csproj
@@ -1,10 +1,10 @@
- net6.0;net5.0
+ net6.0;net7.0
Chris Sainty
-
+ Chris Sainty
Copyright 2020 (c) Chris Sainty. All rights reserved.
A testing library to provide helper extensions for Blazored.LocalStorage
true
@@ -26,12 +26,16 @@
..\..\src\Blazored.LocalStorage\Blazored.LocalStorage.snk
+
+
+
+
-
+
@@ -50,13 +54,4 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Blazored.LocalStorage/Blazored.LocalStorage.csproj b/src/Blazored.LocalStorage/Blazored.LocalStorage.csproj
index be624df..2724322 100644
--- a/src/Blazored.LocalStorage/Blazored.LocalStorage.csproj
+++ b/src/Blazored.LocalStorage/Blazored.LocalStorage.csproj
@@ -1,10 +1,10 @@
- net6.0;net5.0
+ net6.0;net7.0
Chris Sainty
-
+ Chris Sainty
Copyright 2020 (c) Chris Sainty. All rights reserved.
A library to provide access to local storage in Blazor applications
true
@@ -26,18 +26,18 @@
Blazored.LocalStorage.snk
-
+
-
-
-
-
+
+
+
+
@@ -58,13 +58,4 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Blazored.LocalStorage/BrowserStorageProvider.cs b/src/Blazored.LocalStorage/BrowserStorageProvider.cs
index da14daf..f5ce6f0 100644
--- a/src/Blazored.LocalStorage/BrowserStorageProvider.cs
+++ b/src/Blazored.LocalStorage/BrowserStorageProvider.cs
@@ -160,11 +160,6 @@ public async ValueTask RemoveItemsAsync(IEnumerable keys, CancellationTo
{
try
{
- if (keys == null)
- {
- return;
- }
-
foreach (var key in keys)
{
await _jSRuntime.InvokeVoidAsync("localStorage.removeItem", cancellationToken, key);
diff --git a/tests/Blazored.LocalStorage.Tests/Blazored.LocalStorage.Tests.csproj b/tests/Blazored.LocalStorage.Tests/Blazored.LocalStorage.Tests.csproj
index 39b0049..a35e393 100644
--- a/tests/Blazored.LocalStorage.Tests/Blazored.LocalStorage.Tests.csproj
+++ b/tests/Blazored.LocalStorage.Tests/Blazored.LocalStorage.Tests.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net7.0
false
@@ -11,16 +11,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive