Skip to content

Commit

Permalink
chore: target dotnet 9 and drop support for dotnet 6 and 7 (#101)
Browse files Browse the repository at this point in the history
* chore: target dotnet 9 and drop support for dotnet 6 and 7

* Update github actions dotnet version
  • Loading branch information
gabynevada authored Nov 19, 2024
1 parent 5c7c71c commit d8e2dc0
Show file tree
Hide file tree
Showing 34 changed files with 374 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.29.1",
"version": "0.30.1",
"commands": [
"dotnet-csharpier"
],
Expand Down
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{cs,vb}]
csharp_style_namespace_declarations = file_scoped
csharp_style_var_for_built_in_types = true
csharp_style_var_elsewhere = true


2 changes: 1 addition & 1 deletion .github/workflows/build-on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
dotnet-version: '9.x'

- name: Restore dotnet tools
run: dotnet tool restore
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@main

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -57,9 +57,9 @@ jobs:


- name: Setup dotnet
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
dotnet-version: '9.x'

- name: Build with dotnet
run: dotnet build --configuration Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-deploy-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
dotnet-version: '9.x'

- name: Package BlazorReports
run: dotnet pack src/BlazorReports
Expand Down
7 changes: 7 additions & 0 deletions BlazorReports.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{C5
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleReportServer", "examples\SimpleReportServer\SimpleReportServer.csproj", "{1C60A5A2-46DB-419D-BED1-5C97465076D0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExampleTemplates", "examples\ExampleTemplates\ExampleTemplates.csproj", "{B0C3AFB8-AA52-4947-863F-9DEEC9D889AE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -42,12 +44,17 @@ Global
{1C60A5A2-46DB-419D-BED1-5C97465076D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C60A5A2-46DB-419D-BED1-5C97465076D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C60A5A2-46DB-419D-BED1-5C97465076D0}.Release|Any CPU.Build.0 = Release|Any CPU
{B0C3AFB8-AA52-4947-863F-9DEEC9D889AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0C3AFB8-AA52-4947-863F-9DEEC9D889AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0C3AFB8-AA52-4947-863F-9DEEC9D889AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0C3AFB8-AA52-4947-863F-9DEEC9D889AE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2AA5462E-57F7-4A4B-A1BB-1BFF901A7C22} = {84E7AF5B-BDD3-4FB3-A798-7E8541EE7A1E}
{F19F8E2C-C4A1-44FB-86A1-E3642A12E655} = {84E7AF5B-BDD3-4FB3-A798-7E8541EE7A1E}
{DAF00FAE-4B76-4FA6-9690-14F12DB123DB} = {84E7AF5B-BDD3-4FB3-A798-7E8541EE7A1E}
{35F37EF3-9BFD-4C4A-ACDA-761D62E3E940} = {84E7AF5B-BDD3-4FB3-A798-7E8541EE7A1E}
{1C60A5A2-46DB-419D-BED1-5C97465076D0} = {C5BFD20E-2F4E-4EA8-AC79-82E91F93E70F}
{B0C3AFB8-AA52-4947-863F-9DEEC9D889AE} = {C5BFD20E-2F4E-4EA8-AC79-82E91F93E70F}
EndGlobalSection
EndGlobal
7 changes: 7 additions & 0 deletions examples/ExampleTemplates/Components/ExampleHeader.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div style="background-color: lightgray; padding: 10px;">
<h1>Testing Header</h1>
</div>

@code {

}
17 changes: 17 additions & 0 deletions examples/ExampleTemplates/ExampleTemplates.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>


<ItemGroup>
<SupportedPlatform Include="browser"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@* This component will render a repeating header on each page when printed *@

@* This component will render a repeating header on each page when printed *@

<div class="print-container">
<div class="print-header">
<h1>Header for Each Page</h1>
</div>

<div class="print-content">
@for (int i = 0; i < 100; i++)
{
<p>This is line number @i</p>
}
</div>
</div>

<style>
/* General styling for print */
@@media print {
.print-container {
break-inside: avoid;
}
.print-content {
break-before: page;
}
margin-top: 0;
}
/* General styling for screen display */
.print-container {
margin: 20px;
}
.print-header {
background-color: lightgray;
padding: 10px;
}
.print-content {
margin-top: 20px;
}
</style>
@code {
}
1 change: 1 addition & 0 deletions examples/ExampleTemplates/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@using Microsoft.AspNetCore.Components.Web
Binary file added examples/ExampleTemplates/wwwroot/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions examples/ExampleTemplates/wwwroot/exampleJsInterop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This is a JavaScript module that is loaded on demand. It can export any number of
// functions, and may import other JavaScript modules if required.

export function showPrompt(message) {
return prompt(message, 'Type anything here');
}
25 changes: 17 additions & 8 deletions examples/SimpleReportServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using BlazorReports.Extensions;
using BlazorReports.Models;
using ExampleTemplates.Reports;
using SimpleReportServer;

var builder = WebApplication.CreateSlimBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddBlazorReports();
builder.Services.AddBlazorReports(opts =>
{
opts.BrowserOptions.ResponseTimeout = TimeSpan.FromSeconds(90);
});

var app = builder.Build();

Expand All @@ -16,12 +20,17 @@
app.UseSwaggerUI();
}

app.MapGroup("reports").MapBlazorReport<HelloReport, HelloReportData>();
app.MapGroup("reports")
.MapBlazorReport<HelloReport, HelloReportData>(opts =>
{
opts.ReportName = "HelloReportHtml";
opts.OutputFormat = ReportOutputFormat.Html;
});
var reportsGroup = app.MapGroup("reports");

reportsGroup.MapBlazorReport<HelloReport, HelloReportData>();
reportsGroup.MapBlazorReport<HelloReport, HelloReportData>(opts =>
{
opts.ReportName = "HelloReportHtml";
opts.OutputFormat = ReportOutputFormat.Html;
});
reportsGroup.MapBlazorReport<ReportWithRepeatingHeaderPerPage>(opts =>
{
opts.OutputFormat = ReportOutputFormat.Pdf;
});

app.Run();
9 changes: 6 additions & 3 deletions examples/SimpleReportServer/SimpleReportServer.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\BlazorReports\BlazorReports.csproj" />
<ProjectReference Include="..\ExampleTemplates\ExampleTemplates.csproj" />
</ItemGroup>

</Project>
18 changes: 8 additions & 10 deletions src/BlazorReports.Client/BlazorReports.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.8" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.8"/>
</ItemGroup>
</Project>
21 changes: 7 additions & 14 deletions src/BlazorReports.Components/BlazorReports.Components.csproj
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsTrimmable>true</IsTrimmable>
<NoWarn>$(NoWarn);NU5104</NoWarn>
<Title>Blazor Reports Components</Title>
<Description>Blazor components for BlazorReports. Generate PDF reports using Blazor Components. Easily create a report server or generate reports from existing projects.</Description>
</PropertyGroup>

<ItemGroup>
<SupportedPlatform Include="browser" />
<SupportedPlatform Include="browser"/>
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="wwwroot\"/>
</ItemGroup>

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

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

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

</Project>
2 changes: 0 additions & 2 deletions src/BlazorReports.Viewer/BlazorReports.Viewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

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

<ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/BlazorReports/BlazorReports.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Title>Blazor Reports</Title>
<Description>Generate PDF reports using Blazor Components. Easily create a report server or generate reports from existing projects.</Description>
Expand All @@ -19,7 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OneOf" Version="3.0.271" />
<PackageReference Include="OneOf" Version="3.*" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/BlazorReports/Extensions/ReportExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private static BlazorReportRegistrationOptions GetReportRegistrationOptions(
Action<BlazorReportRegistrationOptions>? setupAction = null
)
{
var options = new BlazorReportRegistrationOptions();
BlazorReportRegistrationOptions options = new();
var globalOptions = serviceScope
.ServiceProvider.GetRequiredService<IOptionsSnapshot<BlazorReportsOptions>>()
.Value;
Expand Down
37 changes: 14 additions & 23 deletions src/BlazorReports/Helpers/MimeTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
/// </summary>
internal static class MimeTypes
{
private static readonly Dictionary<string, string> MimeTypesDictionary =
new()
{
{ ".txt", "text/plain" },
{ ".pdf", "application/pdf" },
{ ".csv", "text/csv" },
{ ".png", "image/png" },
{ ".jpg", "image/jpeg" },
{ ".jpeg", "image/jpeg" },
{ ".gif", "image/gif" },
{ ".webp", "image/webp" },
};
private static readonly Dictionary<string, string> MimeTypesDictionary = new()
{
{ ".txt", "text/plain" },
{ ".pdf", "application/pdf" },
{ ".csv", "text/csv" },
{ ".png", "image/png" },
{ ".jpg", "image/jpeg" },
{ ".jpeg", "image/jpeg" },
{ ".gif", "image/gif" },
{ ".webp", "image/webp" },
};

private const string UnknownMimeType = "application/octet-stream";

Expand All @@ -30,16 +29,8 @@ public static string GetMimeType(string fileName)
{
var extension = Path.GetExtension(fileName).ToLowerInvariant();

if (string.IsNullOrEmpty(extension))
{
return UnknownMimeType;
}

if (!MimeTypesDictionary.TryGetValue(extension, out var mimeType))
{
return UnknownMimeType;
}

return mimeType;
return string.IsNullOrEmpty(extension)
? UnknownMimeType
: MimeTypesDictionary.GetValueOrDefault(extension, UnknownMimeType);
}
}
Loading

0 comments on commit d8e2dc0

Please # to comment.