Skip to content
This repository was archived by the owner on Dec 26, 2025. It is now read-only.

Commit 1027325

Browse files
authored
Removes .NET 5 target and adds .NET 7 (#193)
* Removed .NET 5 target and added .NET 7 * Updated test project to target .NET 7
1 parent 4122c6e commit 1027325

15 files changed

Lines changed: 93 additions & 112 deletions

File tree

.github/workflows/ci-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
types: [ published ]
88

99
env:
10-
NETCORE_VERSION: '6.0.x'
10+
NETCORE_VERSION: '7.0.x'
1111
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
1212
DOTNET_CLI_TELEMETRY_OPTOUT: true
1313
PROJECT_NAME: LocalStorage

.github/workflows/ci-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches: [ main ]
66

77
env:
8-
NETCORE_VERSION: '6.0.100'
8+
NETCORE_VERSION: '7.0.100'
99
PROJECT_NAME: Blazored.LocalStorage
1010

1111
jobs:

Blazored.LocalStorage.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
.github\workflows\ci-pr.yml = .github\workflows\ci-pr.yml
1818
README.md = README.md
1919
.github\workflows\release-drafter.yml = .github\workflows\release-drafter.yml
20+
Directory.Build.props = Directory.Build.props
2021
EndProjectSection
2122
EndProject
2223
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B82A5126-EE01-4B4D-B642-F954B6E4E695}"

Directory.Build.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
<Project>
33

44
<PropertyGroup Label="Package Versions">
5-
<DotNet3Version>3.1.14</DotNet3Version>
6-
<DotNet5Version>5.0.5</DotNet5Version>
75
<DotNet6Version>6.0.0</DotNet6Version>
6+
<DotNet7Version>7.0.0</DotNet7Version>
87
</PropertyGroup>
98

109
</Project>

samples/BlazorServer/BlazorServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using Blazored.LocalStorage.Serialization;
2-
using Newtonsoft.Json;
3-
4-
namespace BlazorServer;
5-
6-
public class NewtonSoftJsonSerializer : IJsonSerializer
7-
{
8-
public T Deserialize<T>(string text)
9-
=> JsonConvert.DeserializeObject<T>(text);
10-
11-
public string Serialize<T>(T obj)
12-
=> JsonConvert.SerializeObject(obj);
13-
}
1+
using Blazored.LocalStorage.Serialization;
2+
using Newtonsoft.Json;
3+
4+
namespace BlazorServer;
5+
6+
public class NewtonSoftJsonSerializer : IJsonSerializer
7+
{
8+
public T? Deserialize<T>(string text)
9+
=> JsonConvert.DeserializeObject<T>(text);
10+
11+
public string Serialize<T>(T obj)
12+
=> JsonConvert.SerializeObject(obj);
13+
}
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
using Microsoft.AspNetCore.Mvc;
2-
using Microsoft.AspNetCore.Mvc.RazorPages;
3-
using Microsoft.Extensions.Logging;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Diagnostics;
7-
using System.Linq;
8-
using System.Threading.Tasks;
9-
10-
namespace WebApplication2.Pages
11-
{
12-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13-
[IgnoreAntiforgeryToken]
14-
public class ErrorModel : PageModel
15-
{
16-
public string RequestId { get; set; }
17-
18-
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
19-
20-
private readonly ILogger<ErrorModel> _logger;
21-
22-
public ErrorModel(ILogger<ErrorModel> logger)
23-
{
24-
_logger = logger;
25-
}
26-
27-
public void OnGet()
28-
{
29-
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
30-
}
31-
}
32-
}
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Microsoft.Extensions.Logging;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Diagnostics;
7+
using System.Linq;
8+
using System.Threading.Tasks;
9+
10+
namespace WebApplication2.Pages
11+
{
12+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13+
[IgnoreAntiforgeryToken]
14+
public class ErrorModel : PageModel
15+
{
16+
public string? RequestId { get; set; }
17+
18+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
19+
20+
private readonly ILogger<ErrorModel> _logger;
21+
22+
public ErrorModel(ILogger<ErrorModel> logger)
23+
{
24+
_logger = logger;
25+
}
26+
27+
public void OnGet()
28+
{
29+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
30+
}
31+
}
32+
}

samples/BlazorServer/Pages/Index.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<div class="row">
4848
<div class="col-md-12">
4949
<h5>All keys in local storage:</h5>
50-
@foreach (var key in keys)
50+
@foreach (var key in Keys)
5151
{
5252
<span>@key &nbsp;</span>
5353
}
@@ -56,22 +56,22 @@
5656

5757
@code {
5858

59-
string NameFromLocalStorage { get; set; }
59+
string? NameFromLocalStorage { get; set; }
6060
int ItemsInLocalStorage { get; set; }
61-
string Name { get; set; }
61+
string? Name { get; set; }
6262
bool ItemExist { get; set; }
63-
IEnumerable<string> keys { get; set; } = new List<string>();
63+
IEnumerable<string> Keys { get; set; } = new List<string>();
6464

6565
protected override async Task OnAfterRenderAsync(bool firstRender)
6666
{
67-
keys = await localStorage.KeysAsync();
67+
Keys = await localStorage.KeysAsync();
6868

6969
if (firstRender)
7070
{
7171
await GetNameFromLocalStorage();
7272
await GetLocalStorageLength();
7373

74-
localStorage.Changed += (sender, e) =>
74+
localStorage.Changed += (_, e) =>
7575
{
7676
Console.WriteLine($"Value for key {e.Key} changed from {e.OldValue} to {e.NewValue}");
7777
};
@@ -89,7 +89,7 @@
8989

9090
Name = "";
9191

92-
keys = await localStorage.KeysAsync();
92+
Keys = await localStorage.KeysAsync();
9393
}
9494

9595
async Task GetNameFromLocalStorage()

samples/BlazorServer/Shared/NavMenu.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
</div>
1717

1818
@code {
19-
bool collapseNavMenu = true;
19+
bool _collapseNavMenu = true;
2020

21-
string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
21+
string? NavMenuCssClass => _collapseNavMenu ? "collapse" : null;
2222

2323
void ToggleNavMenu()
2424
{
25-
collapseNavMenu = !collapseNavMenu;
25+
_collapseNavMenu = !_collapseNavMenu;
2626
}
2727
}

samples/BlazorWebAssembly/BlazorWebAssembly.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet6Version)" />
9-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="$(DotNet6Version)" PrivateAssets="all" />
10-
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
8+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet7Version)" />
9+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="$(DotNet7Version)" PrivateAssets="all" />
10+
<PackageReference Include="System.Net.Http.Json" Version="$(DotNet7Version)" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

0 commit comments

Comments
 (0)