Skip to content

Commit

Permalink
Adds .net9 support. Closes #200. (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tewr authored Dec 5, 2024
1 parent e5fc3a8 commit b518e9c
Show file tree
Hide file tree
Showing 84 changed files with 2,976 additions and 10 deletions.
21 changes: 21 additions & 0 deletions src/Blazor.FileReader.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.Wasm.Demo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.FileReader.ServerSide.Demo", "Demo\Net6\Blazor.FileReader.ServerSide.Demo\Blazor.FileReader.ServerSide.Demo.csproj", "{4AFCC00A-7CC4-4143-9D12-0E0E3CA4A630}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Net9", "Net9", "{593A5165-5576-481B-BC31-EBB59C95A687}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.FileReader.ServerSide.Demo", "Demo\Net9\Blazor.FileReader.ServerSide.Demo\Blazor.FileReader.ServerSide.Demo.csproj", "{8582499E-5845-4832-B034-370912150DE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.FileReader.Wasm.Demo", "Demo\Net9\Blazor.FileReader.Wasm.Demo\Blazor.FileReader.Wasm.Demo.csproj", "{ABD80EB4-6419-485E-B98B-6C773441D47C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -99,6 +105,18 @@ Global
{4AFCC00A-7CC4-4143-9D12-0E0E3CA4A630}.Ghpages|Any CPU.Build.0 = Debug|Any CPU
{4AFCC00A-7CC4-4143-9D12-0E0E3CA4A630}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4AFCC00A-7CC4-4143-9D12-0E0E3CA4A630}.Release|Any CPU.Build.0 = Release|Any CPU
{8582499E-5845-4832-B034-370912150DE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8582499E-5845-4832-B034-370912150DE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8582499E-5845-4832-B034-370912150DE2}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU
{8582499E-5845-4832-B034-370912150DE2}.Ghpages|Any CPU.Build.0 = Debug|Any CPU
{8582499E-5845-4832-B034-370912150DE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8582499E-5845-4832-B034-370912150DE2}.Release|Any CPU.Build.0 = Release|Any CPU
{ABD80EB4-6419-485E-B98B-6C773441D47C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ABD80EB4-6419-485E-B98B-6C773441D47C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABD80EB4-6419-485E-B98B-6C773441D47C}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU
{ABD80EB4-6419-485E-B98B-6C773441D47C}.Ghpages|Any CPU.Build.0 = Debug|Any CPU
{ABD80EB4-6419-485E-B98B-6C773441D47C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABD80EB4-6419-485E-B98B-6C773441D47C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -116,6 +134,9 @@ Global
{C3DC632D-7249-4B55-A0F4-68742064C71F} = {8AA482CE-0130-43A1-84BC-92215AF25AED}
{96778444-7F44-4CF8-B8B2-4124865A826A} = {C3DC632D-7249-4B55-A0F4-68742064C71F}
{4AFCC00A-7CC4-4143-9D12-0E0E3CA4A630} = {C3DC632D-7249-4B55-A0F4-68742064C71F}
{593A5165-5576-481B-BC31-EBB59C95A687} = {8AA482CE-0130-43A1-84BC-92215AF25AED}
{8582499E-5845-4832-B034-370912150DE2} = {593A5165-5576-481B-BC31-EBB59C95A687}
{ABD80EB4-6419-485E-B98B-6C773441D47C} = {593A5165-5576-481B-BC31-EBB59C95A687}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BCBB258-C07A-4039-838A-09F3B45F7E58}
Expand Down
15 changes: 10 additions & 5 deletions src/Blazor.FileReader/Blazor.FileReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net9.0</TargetFrameworks>
<BlazorLinkOnBuild>true</BlazorLinkOnBuild>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<LangVersion>latest</LangVersion>
Expand All @@ -14,15 +14,15 @@
<PackageTags>blazor blazor-component stream filestream file-stream read-file filereader</PackageTags>
<Configurations>Debug;Release;Ghpages</Configurations>
<PackageId>Tewr.Blazor.FileReader</PackageId>
<PackageReleaseNotes>Fixes a bug introduced in 3.2.23185, additive drag and drop would never return</PackageReleaseNotes>
<PackageReleaseNotes>NET9 Support</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>icon.png</PackageIcon>
<RazorLangVersion>3.0</RazorLangVersion>
<AssemblyName>Tewr.Blazor.FileReader</AssemblyName>
<RootNamespace>Tewr.Blazor.FileReader</RootNamespace>
<AssemblyVersion>3.3.2.23201</AssemblyVersion>
<Version>3.3.2.23201</Version>
<FileVersion>3.3.2.23201</FileVersion>
<AssemblyVersion>3.4.0.24340</AssemblyVersion>
<Version>3.4.0.24340</Version>
<FileVersion>3.4.0.24340</FileVersion>


<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand All @@ -49,6 +49,11 @@
<EmbeddedResource Include="wwwroot\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
Expand Down
7 changes: 4 additions & 3 deletions src/Blazor.FileReader/FileReaderJsInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ private static readonly Dictionary<long, TaskCompletionSource<int>> _readFileUnm


internal IJSRuntime CurrentJSRuntime;
#if !NET9_0_OR_GREATER
internal IJSUnmarshalledRuntime UnmarshalledRuntime;

#endif
internal FileReaderJsInterop(IJSRuntime jsRuntime, FileReaderServiceOptions options)
{
CurrentJSRuntime = jsRuntime;
Expand Down Expand Up @@ -215,7 +216,7 @@ private async Task<int> ReadFileSliceAsync(
using var readStream = await streamReference.OpenReadStreamAsync(cancellationToken: cancellationToken);
return await readStream.ReadAsync(buffer.AsMemory((int)bufferOffset, count), cancellationToken);
}
#endif
#else

private async Task<int> ReadFileUnmarshalledAsync(
int fileRef, byte[] buffer, long position, long bufferOffset, int count,
Expand Down Expand Up @@ -251,7 +252,7 @@ private async Task<int> ReadFileUnmarshalledAsync(

return bytesRead;
}

#endif
/// <summary>
/// Called from Js
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions src/Blazor.FileReader/FileReaderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ public interface IFileReaderServiceOptions
/// For client-side blazor, uses shared memory buffer to transfer data quickly.
/// Not available for server-side blazor.
/// </summary>
#if NET9_0_OR_GREATER
[Obsolete("This option is ignored, should no longer be used, and will be removed in a future version.")]
#endif
bool UseWasmSharedBuffer { get; set; }
}

internal class FileReaderServiceOptions : IFileReaderServiceOptions
{
public bool InitializeOnFirstCall { get; set; } = true;

#if NET9_0_OR_GREATER
[Obsolete("This option is ignored, should no longer be used, and will be removed in a future version.")]
public bool UseWasmSharedBuffer { get { return false; } set { } }
#else
public bool UseWasmSharedBuffer { get; set; } = false;
#endif

/// <summary>
/// Activates server-side buffer chunking. Activated if not running on WASM.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1;net5.0;net6.0;net9.0</TargetFrameworks>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="epplus" Version="5.1.0" />
</ItemGroup>


<ItemGroup Condition="'$(TargetFramework)'=='net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0" PrivateAssets="all" />
Expand Down
12 changes: 12 additions & 0 deletions src/Demo/Net9/Blazor.FileReader.ServerSide.Demo/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

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

<ItemGroup>
<ProjectReference Include="..\..\..\Blazor.FileReader\Blazor.FileReader.csproj" />
<ProjectReference Include="..\..\Blazor.FileReader.Demo.Common\Blazor.FileReader.Demo.Common.csproj" />
</ItemGroup>

<ItemGroup>
<Content Update="Pages\Index.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Shared\MainLayout.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Shared\NavMenu.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@page "/Assembly"
<AssemblyCommon />
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@page "/counter"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/DragnDrop"

<DragnDropCommon/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/E2ETestDragnDrop"

<E2ECommonTestDragnDrop />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/E2ETestHash"

<E2ECommonTestHash />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/EPPlus"

<EPPlusCommon />
42 changes: 42 additions & 0 deletions src/Demo/Net9/Blazor.FileReader.ServerSide.Demo/Pages/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@page
@model Blazor.FileReader.ServerSide.Demo.Pages.ErrorModel

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
</head>

<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace Blazor.FileReader.ServerSide.Demo.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/"

<IndexCommon/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/Knuth"

<KnuthCommon />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/Paste"

<PasteDivCommon/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@page "/SHA256"

<SHA256Common/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@page "/"
@namespace Blazor.FileReader.ServerSide.Demo.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_Layout";
}

<component type="typeof(App)" render-mode="ServerPrerendered" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@using Microsoft.AspNetCore.Components.Web
@namespace Blazor.FileReader.ServerSide.Demo.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="Blazor.FileReader.ServerSide.Demo.styles.css" rel="stylesheet" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
<body flow-prevent-drop="">
@RenderBody()

<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<script src="_framework/blazor.server.js"></script>
</body>
</html>
Loading

0 comments on commit b518e9c

Please sign in to comment.