Skip to content

Commit

Permalink
Removes .NET 5 target and adds .NET 7 (#193)
Browse files Browse the repository at this point in the history
* Removed .NET 5 target and added .NET 7

* Updated test project to target .NET 7
  • Loading branch information
chrissainty committed Nov 9, 2022
1 parent 4122c6e commit 1027325
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [ main ]

env:
NETCORE_VERSION: '6.0.100'
NETCORE_VERSION: '7.0.100'
PROJECT_NAME: Blazored.LocalStorage

jobs:
Expand Down
1 change: 1 addition & 0 deletions Blazored.LocalStorage.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 1 addition & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<Project>

<PropertyGroup Label="Package Versions">
<DotNet3Version>3.1.14</DotNet3Version>
<DotNet5Version>5.0.5</DotNet5Version>
<DotNet6Version>6.0.0</DotNet6Version>
<DotNet7Version>7.0.0</DotNet7Version>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion samples/BlazorServer/BlazorServer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
26 changes: 13 additions & 13 deletions samples/BlazorServer/NewtonSoftJsonSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Blazored.LocalStorage.Serialization;
using Newtonsoft.Json;

namespace BlazorServer;

public class NewtonSoftJsonSerializer : IJsonSerializer
{
public T Deserialize<T>(string text)
=> JsonConvert.DeserializeObject<T>(text);

public string Serialize<T>(T obj)
=> JsonConvert.SerializeObject(obj);
}
using Blazored.LocalStorage.Serialization;
using Newtonsoft.Json;

namespace BlazorServer;

public class NewtonSoftJsonSerializer : IJsonSerializer
{
public T? Deserialize<T>(string text)
=> JsonConvert.DeserializeObject<T>(text);

public string Serialize<T>(T obj)
=> JsonConvert.SerializeObject(obj);
}
64 changes: 32 additions & 32 deletions samples/BlazorServer/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -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<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> 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<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
14 changes: 7 additions & 7 deletions samples/BlazorServer/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="row">
<div class="col-md-12">
<h5>All keys in local storage:</h5>
@foreach (var key in keys)
@foreach (var key in Keys)
{
<span>@key &nbsp;</span>
}
Expand All @@ -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<string> keys { get; set; } = new List<string>();
IEnumerable<string> Keys { get; set; } = new List<string>();

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}");
};
Expand All @@ -89,7 +89,7 @@

Name = "";

keys = await localStorage.KeysAsync();
Keys = await localStorage.KeysAsync();
}

async Task GetNameFromLocalStorage()
Expand Down
6 changes: 3 additions & 3 deletions samples/BlazorServer/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
</div>

@code {
bool collapseNavMenu = true;
bool _collapseNavMenu = true;

string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
string? NavMenuCssClass => _collapseNavMenu ? "collapse" : null;

void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
_collapseNavMenu = !_collapseNavMenu;
}
}
8 changes: 4 additions & 4 deletions samples/BlazorWebAssembly/BlazorWebAssembly.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet6Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="$(DotNet6Version)" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(DotNet7Version)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="$(DotNet7Version)" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="$(DotNet7Version)" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions samples/bUnitExample/bUnitExample.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="bunit.core" Version="1.6.4" />
<PackageReference Include="bunit.web" Version="1.6.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="bunit.core" Version="1.12.6" />
<PackageReference Include="bunit.web" Version="1.12.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>

<Authors>Chris Sainty</Authors>
<Company></Company>
<Company>Chris Sainty</Company>
<Copyright>Copyright 2020 (c) Chris Sainty. All rights reserved.</Copyright>
<Description>A testing library to provide helper extensions for Blazored.LocalStorage</Description>
<IncludeSymbols>true</IncludeSymbols>
Expand All @@ -26,12 +26,16 @@
<AssemblyOriginatorKeyFile>..\..\src\Blazored.LocalStorage\Blazored.LocalStorage.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\src\Blazored.LocalStorage\icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="bunit.core" Version="1.6.4" />
<PackageReference Include="bunit.core" Version="1.12.6" />
</ItemGroup>

<ItemGroup>
Expand All @@ -50,13 +54,4 @@
<None Include="..\Blazored.LocalStorage\Blazored.LocalStorage.snk" Link="Blazored.LocalStorage.snk" />
</ItemGroup>

<!-- Microsoft.Extensions.Logging.Abstractions 6.0.0-preview.5.21301.5 introduced the analyzer which is not present
in .net5 or .netcore3.1 therefore we have to remove the analyzer otherwise the build will fail
-->
<Target Name="RemoveLoggingAnalyzer" BeforeTargets="CoreCompile" Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'Microsoft.Extensions.Logging.Generators'" />
</ItemGroup>
</Target>

</Project>
23 changes: 7 additions & 16 deletions src/Blazored.LocalStorage/Blazored.LocalStorage.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>

<Authors>Chris Sainty</Authors>
<Company></Company>
<Company>Chris Sainty</Company>
<Copyright>Copyright 2020 (c) Chris Sainty. All rights reserved.</Copyright>
<Description>A library to provide access to local storage in Blazor applications</Description>
<IncludeSymbols>true</IncludeSymbols>
Expand All @@ -26,18 +26,18 @@
<AssemblyOriginatorKeyFile>Blazored.LocalStorage.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0'">
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet5Version)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet6Version)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="$(DotNet7Version)" />
</ItemGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="\" />
</ItemGroup>
Expand All @@ -58,13 +58,4 @@
</AssemblyAttribute>
</ItemGroup>

<!-- Microsoft.Extensions.Logging.Abstractions 6.0.0-preview.5.21301.5 introduced the analyzer which is not present
in .net5 or .netcore3.1 therefore we have to remove the analyzer otherwise the build will fail
-->
<Target Name="RemoveLoggingAnalyzer" BeforeTargets="CoreCompile" Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'Microsoft.Extensions.Logging.Generators'" />
</ItemGroup>
</Target>

</Project>
5 changes: 0 additions & 5 deletions src/Blazored.LocalStorage/BrowserStorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ public async ValueTask RemoveItemsAsync(IEnumerable<string> keys, CancellationTo
{
try
{
if (keys == null)
{
return;
}

foreach (var key in keys)
{
await _jSRuntime.InvokeVoidAsync("localStorage.removeItem", cancellationToken, key);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand All @@ -11,16 +11,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="System.Text.Json" Version="5.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="System.Text.Json" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.3">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 1027325

Please sign in to comment.