Skip to content

Commit

Permalink
Run tests on .NET 9 (#77)
Browse files Browse the repository at this point in the history
* Run tests on .NET 9

* Perf benchmark
  • Loading branch information
soundaranbu authored Nov 20, 2024
1 parent 6086a4c commit fc17bcc
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Setup .NET 9
uses: actions/setup-dotnet@v1
with:
dotnet-version: '9.0.x'

- name: Setup .NET 8
uses: actions/setup-dotnet@v1
with:
Expand Down
9 changes: 8 additions & 1 deletion Razor.Templating.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Desktop", "Desktop", "{858C
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BlazorServer", "BlazorServer", "{02CC8A7C-F37F-4B70-B52B-5B2AFA2BF7B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleBlazorServerApp", "examples\BlazorServer\ExampleBlazorServerApp\ExampleBlazorServerApp.csproj", "{29918D5C-C810-4B1C-90EF-A577DF268600}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExampleBlazorServerApp", "examples\BlazorServer\ExampleBlazorServerApp\ExampleBlazorServerApp.csproj", "{29918D5C-C810-4B1C-90EF-A577DF268600}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Razor.Template.Core.PerfBenchmark", "src\Razor.Template.Core.PerfBenchmark\Razor.Template.Core.PerfBenchmark.csproj", "{B019FC27-9A9F-48F2-B04D-632888F1679A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -105,6 +107,10 @@ Global
{29918D5C-C810-4B1C-90EF-A577DF268600}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29918D5C-C810-4B1C-90EF-A577DF268600}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29918D5C-C810-4B1C-90EF-A577DF268600}.Release|Any CPU.Build.0 = Release|Any CPU
{B019FC27-9A9F-48F2-B04D-632888F1679A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B019FC27-9A9F-48F2-B04D-632888F1679A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B019FC27-9A9F-48F2-B04D-632888F1679A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B019FC27-9A9F-48F2-B04D-632888F1679A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -129,6 +135,7 @@ Global
{858C6EFB-A924-4909-8E2F-C88FC2A31FED} = {AD88CAC8-F022-4702-8073-8E6EF62AADD7}
{02CC8A7C-F37F-4B70-B52B-5B2AFA2BF7B1} = {AD88CAC8-F022-4702-8073-8E6EF62AADD7}
{29918D5C-C810-4B1C-90EF-A577DF268600} = {02CC8A7C-F37F-4B70-B52B-5B2AFA2BF7B1}
{B019FC27-9A9F-48F2-B04D-632888F1679A} = {C6E8ABD2-AE4D-4088-B1FE-3C6593D08211}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {73728C09-FCFE-43D7-BEF4-B24DF6A38562}
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"rollForward": "latestMinor"
}
}
31 changes: 31 additions & 0 deletions src/Razor.Template.Core.PerfBenchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using ExampleRazorTemplatesLibrary.Models;
using Razor.Templating.Core;

BenchmarkRunner.Run<RazorTemplateBenchMark>();

[MemoryDiagnoser]
public class RazorTemplateBenchMark
{

[GlobalSetup]
public void Setup()
{
}

[Benchmark]
public async Task RenderViewWithModelAsync()
{
var model = new ExampleModel()
{
PlainText = "Some text",
HtmlContent = "<em>Some emphasized text</em>"
};
var viewData = new Dictionary<string, object>();
viewData["Value1"] = "1";
viewData["Value2"] = "2";

var html = await RazorTemplateEngine.RenderAsync("/Views/ExampleView.cshtml", model, viewData);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\examples\Templates\ExampleAppRazorTemplates\ExampleRazorTemplatesLibrary.csproj" />
<ProjectReference Include="..\Razor.Templating.Core\Razor.Templating.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<CollectCoverage>true</CollectCoverage>
<CoverletOutputFormat>cobertura</CoverletOutputFormat>
Expand All @@ -14,8 +14,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand All @@ -24,7 +24,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="ReportGenerator" Version="5.3.8" />
<PackageReference Include="ReportGenerator" Version="5.4.1" />
</ItemGroup>

<Target Name="GenerateHtmlCoverageReport" AfterTargets="GenerateCoverageResultAfterTest">
Expand All @@ -39,6 +39,11 @@
<ProjectReference Include="..\..\src\Razor.Templating.Core\Razor.Templating.Core.csproj" />
</ItemGroup>

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

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing">
Expand Down

0 comments on commit fc17bcc

Please sign in to comment.