diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 5c0bc03..ab8a2c8 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -7,7 +7,7 @@ on: types: [ published ] env: - NETCORE_VERSION: '6.0.x' + NETCORE_VERSION: '7.0.x' DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: true PROJECT_NAME: LocalStorage diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 8fbd145..ac76c7f 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -5,7 +5,7 @@ on: branches: [ main ] env: - NETCORE_VERSION: '6.0.100' + NETCORE_VERSION: '7.0.100' PROJECT_NAME: Blazored.LocalStorage jobs: diff --git a/Blazored.LocalStorage.sln b/Blazored.LocalStorage.sln index 8234643..59cfa9e 100644 --- a/Blazored.LocalStorage.sln +++ b/Blazored.LocalStorage.sln @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .github\workflows\ci-pr.yml = .github\workflows\ci-pr.yml README.md = README.md .github\workflows\release-drafter.yml = .github\workflows\release-drafter.yml + Directory.Build.props = Directory.Build.props EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B82A5126-EE01-4B4D-B642-F954B6E4E695}" diff --git a/Directory.Build.props b/Directory.Build.props index 8f64684..1e28886 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,9 +2,8 @@ - 3.1.14 - 5.0.5 6.0.0 + 7.0.0 \ No newline at end of file diff --git a/samples/BlazorServer/BlazorServer.csproj b/samples/BlazorServer/BlazorServer.csproj index 4622db9..5ca1537 100644 --- a/samples/BlazorServer/BlazorServer.csproj +++ b/samples/BlazorServer/BlazorServer.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 enable enable diff --git a/samples/BlazorServer/NewtonSoftJsonSerializer.cs b/samples/BlazorServer/NewtonSoftJsonSerializer.cs index c37118a..180fdba 100644 --- a/samples/BlazorServer/NewtonSoftJsonSerializer.cs +++ b/samples/BlazorServer/NewtonSoftJsonSerializer.cs @@ -1,13 +1,13 @@ -using Blazored.LocalStorage.Serialization; -using Newtonsoft.Json; - -namespace BlazorServer; - -public class NewtonSoftJsonSerializer : IJsonSerializer -{ - public T Deserialize(string text) - => JsonConvert.DeserializeObject(text); - - public string Serialize(T obj) - => JsonConvert.SerializeObject(obj); -} +using Blazored.LocalStorage.Serialization; +using Newtonsoft.Json; + +namespace BlazorServer; + +public class NewtonSoftJsonSerializer : IJsonSerializer +{ + public T? Deserialize(string text) + => JsonConvert.DeserializeObject(text); + + public string Serialize(T obj) + => JsonConvert.SerializeObject(obj); +} diff --git a/samples/BlazorServer/Pages/Error.cshtml.cs b/samples/BlazorServer/Pages/Error.cshtml.cs index 67ebdb8..99c8d80 100644 --- a/samples/BlazorServer/Pages/Error.cshtml.cs +++ b/samples/BlazorServer/Pages/Error.cshtml.cs @@ -1,32 +1,32 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; - -namespace WebApplication2.Pages -{ - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - [IgnoreAntiforgeryToken] - public class ErrorModel : PageModel - { - public string RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - private readonly ILogger _logger; - - public ErrorModel(ILogger logger) - { - _logger = logger; - } - - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - } - } -} +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApplication2.Pages +{ + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [IgnoreAntiforgeryToken] + public class ErrorModel : PageModel + { + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/samples/BlazorServer/Pages/Index.razor b/samples/BlazorServer/Pages/Index.razor index a94c1db..60b3dc8 100644 --- a/samples/BlazorServer/Pages/Index.razor +++ b/samples/BlazorServer/Pages/Index.razor @@ -47,7 +47,7 @@
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