Skip to content

Commit

Permalink
feat(upgrade): Upgraded to .NET8
Browse files Browse the repository at this point in the history
Migrated to new Interop patterns.
Expanded on Performance Validations.
  • Loading branch information
canhorn committed Dec 16, 2023
1 parent 318b156 commit e635c66
Show file tree
Hide file tree
Showing 25 changed files with 1,023 additions and 846 deletions.
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
);
}
}
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 Int 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",
"setInt",
9999
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@page "/interop/performance/set"

<h1>Interop Set Performance</h1>

<div class="testing-content">
<InteropSetDecimalTest />
<InteropSetFloatTest />
<InteropSetIntTest />
<InteropSetTest />
</div>
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 Test</h3>
<div class="--lighter">Interop Set</div>
<ReportTimeTaken TimeTaken="TimeTaken" Runs="_max" />
<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",
"setString",
"location"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<div>
<h3>Interop Get Test</h3>
<div class="--lighter">Interop Get</div>
<ReportTimeTaken TimeTaken="TimeTaken" Runs="_max" />
<button class="run-btn" @onclick="HandleRunTest">Run</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
if (arg1 == expectedArg)
{
return new TestClass { Found = true, Arg1 = arg1 };
}

}

return new TestClass { Found = false };
});

Expand All @@ -58,13 +58,13 @@
actionHandler
);
initialized = true;
TestStatus = "Failed";

if (result.Found
&& result.Arg1 == expectedArg)
{
TestStatus = "Passed";
}
}
}
TestStatus = "Failed";

if (result.Found
&& result.Arg1 == expectedArg)
{
TestStatus = "Passed";
}
}
}
}
Loading

0 comments on commit e635c66

Please sign in to comment.