Skip to content

Commit

Permalink
Add support for .NET 9
Browse files Browse the repository at this point in the history
- drop support for .NET 6.0 and 7.0
  • Loading branch information
jsakamoto committed Dec 19, 2024
1 parent cbb2da5 commit 548dae9
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 109 deletions.
59 changes: 23 additions & 36 deletions HotKeys2.E2ETest/HotKeysOnBrowserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ namespace Toolbelt.Blazor.HotKeys2.E2ETest;

public class HotKeysOnBrowserTest
{
public static IEnumerable<HostingModel> AllHostingModels { get; } = new[] {
HostingModel.Wasm60,
HostingModel.Wasm70,
HostingModel.Wasm80,
HostingModel.Server60,
HostingModel.Server70,
HostingModel.Server80,
};

public static IEnumerable<HostingModel> WasmHostingModels { get; } = new[] {
HostingModel.Wasm60,
HostingModel.Wasm70,
HostingModel.Wasm80,
};
public static IEnumerable<HostingModel> AllHostingModels { get; } = [
HostingModel.Wasm80,
HostingModel.Wasm90,
HostingModel.Server80,
HostingModel.Server90,
];

public static IEnumerable<HostingModel> WasmHostingModels { get; } = [
HostingModel.Wasm80,
HostingModel.Wasm90,
];

[Test]
[TestCaseSource(typeof(HotKeysOnBrowserTest), nameof(AllHostingModels))]
Expand Down Expand Up @@ -57,19 +54,19 @@ public async Task HotKey_on_Body_Test(HostingModel hostingModel)
await page.Keyboard.UpAsync("u");
await page.AssertEqualsAsync(_ => counter.TextContentAsync(), "Current count: 2");

// Show and hide the cheatSeetElement by entering "?" and ESC key.
var cheatSeetElement = page.Locator(".popup-container");
(await cheatSeetElement.IsVisibleAsync()).IsFalse();
// Show and hide the cheatSheetElement by entering "?" and ESC key.
var cheatSheetElement = page.Locator(".popup-container");
(await cheatSheetElement.IsVisibleAsync()).IsFalse();

await page.Keyboard.DownAsync("Shift"); // Enter "?"
await page.Keyboard.DownAsync("Slash");
await page.Keyboard.UpAsync("Slash");
await page.Keyboard.UpAsync("Shift");
await page.AssertEqualsAsync(_ => cheatSeetElement.IsVisibleAsync(), true);
await page.AssertEqualsAsync(_ => cheatSheetElement.IsVisibleAsync(), true);

await page.Keyboard.DownAsync("Escape");
await page.Keyboard.UpAsync("Escape");
await page.AssertEqualsAsync(_ => cheatSeetElement.IsVisibleAsync(), false);
await page.AssertEqualsAsync(_ => cheatSheetElement.IsVisibleAsync(), false);

// Double hit of Ctrl key makes jump to the "Home" page.
await page.AssertUrlIsAsync(host.GetUrl("/counter"));
Expand All @@ -93,12 +90,12 @@ public async Task AllowIn_Input_Test(HostingModel hostingModel)
await page.AssertUrlIsAsync(host.GetUrl("/test/onkeydown"));

// and shows cheat sheet.
var cheatSeetElement = page.Locator(".popup-container");
var cheatSheetElement = page.Locator(".popup-container");
await page.Keyboard.DownAsync("Shift"); // Enter "?"
await page.Keyboard.DownAsync("Slash");
await page.Keyboard.UpAsync("Slash");
await page.Keyboard.UpAsync("Shift");
await page.AssertEqualsAsync(_ => cheatSeetElement.IsVisibleAsync(), true);
await page.AssertEqualsAsync(_ => cheatSheetElement.IsVisibleAsync(), true);

// Entering "C", "F", "Shift+H" in an input element has no effect.
var inputElement = page.Locator(".hot-keys-cheat-sheet input[type=text]");
Expand Down Expand Up @@ -135,12 +132,12 @@ public async Task AllowIn_NonTextInput_Test(HostingModel hostingModel)
await page.AssertUrlIsAsync(host.GetUrl("/test/onkeydown"));

// and shows cheat sheet.
var cheatSeetElement = page.Locator(".popup-container");
var cheatSheetElement = page.Locator(".popup-container");
await page.Keyboard.DownAsync("Shift"); // Enter "?"
await page.Keyboard.DownAsync("Slash");
await page.Keyboard.UpAsync("Slash");
await page.Keyboard.UpAsync("Shift");
await page.AssertEqualsAsync(_ => cheatSeetElement.IsVisibleAsync(), true);
await page.AssertEqualsAsync(_ => cheatSheetElement.IsVisibleAsync(), true);

// Entering "F" key in an input element has no effect.
var inputElement = page.Locator(".hot-keys-cheat-sheet input[type=checkbox]");
Expand Down Expand Up @@ -209,7 +206,7 @@ public async Task HelperJavaScript_Namespace_Not_Conflict_Test(HostingModel host
var page = await context.GetPageAsync();
await page.GotoAndWaitForReadyAsync(host.GetUrl("/save-text"));

// Input random text into the testbox,
// Input random text into the text box,
var text = Guid.NewGuid().ToString("N");
await page.FocusAsync("#text-box-1");
foreach (var c in text) { await page.Keyboard.DownAsync(c.ToString()); }
Expand Down Expand Up @@ -325,12 +322,7 @@ public async Task StateDisabled_Test(HostingModel hostingModel)

// Set focus to the "Hotkeys are enabled in this field" input element, and type "U" key.
// Then the counter should not be incremented.
var inputElement1 = await page.QuerySelectorAsync(".disabled-state-hotkeys");
if (inputElement1 == null)
{
throw new InvalidOperationException("Test element is missing");
}

var inputElement1 = await page.QuerySelectorAsync(".disabled-state-hotkeys") ?? throw new InvalidOperationException("Test element is missing");
await inputElement1.FocusAsync();
await page.Keyboard.DownAsync("y");
await page.Keyboard.UpAsync("y");
Expand Down Expand Up @@ -358,12 +350,7 @@ public async Task StateDisabledTrigger_Test(HostingModel hostingModel)

// Set focus to the "Hotkeys are enabled in this field" input element, and type "U" key.
// Then the counter should not be incremented.
var inputElement1 = await page.QuerySelectorAsync(".disabled-state-hotkeys");
if (inputElement1 == null)
{
throw new InvalidOperationException("Test element is missing");
}

var inputElement1 = await page.QuerySelectorAsync(".disabled-state-hotkeys") ?? throw new InvalidOperationException("Test element is missing");
await inputElement1.FocusAsync();
await page.Keyboard.DownAsync("y");
await page.Keyboard.UpAsync("y");
Expand Down
6 changes: 2 additions & 4 deletions HotKeys2.E2ETest/Internals/HostingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

public enum HostingModel
{
Wasm60,
Wasm70,
Wasm80,
Server60,
Server70,
Wasm90,
Server80,
Server90,
}
25 changes: 12 additions & 13 deletions HotKeys2.E2ETest/Internals/TestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ public class TestContext
{
public static TestContext Instance { get; private set; } = null!;

private readonly IReadOnlyDictionary<HostingModel, SampleSite> SampleSites = new Dictionary<HostingModel, SampleSite> {
{ HostingModel.Wasm60, new SampleSite(5012, "Client", "net6.0") },
{ HostingModel.Wasm70, new SampleSite(5013, "Client", "net7.0") },
{ HostingModel.Wasm80, new SampleSite(5014, "Client", "net8.0") },
{ HostingModel.Server60, new SampleSite(5015, "Server", "net6.0") },
{ HostingModel.Server70, new SampleSite(5016, "Server", "net7.0") },
{ HostingModel.Server80, new SampleSite(5017, "Server", "net8.0") },
};
private readonly IReadOnlyDictionary<HostingModel, SampleSite> SampleSites = new Dictionary<HostingModel, SampleSite>
{
[HostingModel.Wasm80] = new(5014, "Client", "net8.0"),
[HostingModel.Wasm90] = new(5015, "Client", "net9.0"),
[HostingModel.Server80] = new(5017, "Server", "net8.0"),
[HostingModel.Server90] = new(5018, "Server", "net9.0"),
};

private IPlaywright? _Playwrite;
private IPlaywright? _Playwright;

private IBrowser? _Browser;

Expand Down Expand Up @@ -53,14 +52,14 @@ public void OneTimeSetUp()

if (!this._Options.SkipInstallBrowser)
{
Microsoft.Playwright.Program.Main(new[] { "install" });
Microsoft.Playwright.Program.Main(["install"]);
}
}

public async ValueTask<IPage> GetPageAsync()
{
this._Playwrite ??= await Playwright.CreateAsync();
this._Browser ??= await this.LaunchBrowserAsync(this._Playwrite);
this._Playwright ??= await Playwright.CreateAsync();
this._Browser ??= await this.LaunchBrowserAsync(this._Playwright);
this._Page ??= await this._Browser.NewPageAsync();
return this._Page;
}
Expand Down Expand Up @@ -91,7 +90,7 @@ private Task<IBrowser> LaunchBrowserAsync(IPlaywright playwright)
public async Task OneTimeTearDownAsync()
{
if (this._Browser != null) await this._Browser.DisposeAsync();
this._Playwrite?.Dispose();
this._Playwright?.Dispose();
Parallel.ForEach(this.SampleSites.Values, sampleSite => sampleSite.Stop());
}
}
14 changes: 7 additions & 7 deletions HotKeys2.E2ETest/Toolbelt.Blazor.HotKeys.E2ETest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
Expand All @@ -14,14 +14,14 @@

<ItemGroup>
<PackageReference Include="ChainingAssertion-NUnit.Bin" Version="4.0.1" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.44.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="NUnit" Version="4.3.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.49.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Toolbelt.WorkDirectory" Version="1.0.0" />
<PackageReference Include="XProcess" Version="1.3.1.1" />
<PackageReference Include="XProcess" Version="1.4.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions HotKeys2.Test/Toolbelt.Blazor.HotKeys2.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<WarningsAsErrors>$(WarningsAsErrors);nullable</WarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
Expand All @@ -13,9 +13,9 @@

<ItemGroup>
<PackageReference Include="ChainingAssertion-NUnit.Bin" Version="4.0.1" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.3.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
</ItemGroup>

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

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>Latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -14,7 +14,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>5.1.0</Version>
<Version>6.0.0-preview.1</Version>
<Copyright>Copyright © 2022-2024 J.Sakamoto, Mozilla Public License 2.0</Copyright>
<Authors>J.Sakamoto</Authors>
<RepositoryType>git</RepositoryType>
Expand Down Expand Up @@ -47,21 +47,16 @@
<PackageReference Include="Toolbelt.Blazor.GetProperty.Script" Version="1.2.0" />
</ItemGroup>

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

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

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

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

<ItemGroup>
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.8.4">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion HotKeys2/VersionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Toolbelt.Blazor.HotKeys2;
internal static class VersionInfo
{
internal const string VersionText = "5.1.0";
internal const string VersionText = "6.0.0-preview.1";
}
25 changes: 10 additions & 15 deletions SampleSites/Client/SampleSite.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<InvariantGlobalization>true</InvariantGlobalization>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<WarningsAsErrors>$(WarningsAsErrors);nullable</WarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="2.1.1" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="3.1.0-preview.4" />
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="3.0.0" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.29" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.29" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.18" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.18" PrivateAssets="all" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.11" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 6 additions & 10 deletions SampleSites/Components/SampleSite.Components.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

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

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

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.4" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(BuildMode)' != 'test' ">
<PackageReference Include="Toolbelt.Blazor.HotKeys2" Version="5.1.0" />
<PackageReference Include="Toolbelt.Blazor.HotKeys2" Version="6.0.0-preview.1" />
<!--<ProjectReference Include="..\..\HotKeys2\Toolbelt.Blazor.HotKeys2.csproj" />-->
</ItemGroup>

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

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
Loading

0 comments on commit 548dae9

Please sign in to comment.