Skip to content

Commit 33d7c79

Browse files
authored
Merge pull request #1 from Zettersten/feature/component-modernization-5872
Component modernization
2 parents c0b593c + f947240 commit 33d7c79

File tree

45 files changed

+983
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+983
-380
lines changed

.config/dotnet-tools.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
"isRoot": true,
44
"tools": {
55
"csharpier": {
6-
"version": "1.0.3",
6+
"version": "1.2.5",
77
"commands": [
88
"csharpier"
99
],
1010
"rollForward": false
1111
},
1212
"husky": {
13-
"version": "0.7.2",
13+
"version": "0.8.0",
1414
"commands": [
1515
"husky"
1616
],
1717
"rollForward": false
1818
},
1919
"nbgv": {
20-
"version": "3.7.115",
20+
"version": "3.9.50",
2121
"commands": [
2222
"nbgv"
2323
],

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ indent_size = 4
88
charset = utf-8
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
11-
end_of_line = crlf
11+
end_of_line = lf
1212

1313
# C# files
1414
[*.cs]

.gitattributes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
###############################################################################
44
* text=auto
55

6+
# Normalize common source files to LF for formatter stability
7+
*.cs text eol=lf
8+
*.razor text eol=lf
9+
*.csproj text eol=lf
10+
*.sln text eol=lf
11+
*.props text eol=lf
12+
*.targets text eol=lf
13+
*.yml text eol=lf
14+
*.yaml text eol=lf
15+
*.md text eol=lf
16+
*.json text eol=lf
17+
*.js text eol=lf
18+
*.ts text eol=lf
19+
*.d.ts text eol=lf
20+
621
###############################################################################
722
# Set default behavior for command prompt diff.
823
#

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup .NET
15+
uses: actions/setup-dotnet@v4
16+
with:
17+
dotnet-version: 10.0.x
18+
19+
- name: Restore tools
20+
run: dotnet tool restore
21+
22+
- name: Restore
23+
run: dotnet restore
24+
25+
- name: Build (Release)
26+
run: dotnet build --configuration Release --no-restore
27+
28+
- name: Test
29+
run: dotnet test --configuration Release --no-build
30+
31+
- name: CSharpier (check)
32+
run: dotnet csharpier check .
33+

.github/workflows/deploy-demo.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Deploy demo (GitHub Pages)
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
paths:
7+
- "BlazorCanvas2d/**"
8+
- "BlazorCanvas2d.Samples/**"
9+
- ".github/workflows/deploy-demo.yml"
10+
- ".github/workflows/ci.yml"
11+
- "BlazorCanvas2d.sln"
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: true
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: 10.0.x
32+
33+
- name: Publish SimpleCanvas (Release)
34+
run: dotnet publish "BlazorCanvas2d.Samples/BlazorCanvas2d.Samples.SimpleCanvas/BlazorCanvas2d.Samples.SimpleCanvas.csproj" -c Release -o "artifacts/publish"
35+
36+
- name: Prepare GitHub Pages assets
37+
shell: bash
38+
run: |
39+
set -euo pipefail
40+
WWWROOT="artifacts/publish/wwwroot"
41+
REPO_NAME="${GITHUB_REPOSITORY#*/}"
42+
BASE_HREF="/${REPO_NAME}/"
43+
44+
# Blazor WASM needs correct base href when hosted from /<repo>/
45+
python3 - <<'PY'
46+
import os
47+
import pathlib
48+
import re
49+
50+
wwwroot = pathlib.Path(os.environ["WWWROOT"])
51+
base_href = os.environ["BASE_HREF"]
52+
index = wwwroot / "index.html"
53+
html = index.read_text(encoding="utf-8")
54+
html2, n = re.subn(r'<base href="[^"]*"\s*/>', f'<base href="{base_href}" />', html, count=1)
55+
if n != 1:
56+
raise SystemExit("Expected exactly one <base href=\"...\" /> in index.html")
57+
index.write_text(html2, encoding="utf-8")
58+
(wwwroot / "404.html").write_text(html2, encoding="utf-8")
59+
(wwwroot / ".nojekyll").write_text("", encoding="utf-8")
60+
PY
61+
62+
- name: Upload Pages artifact
63+
uses: actions/upload-pages-artifact@v3
64+
with:
65+
path: artifacts/publish/wwwroot
66+
67+
deploy:
68+
runs-on: ubuntu-latest
69+
needs: build
70+
environment:
71+
name: github-pages
72+
url: ${{ steps.deployment.outputs.page_url }}
73+
steps:
74+
- id: deployment
75+
uses: actions/deploy-pages@v4
76+

.github/workflows/nuget-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313

1414
- name: Setup .NET
15-
uses: actions/setup-dotnet@v3
15+
uses: actions/setup-dotnet@v4
1616
with:
17-
dotnet-version: 9.0.x
17+
dotnet-version: 10.0.x
1818

1919
- name: Restore dependencies
2020
run: dotnet restore

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,3 +757,7 @@ sketch
757757
.azure
758758
.vs
759759
.vscode
760+
761+
# Local .NET SDK installs (do not commit)
762+
.dotnet/
763+
dotnet-install.sh

BlazorCanvas2d.Samples/BlazorCanvas2d.Samples.DoomFire/BlazorCanvas2d.Samples.DoomFire.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<Nullable>enable</Nullable>
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.8" />
9-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.8" PrivateAssets="all" />
8+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.1" />
9+
<PackageReference
10+
Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer"
11+
Version="10.0.1"
12+
PrivateAssets="all"
13+
/>
1014
</ItemGroup>
1115
<ItemGroup>
1216
<ProjectReference Include="..\..\BlazorCanvas2d\BlazorCanvas2d.csproj" />

BlazorCanvas2d.Samples/BlazorCanvas2d.Samples.DoomFire/Pages/Home.razor

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
@page "/"
1+
@page "/"
22

33
<PageTitle>Home</PageTitle>
44

55
<CanvasManager @ref="_canvasManager" />
66

77
@code
88
{
9-
CanvasManager _canvasManager;
10-
IRenderContext _context;
11-
MouseMoveEvent _mousecoords;
12-
ICanvas _fireCanvas;
9+
private CanvasManager? _canvasManager;
10+
private IRenderContext? _context;
11+
private MouseMoveEvent _mousecoords;
12+
private ICanvas? _fireCanvas;
1313

1414
int _width = 800;
1515
int _height = 600;
@@ -18,7 +18,7 @@
1818
float _lastUpdate = 0;
1919
float _elapsedTime = 0;
2020

21-
private Services.FireRenderer _fireRenderer;
21+
private Services.FireRenderer? _fireRenderer;
2222
private int _fireWidth = 256;
2323
private int _fireHeight = 64;
2424

@@ -27,15 +27,15 @@
2727
if (!firstRender)
2828
return;
2929

30-
_canvasManager.CreateCanvas("fire", new CanvasCreationOptions()
30+
_canvasManager?.CreateCanvas("fire", new CanvasCreationOptions()
3131
{
3232
Hidden = true,
3333
Width = _fireWidth,
3434
Height = _fireHeight,
3535
OnCanvasReadyAsync = this.OnFireCanvasReady,
3636
OnFrameReady = this.OnFireCanvasFrameReady,
3737
});
38-
_canvasManager.CreateCanvas("main", new CanvasCreationOptions()
38+
_canvasManager?.CreateCanvas("main", new CanvasCreationOptions()
3939
{
4040
Hidden = false,
4141
Width = _width,
@@ -56,6 +56,11 @@
5656

5757
private void OnFireCanvasFrameReady(float timeStamp)
5858
{
59+
if (_fireRenderer is null)
60+
{
61+
return;
62+
}
63+
5964
_fireRenderer.Update();
6065
_fireRenderer.Render();
6166
}
@@ -89,6 +94,11 @@
8994

9095
private void Render()
9196
{
97+
if (_context is null || _fireCanvas is null)
98+
{
99+
return;
100+
}
101+
92102
_context.ClearRect(0, 0, _width, _height);
93103

94104
_context.DrawImage(_fireCanvas.ElementReference, 0, 0, _width, _height);

BlazorCanvas2d.Samples/BlazorCanvas2d.Samples.FallingBlocks/BlazorCanvas2d.Samples.FallingBlocks.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<Nullable>enable</Nullable>
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
77
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.8" />
9-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.8" PrivateAssets="all" />
8+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.1" />
9+
<PackageReference
10+
Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer"
11+
Version="10.0.1"
12+
PrivateAssets="all"
13+
/>
1014
</ItemGroup>
1115
<ItemGroup>
1216
<ProjectReference Include="..\..\BlazorCanvas2d\BlazorCanvas2d.csproj" />

0 commit comments

Comments
 (0)