Skip to content

Commit

Permalink
feat(upgrade): Upgraded to .NET8 (#39)
Browse files Browse the repository at this point in the history
* feat(upgrade): Upgraded to .NET8
Migrated to new Interop patterns.
Expanded on Performance Validations.

* feat(build): Updated build files and framework versions.

* feat(build): Added missing .NET Workload.

* feat(version): Bumped new minor Version.
+semver: minor
  • Loading branch information
canhorn authored Dec 16, 2023
1 parent 318b156 commit 690ea8a
Show file tree
Hide file tree
Showing 28 changed files with 1,056 additions and 856 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/dotnet-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@ jobs:
runs-on: ubuntu-latest
name: Build/Deploy .NET Core
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: Install .NET Workloads
run: dotnet workload install wasm-tools

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: .NET Publish
run: dotnet publish --configuration Release -o published ./EventHorizon.Blazor.Interop.Sample

- name: Publish Static Site
id: builddeploy
uses: Azure/static-web-apps-deploy@v0.0.1-preview
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_PLANT_0F8750A10 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
Expand All @@ -44,7 +52,8 @@ jobs:
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v0.0.1-preview
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_PLANT_0F8750A10 }}
action: 'close'
app_location: "published/wwwroot" # App source code path
16 changes: 13 additions & 3 deletions .github/workflows/dotnet-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,37 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
with:
additionalArguments: '/updateAssemblyInfo'

- run: |
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.NuGetVersionV2 }}"
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'

- name: Install .NET Workloads
run: dotnet workload install wasm-tools

- name: Build with dotnet
run: dotnet build --configuration Release ./EventHorizon.Blazor.Interop/EventHorizon.Blazor.Interop.csproj

- name: Pack with dotnet
run: dotnet pack EventHorizon.Blazor.Interop/EventHorizon.Blazor.Interop.csproj --output nuget-packages --configuration Release -p:PackageVersion=${{ steps.gitversion.outputs.NuGetVersionV2 }}

- name: Push with dotnet
run: dotnet nuget push nuget-packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
8 changes: 6 additions & 2 deletions .github/workflows/main-tag-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]

- run: |
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.NuGetVersionV2 }}"
- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.17.2
uses: anothrNick/github-tag-action@1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# We want to push to nuget the same version we tag
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

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

<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
<BlazorWebAssemblyPreserveCollationData>false</BlazorWebAssemblyPreserveCollationData>

<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,34 @@
actualClass1 = arg1[0];
actualClass2 = arg1[1];
actualClass3 = arg1[2];

ValidateTest();
return Task.CompletedTask;
});

EventHorizonBlazorInterop.Func<string>(
new string[] { testId, "register" },
actionHandler
new string[] { testId, "register" },
actionHandler
);
initialized = true;
}

RunTest();
ValidateTest();
}

public void RunTest()
{
EventHorizonBlazorInterop.Func<CachedEntity>(
new object[] { new string[] { testId, "trigger" } }
new object[] { new string[] { testId, "trigger" } }
);
}

public void ValidateTest()
{
var value = actualClass1.Id;
if (actualClass1.Id == expectedClass1
&& actualClass2.Id == expectedClass2
&& actualClass3.Id == expectedClass3
&& actualClass2.Id == expectedClass2
&& actualClass3.Id == expectedClass3
)
{
TestStatus = "Passed";
Expand All @@ -93,5 +94,7 @@
{
TestStatus = "Failed";
}

StateHasChanged();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
actualClass2 = arg3;
actualString2 = arg4;
actualClass3 = arg5;

ValidateTest();
return Task.CompletedTask;
});

Expand All @@ -75,7 +77,6 @@
}

RunTest();
ValidateTest();
}

public void RunTest()
Expand All @@ -101,5 +102,7 @@
{
TestStatus = "Failed";
}

StateHasChanged();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
actualClass2 = arg3;
actualString2 = arg4;
actualClass3 = arg5;

ValidateTest();
return Task.CompletedTask;
});

Expand All @@ -78,7 +80,6 @@
}

RunTest();
ValidateTest();
}

public void RunTest()
Expand All @@ -104,5 +105,7 @@
{
TestStatus = "Failed";
}

StateHasChanged();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
actualClass1 = arg1[0];
actualClass2 = arg1[1];
actualClass3 = arg1[2];

ValidateTest();
return Task.CompletedTask;
});

Expand All @@ -72,7 +74,6 @@
}

RunTest();
ValidateTest();
}

public void RunTest()
Expand All @@ -97,5 +98,7 @@
{
TestStatus = "Failed";
}

StateHasChanged();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
actualClass2 = arg3;
actualString2 = arg4;
actualClass3 = arg5;

ValidateTest();
return Task.CompletedTask;
});

Expand All @@ -77,7 +79,6 @@
}

RunTest();
ValidateTest();
}

public void RunTest()
Expand All @@ -104,5 +105,7 @@
{
TestStatus = "Failed";
}

StateHasChanged();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
actualClass2 = arg3;
actualString2 = arg4;
actualClass3 = arg5;

ValidateTest();
return Task.CompletedTask;
});

Expand All @@ -80,7 +82,6 @@
}

RunTest();
ValidateTest();
}

public void RunTest()
Expand All @@ -107,5 +108,7 @@
{
TestStatus = "Failed";
}

StateHasChanged();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@using System.Diagnostics
@using EventHorizon.Blazor.Interop;

<div>
<h3>Interop Set Decimal Test</h3>
<div class="--lighter">Interop Set</div>
<ReportTimeTaken Runs="_max" TimeTaken="TimeTaken" />
<button class="run-btn" @onclick="HandleRunTest">Run</button>
</div>

@code {
public TimeSpan TimeTaken { get; set; }

const int _max = 1_000;
private void HandleRunTest()
{
var s1 = Stopwatch.StartNew();
for (int i = 0; i < _max; i++)
{

RunTest();
}
s1.Stop();
TimeTaken = s1.Elapsed;
Console.WriteLine(((double)(s1.ElapsedMilliseconds * 1000000) / _max).ToString("0.00 ns"));
}

public void RunTest()
{
EventHorizonBlazorInterop.Set(
"setPrimitive",
"setNumber",
999.99m
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@using System.Diagnostics
@using EventHorizon.Blazor.Interop;

<div>
<h3>Interop Set Float Test</h3>
<div class="--lighter">Interop Set</div>
<ReportTimeTaken Runs="_max" TimeTaken="TimeTaken" />
<button class="run-btn" @onclick="HandleRunTest">Run</button>
</div>

@code {
public TimeSpan TimeTaken { get; set; }

const int _max = 1_000;
private void HandleRunTest()
{
var s1 = Stopwatch.StartNew();
for (int i = 0; i < _max; i++)
{
RunTest();
}
s1.Stop();
TimeTaken = s1.Elapsed;
Console.WriteLine(((double)(s1.ElapsedMilliseconds * 1000000) / _max).ToString("0.00 ns"));
}

public void RunTest()
{
EventHorizonBlazorInterop.Set(
"setPrimitive",
"setNumber",
99.99f
);
}
}
Loading

0 comments on commit 690ea8a

Please sign in to comment.