From ee281316f17e37723bbfe74c5b36156a60041653 Mon Sep 17 00:00:00 2001 From: Tewr Date: Tue, 8 Dec 2020 18:03:26 +0100 Subject: [PATCH] Upgrade to 5 multi targeting (#167) * Updated to 5.0rc1 * Small corrections * Less of an allocation risk * Some cleanup, removed repetitive cast * Build after merge * Update old value for Wasm detection --- src/Blazor.FileReader.sln | 99 +--- .../Blazor.FileReader.csproj | 31 +- src/Blazor.FileReader/FileReaderJsInterop.cs | 39 +- src/Blazor.FileReader/FileReaderService.cs | 3 + ...Extensions.cs => JSUnmarshalledRuntime.cs} | 28 +- src/Blazor.FileReader/PlatformConfig.cs | 4 +- src/Blazor.FileReader/SetupExtension.cs | 5 +- .../script/FileReaderComponent.ts | 2 +- .../wwwroot/FileReaderComponent.js | 0 .../wwwroot/FileReaderComponent.js.map | 0 .../Blazor.FileReader.Demo.Common.csproj | 13 +- .../KnuthCommon.razor | 110 ++++ .../SHA256Common.razor | 12 + .../Blazor.FileReader.ServerSide.Demo.csproj | 3 +- .../Pages/Knuth.razor | 3 + .../Shared/NavMenu.razor | 5 + .../Blazor.FileReader.Wasm.Demo/App.razor | 10 +- .../Blazor.FileReader.Wasm.Demo.csproj | 12 +- .../Pages/Knuth.razor | 3 + .../Pages/_imports.razor | 1 + .../Blazor.FileReader.Wasm.Demo/Program.cs | 2 - .../Shared/NavMenu.razor | 5 + .../wwwroot/index.html | 31 - .../App.razor | 9 + .../Blazor.FileReader.ServerSide.Demo.csproj | 13 + .../Pages/Assembly.razor | 2 + .../Pages/DragnDrop.razor | 3 + .../Pages/EPPlus.razor | 3 + .../Pages/Index.razor | 3 + .../Pages/Knuth.razor | 3 + .../Pages/SHA256.razor | 3 + .../Pages/_Host.cshtml | 28 + .../Pages/_Imports.razor | 1 + .../Program.cs | 28 + .../Shared/MainLayout.razor | 15 + .../Shared/NavMenu.razor | 58 ++ .../Startup.cs | 47 ++ .../_Imports.razor | 9 + .../appsettings.Development.json | 9 + .../appsettings.json | 10 + .../wwwroot/css/bootstrap/bootstrap.min.css | 7 + .../css/bootstrap/bootstrap.min.css.map | 1 + .../wwwroot/css/open-iconic/FONT-LICENSE | 86 +++ .../wwwroot/css/open-iconic/ICON-LICENSE | 21 + .../wwwroot/css/open-iconic/README.md | 114 ++++ .../font/css/open-iconic-bootstrap.min.css | 1 + .../open-iconic/font/fonts/open-iconic.eot | Bin 0 -> 28196 bytes .../open-iconic/font/fonts/open-iconic.otf | Bin 0 -> 20996 bytes .../open-iconic/font/fonts/open-iconic.svg | 543 ++++++++++++++++++ .../open-iconic/font/fonts/open-iconic.ttf | Bin 0 -> 28028 bytes .../open-iconic/font/fonts/open-iconic.woff | Bin 0 -> 14984 bytes .../wwwroot/css/site.css | 135 +++++ .../wwwroot/favicon.ico | Bin 0 -> 32038 bytes .../Blazor.FileReader.Wasm.Demo/App.razor | 10 + .../Blazor.FileReader.Wasm.Demo.csproj | 30 + .../Pages/Assembly.razor | 2 + .../Pages/DragnDrop.razor | 3 + .../Pages/EPPlus.razor | 3 + .../Pages/Index.razor | 3 + .../Pages/Knuth.razor | 3 + .../Pages/SHA256.razor | 3 + .../Pages/_imports.razor | 2 + .../Blazor.FileReader.Wasm.Demo/Program.cs | 18 + .../Shared/MainLayout.razor | 14 + .../Shared/NavMenu.razor | 65 +++ .../_imports.razor | 10 + .../wwwroot/.nojekyll | 0 .../wwwroot/404.html | 41 ++ .../wwwroot/animated-icon.svg | 24 + .../wwwroot/css/bootstrap/bootstrap.min.css | 7 + .../css/bootstrap/bootstrap.min.css.map | 1 + .../wwwroot/css/open-iconic/FONT-LICENSE | 86 +++ .../wwwroot/css/open-iconic/ICON-LICENSE | 21 + .../wwwroot/css/open-iconic/README.md | 114 ++++ .../font/css/open-iconic-bootstrap.min.css | 1 + .../open-iconic/font/fonts/open-iconic.eot | Bin 0 -> 28196 bytes .../open-iconic/font/fonts/open-iconic.otf | Bin 0 -> 20996 bytes .../open-iconic/font/fonts/open-iconic.svg | 543 ++++++++++++++++++ .../open-iconic/font/fonts/open-iconic.ttf | Bin 0 -> 28028 bytes .../open-iconic/font/fonts/open-iconic.woff | Bin 0 -> 14984 bytes .../wwwroot/css/site.css | 124 ++++ .../wwwroot/index.html | 66 +++ 82 files changed, 2609 insertions(+), 158 deletions(-) rename src/Blazor.FileReader/{IJSRuntimeExtensions.cs => JSUnmarshalledRuntime.cs} (70%) mode change 100755 => 100644 src/Blazor.FileReader/wwwroot/FileReaderComponent.js mode change 100755 => 100644 src/Blazor.FileReader/wwwroot/FileReaderComponent.js.map create mode 100644 src/Demo/Blazor.FileReader.Demo.Common/KnuthCommon.razor create mode 100644 src/Demo/Blazor.FileReader.ServerSide.Demo/Pages/Knuth.razor create mode 100644 src/Demo/Blazor.FileReader.Wasm.Demo/Pages/Knuth.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/App.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Blazor.FileReader.ServerSide.Demo.csproj create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/Assembly.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/DragnDrop.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/EPPlus.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/Index.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/Knuth.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/SHA256.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/_Host.cshtml create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Pages/_Imports.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Program.cs create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Shared/MainLayout.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Shared/NavMenu.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/Startup.cs create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/_Imports.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/appsettings.Development.json create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/appsettings.json create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/bootstrap/bootstrap.min.css create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/bootstrap/bootstrap.min.css.map create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/FONT-LICENSE create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/ICON-LICENSE create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/README.md create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.eot create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.otf create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.svg create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.woff create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/css/site.css create mode 100644 src/Demo/Blazor3/Blazor.FileReader.ServerSide.Demo/wwwroot/favicon.ico create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/App.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Blazor.FileReader.Wasm.Demo.csproj create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Pages/Assembly.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Pages/DragnDrop.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Pages/EPPlus.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Pages/Index.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Pages/Knuth.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Pages/SHA256.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Pages/_imports.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Program.cs create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Shared/MainLayout.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/Shared/NavMenu.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/_imports.razor create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/.nojekyll create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/404.html create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/animated-icon.svg create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/bootstrap/bootstrap.min.css create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/bootstrap/bootstrap.min.css.map create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/FONT-LICENSE create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/ICON-LICENSE create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/README.md create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.eot create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.otf create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.svg create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.woff create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/css/site.css create mode 100644 src/Demo/Blazor3/Blazor.FileReader.Wasm.Demo/wwwroot/index.html diff --git a/src/Blazor.FileReader.sln b/src/Blazor.FileReader.sln index 6e0ab12e..307e7979 100644 --- a/src/Blazor.FileReader.sln +++ b/src/Blazor.FileReader.sln @@ -11,27 +11,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.ServerSid EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demo", "Demo", "{8AA482CE-0130-43A1-84BC-92215AF25AED}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{C9B92F56-D84F-4DB7-B8B6-B93D76CE6BA1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.E2ETestsShared", "Tests\Blazor.FileReader.E2ETestsShared\Blazor.FileReader.E2ETestsShared.csproj", "{33687379-9E64-48A3-B639-C4C68ED1E34C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.ServerSideE2ETests", "Tests\Blazor.FileReader.ServerSideE2ETests\Blazor.FileReader.ServerSideE2ETests.csproj", "{2739877D-DB94-4382-B591-BDC62975BCF5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.WasmE2ETests", "Tests\Blazor.FileReader.WasmE2ETests\Blazor.FileReader.WasmE2ETests.csproj", "{2CF5D654-B4DB-41FA-B4B3-2C10E41A854D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "E2ETestApplications", "E2ETestApplications", "{3B98DC81-24B2-4EBF-A629-6A2D7948341C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.E2ETestAppShared", "Tests\E2ETestApplications\Blazor.FileReader.E2ETestAppShared\Blazor.FileReader.E2ETestAppShared.csproj", "{9ADAE778-C2E2-4EDB-9302-1F15B00454CB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.ServerSideTestApp", "Tests\E2ETestApplications\Blazor.FileReader.ServerSideTestApp\Blazor.FileReader.ServerSideTestApp.csproj", "{20935500-FE99-4660-83F6-4F58D48E4464}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.Demo.Common", "Demo\Blazor.FileReader.Demo.Common\Blazor.FileReader.Demo.Common.csproj", "{6D6A6678-F90F-4EA3-94A7-A930D27F47E0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.WasmTestApp.Client", "Tests\E2ETestApplications\Blazor.FileReader.WasmTestApp.Client\Blazor.FileReader.WasmTestApp.Client.csproj", "{20017041-698E-4635-B193-5E2F8DB2121B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Net5", "Net5", "{C37C1525-4B17-48BC-9B12-9E74FBAA9BE8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.WasmTestApp.Server", "Tests\E2ETestApplications\Blazor.FileReader.WasmTestApp.Server\Blazor.FileReader.WasmTestApp.Server.csproj", "{E071BF86-678D-45D2-B4D2-5414AAE6E734}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Blazor3", "Blazor3", "{856A3F73-2C95-4E2E-819C-41F6456EE049}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.Demo.Common", "Demo\Blazor.FileReader.Demo.Common\Blazor.FileReader.Demo.Common.csproj", "{6D6A6678-F90F-4EA3-94A7-A930D27F47E0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.Wasm.Demo", "Demo\Blazor3\Blazor.FileReader.Wasm.Demo\Blazor.FileReader.Wasm.Demo.csproj", "{707F28F7-80EF-4A66-BF30-44EB218A4B11}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.FileReader.UnitTests", "Tests\Blazor.FileReader.UnitTests\Blazor.FileReader.UnitTests.csproj", "{7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor.FileReader.ServerSide.Demo", "Demo\Blazor3\Blazor.FileReader.ServerSide.Demo\Blazor.FileReader.ServerSide.Demo.csproj", "{AEA2CBDF-329E-4B17-9B02-4178D045F528}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -57,77 +45,36 @@ Global {DD950FC8-40D7-46CE-8144-7D66B3A86286}.Ghpages|Any CPU.Build.0 = Debug|Any CPU {DD950FC8-40D7-46CE-8144-7D66B3A86286}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD950FC8-40D7-46CE-8144-7D66B3A86286}.Release|Any CPU.Build.0 = Release|Any CPU - {33687379-9E64-48A3-B639-C4C68ED1E34C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {33687379-9E64-48A3-B639-C4C68ED1E34C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {33687379-9E64-48A3-B639-C4C68ED1E34C}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {33687379-9E64-48A3-B639-C4C68ED1E34C}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {33687379-9E64-48A3-B639-C4C68ED1E34C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {33687379-9E64-48A3-B639-C4C68ED1E34C}.Release|Any CPU.Build.0 = Release|Any CPU - {2739877D-DB94-4382-B591-BDC62975BCF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2739877D-DB94-4382-B591-BDC62975BCF5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2739877D-DB94-4382-B591-BDC62975BCF5}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {2739877D-DB94-4382-B591-BDC62975BCF5}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {2739877D-DB94-4382-B591-BDC62975BCF5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2739877D-DB94-4382-B591-BDC62975BCF5}.Release|Any CPU.Build.0 = Release|Any CPU - {2CF5D654-B4DB-41FA-B4B3-2C10E41A854D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2CF5D654-B4DB-41FA-B4B3-2C10E41A854D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2CF5D654-B4DB-41FA-B4B3-2C10E41A854D}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {2CF5D654-B4DB-41FA-B4B3-2C10E41A854D}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {2CF5D654-B4DB-41FA-B4B3-2C10E41A854D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2CF5D654-B4DB-41FA-B4B3-2C10E41A854D}.Release|Any CPU.Build.0 = Release|Any CPU - {9ADAE778-C2E2-4EDB-9302-1F15B00454CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9ADAE778-C2E2-4EDB-9302-1F15B00454CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9ADAE778-C2E2-4EDB-9302-1F15B00454CB}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {9ADAE778-C2E2-4EDB-9302-1F15B00454CB}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {9ADAE778-C2E2-4EDB-9302-1F15B00454CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9ADAE778-C2E2-4EDB-9302-1F15B00454CB}.Release|Any CPU.Build.0 = Release|Any CPU - {20935500-FE99-4660-83F6-4F58D48E4464}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {20935500-FE99-4660-83F6-4F58D48E4464}.Debug|Any CPU.Build.0 = Debug|Any CPU - {20935500-FE99-4660-83F6-4F58D48E4464}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {20935500-FE99-4660-83F6-4F58D48E4464}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {20935500-FE99-4660-83F6-4F58D48E4464}.Release|Any CPU.ActiveCfg = Release|Any CPU - {20935500-FE99-4660-83F6-4F58D48E4464}.Release|Any CPU.Build.0 = Release|Any CPU - {20017041-698E-4635-B193-5E2F8DB2121B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {20017041-698E-4635-B193-5E2F8DB2121B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {20017041-698E-4635-B193-5E2F8DB2121B}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {20017041-698E-4635-B193-5E2F8DB2121B}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {20017041-698E-4635-B193-5E2F8DB2121B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {20017041-698E-4635-B193-5E2F8DB2121B}.Release|Any CPU.Build.0 = Release|Any CPU - {E071BF86-678D-45D2-B4D2-5414AAE6E734}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E071BF86-678D-45D2-B4D2-5414AAE6E734}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E071BF86-678D-45D2-B4D2-5414AAE6E734}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {E071BF86-678D-45D2-B4D2-5414AAE6E734}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {E071BF86-678D-45D2-B4D2-5414AAE6E734}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E071BF86-678D-45D2-B4D2-5414AAE6E734}.Release|Any CPU.Build.0 = Release|Any CPU {6D6A6678-F90F-4EA3-94A7-A930D27F47E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D6A6678-F90F-4EA3-94A7-A930D27F47E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D6A6678-F90F-4EA3-94A7-A930D27F47E0}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU {6D6A6678-F90F-4EA3-94A7-A930D27F47E0}.Ghpages|Any CPU.Build.0 = Debug|Any CPU {6D6A6678-F90F-4EA3-94A7-A930D27F47E0}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D6A6678-F90F-4EA3-94A7-A930D27F47E0}.Release|Any CPU.Build.0 = Release|Any CPU - {7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU - {7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703}.Ghpages|Any CPU.Build.0 = Debug|Any CPU - {7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703}.Release|Any CPU.Build.0 = Release|Any CPU + {707F28F7-80EF-4A66-BF30-44EB218A4B11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {707F28F7-80EF-4A66-BF30-44EB218A4B11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {707F28F7-80EF-4A66-BF30-44EB218A4B11}.Ghpages|Any CPU.ActiveCfg = Ghpages|Any CPU + {707F28F7-80EF-4A66-BF30-44EB218A4B11}.Ghpages|Any CPU.Build.0 = Ghpages|Any CPU + {707F28F7-80EF-4A66-BF30-44EB218A4B11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {707F28F7-80EF-4A66-BF30-44EB218A4B11}.Release|Any CPU.Build.0 = Release|Any CPU + {AEA2CBDF-329E-4B17-9B02-4178D045F528}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEA2CBDF-329E-4B17-9B02-4178D045F528}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEA2CBDF-329E-4B17-9B02-4178D045F528}.Ghpages|Any CPU.ActiveCfg = Debug|Any CPU + {AEA2CBDF-329E-4B17-9B02-4178D045F528}.Ghpages|Any CPU.Build.0 = Debug|Any CPU + {AEA2CBDF-329E-4B17-9B02-4178D045F528}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEA2CBDF-329E-4B17-9B02-4178D045F528}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {9FA01C57-BBB5-420E-AA9B-AD22F39B77ED} = {8AA482CE-0130-43A1-84BC-92215AF25AED} - {DD950FC8-40D7-46CE-8144-7D66B3A86286} = {8AA482CE-0130-43A1-84BC-92215AF25AED} - {33687379-9E64-48A3-B639-C4C68ED1E34C} = {C9B92F56-D84F-4DB7-B8B6-B93D76CE6BA1} - {2739877D-DB94-4382-B591-BDC62975BCF5} = {C9B92F56-D84F-4DB7-B8B6-B93D76CE6BA1} - {2CF5D654-B4DB-41FA-B4B3-2C10E41A854D} = {C9B92F56-D84F-4DB7-B8B6-B93D76CE6BA1} - {3B98DC81-24B2-4EBF-A629-6A2D7948341C} = {C9B92F56-D84F-4DB7-B8B6-B93D76CE6BA1} - {9ADAE778-C2E2-4EDB-9302-1F15B00454CB} = {3B98DC81-24B2-4EBF-A629-6A2D7948341C} - {20935500-FE99-4660-83F6-4F58D48E4464} = {3B98DC81-24B2-4EBF-A629-6A2D7948341C} - {20017041-698E-4635-B193-5E2F8DB2121B} = {3B98DC81-24B2-4EBF-A629-6A2D7948341C} - {E071BF86-678D-45D2-B4D2-5414AAE6E734} = {3B98DC81-24B2-4EBF-A629-6A2D7948341C} + {9FA01C57-BBB5-420E-AA9B-AD22F39B77ED} = {C37C1525-4B17-48BC-9B12-9E74FBAA9BE8} + {DD950FC8-40D7-46CE-8144-7D66B3A86286} = {C37C1525-4B17-48BC-9B12-9E74FBAA9BE8} {6D6A6678-F90F-4EA3-94A7-A930D27F47E0} = {8AA482CE-0130-43A1-84BC-92215AF25AED} - {7E1DF17E-F84D-44E0-B3C6-64CE3EE0C703} = {C9B92F56-D84F-4DB7-B8B6-B93D76CE6BA1} + {C37C1525-4B17-48BC-9B12-9E74FBAA9BE8} = {8AA482CE-0130-43A1-84BC-92215AF25AED} + {856A3F73-2C95-4E2E-819C-41F6456EE049} = {8AA482CE-0130-43A1-84BC-92215AF25AED} + {707F28F7-80EF-4A66-BF30-44EB218A4B11} = {856A3F73-2C95-4E2E-819C-41F6456EE049} + {AEA2CBDF-329E-4B17-9B02-4178D045F528} = {856A3F73-2C95-4E2E-819C-41F6456EE049} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7BCBB258-C07A-4039-838A-09F3B45F7E58} diff --git a/src/Blazor.FileReader/Blazor.FileReader.csproj b/src/Blazor.FileReader/Blazor.FileReader.csproj index 26dcfc7a..defbaf26 100644 --- a/src/Blazor.FileReader/Blazor.FileReader.csproj +++ b/src/Blazor.FileReader/Blazor.FileReader.csproj @@ -1,12 +1,12 @@  - netstandard2.0 + netstandard2.0;net5.0 true 2.8 latest false - 2.1.0.20274 + 3.0.0.20340 Tor Knutsson (Tewr) https://github.com/Tewr/BlazorFileReader https://github.com/Tewr/BlazorFileReader @@ -14,35 +14,36 @@ blazor blazor-component stream filestream file-stream read-file filereader Debug;Release;Ghpages Tewr.Blazor.FileReader - - 2.1.0.20274 + Support for to 5, multi-targeting + 3.0.0.20340 MIT icon.png 3.0 Tewr.Blazor.FileReader Tewr.Blazor.FileReader - 2.1.0.20274 + 3.0.0.20340 - + 1701;1702;NU5104 Blazor.FileReader.xml - - Blazor.FileReader.xml - - - + + + + + + @@ -68,4 +69,12 @@ + + $(DefineConstants);NETSTANDARD20 + + + + $(DefineConstants);NET5 + + diff --git a/src/Blazor.FileReader/FileReaderJsInterop.cs b/src/Blazor.FileReader/FileReaderJsInterop.cs index fbcde890..ff4f65f4 100644 --- a/src/Blazor.FileReader/FileReaderJsInterop.cs +++ b/src/Blazor.FileReader/FileReaderJsInterop.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.Options; using Microsoft.JSInterop; using System; using System.Collections.Generic; @@ -21,6 +20,7 @@ private static readonly Dictionary> _readFileUnm = new Dictionary>(); internal IJSRuntime CurrentJSRuntime; + internal IJSUnmarshalledRuntime UnmarshalledRuntime; internal FileReaderJsInterop(IJSRuntime jsRuntime, FileReaderServiceOptions options) { @@ -29,6 +29,26 @@ internal FileReaderJsInterop(IJSRuntime jsRuntime, FileReaderServiceOptions opti _needsInitialization = options.InitializeOnFirstCall; } + internal void Initialize() + { + if (_options.UseWasmSharedBuffer) + { +#if NET5 + UnmarshalledRuntime = CurrentJSRuntime as IJSUnmarshalledRuntime; +#endif +#if NETSTANDARD20 + if (JSUnmarshalledRuntime.IsInvokeUnmarshalledSupported()) + { + UnmarshalledRuntime = new JSUnmarshalledRuntime(CurrentJSRuntime); + } +#endif + if (UnmarshalledRuntime is null) + { + throw new PlatformNotSupportedException($"{nameof(_options.UseWasmSharedBuffer)}=true is not supported on this platform: Unable to acquire {nameof(IJSUnmarshalledRuntime)}."); + } + } + } + public async Task RegisterDropEvents(ElementReference elementReference, bool additive) { await EnsureInitializedAsync(); @@ -75,7 +95,7 @@ public async Task EnsureInitializedAsync(bool force = false) return; } - await Initialize(); + await InitializeAsync(); } private async Task OpenReadAsync(ElementReference elementReference, int fileIndex) @@ -171,8 +191,9 @@ private async Task ReadFileUnmarshalledAsync( var id = ++_readFileUnmarshalledCallIdSource; _readFileUnmarshalledCalls[id] = taskCompletionSource; cancellationToken.Register(() => taskCompletionSource.TrySetCanceled()); - // Do not try to push over the buffer here... - CurrentJSRuntime.InvokeUnmarshalled( + + // Buffer is not allocated here, + UnmarshalledRuntime.InvokeUnmarshalled( $"FileReaderComponent.ReadFileUnmarshalledAsync", new ReadFileParams { BufferOffset = bufferOffset, @@ -182,11 +203,11 @@ private async Task ReadFileUnmarshalledAsync( TaskId = id }); - // as it might not survive the heap charge of the following statement + // as the corresponding TypeArray might not survive the heap charge of the following statement await taskCompletionSource.Task; - - // Charge the buffer here instead, once its loadeg on the js side - var bytesRead = CurrentJSRuntime.InvokeUnmarshalled( + + // It is safely filled up here instead + var bytesRead = UnmarshalledRuntime.InvokeUnmarshalled( $"FileReaderComponent.FillBufferUnmarshalled", new BufferParams { @@ -226,7 +247,7 @@ public static void EndReadFileUnmarshalledAsyncError(long taskId, string error) taskCompletionSource.SetException(new BrowserFileReaderException(error)); } - private async Task Initialize() + private async Task InitializeAsync() { var isLoaded = await IsLoaded(); if (isLoaded) diff --git a/src/Blazor.FileReader/FileReaderService.cs b/src/Blazor.FileReader/FileReaderService.cs index 908e8e63..e94a7d89 100644 --- a/src/Blazor.FileReader/FileReaderService.cs +++ b/src/Blazor.FileReader/FileReaderService.cs @@ -96,7 +96,10 @@ public FileReaderService(IJSRuntime jsRuntime, FileReaderServiceOptions options, options.MaximumRecieveMessageSize = MaximumReceiveMessageSize.Value; } + + this._fileReaderJsInterop = new FileReaderJsInterop(jsRuntime, options); + this._fileReaderJsInterop.Initialize(); } public IFileReaderServiceOptions Options { get; } diff --git a/src/Blazor.FileReader/IJSRuntimeExtensions.cs b/src/Blazor.FileReader/JSUnmarshalledRuntime.cs similarity index 70% rename from src/Blazor.FileReader/IJSRuntimeExtensions.cs rename to src/Blazor.FileReader/JSUnmarshalledRuntime.cs index 562f72bf..5f544e4f 100644 --- a/src/Blazor.FileReader/IJSRuntimeExtensions.cs +++ b/src/Blazor.FileReader/JSUnmarshalledRuntime.cs @@ -5,22 +5,35 @@ namespace Tewr.Blazor.FileReader { - internal static class IJSRuntimeExtensions +#if NETSTANDARD20 + + internal interface IJSUnmarshalledRuntime + { + TReturn InvokeUnmarshalled(string methodName, TParam parameter); + } + + internal class JSUnmarshalledRuntime : IJSUnmarshalledRuntime { private readonly static Type WebAssemblyJSRuntime = Type.GetType("Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime, Microsoft.JSInterop.WebAssembly") ?? Type.GetType("Mono.WebAssembly.Interop.MonoWebAssemblyJSRuntime, Mono.WebAssembly.Interop"); private readonly static MethodInfo _invokeUnmarshalled = GetInvokeUnmarshalled(); - private readonly static Dictionary _genericinvokeUnmarshalledMethods + private readonly static Dictionary _genericinvokeUnmarshalledMethods = new Dictionary(); + private readonly IJSRuntime jsRuntime; + + public JSUnmarshalledRuntime(IJSRuntime jsRuntime) + { + this.jsRuntime = jsRuntime; + } public static bool IsInvokeUnmarshalledSupported() { return _invokeUnmarshalled != null; - } + } - public static TReturn InvokeUnmarshalled(this IJSRuntime jsRuntime, string methodName, TParam parameter) + public TReturn InvokeUnmarshalled(string methodName, TParam parameter) { var cacheKey = $"{typeof(TReturn)}|{typeof(TParam)}"; if (!_genericinvokeUnmarshalledMethods.TryGetValue(cacheKey, out var genericMethodInfo)) @@ -37,7 +50,7 @@ private static MethodInfo GetInvokeUnmarshalled() { if (WebAssemblyJSRuntime == null) { - System.Diagnostics.Debug.WriteLine($"{nameof(IJSRuntimeExtensions)} : MonoWebAssemblyJSRuntime not found."); + System.Diagnostics.Debug.WriteLine($"{nameof(JSUnmarshalledRuntime)} : MonoWebAssemblyJSRuntime not found."); return null; } @@ -50,9 +63,10 @@ private static MethodInfo GetInvokeUnmarshalled() } } - System.Diagnostics.Debug.WriteLine($"{nameof(IJSRuntimeExtensions)} : MonoWebAssemblyJSRuntime.InvokeUnmarshalled method not found."); + System.Diagnostics.Debug.WriteLine($"{nameof(JSUnmarshalledRuntime)} : MonoWebAssemblyJSRuntime.InvokeUnmarshalled method not found."); return null; } } -} +#endif +} \ No newline at end of file diff --git a/src/Blazor.FileReader/PlatformConfig.cs b/src/Blazor.FileReader/PlatformConfig.cs index 01a736d1..593364fa 100644 --- a/src/Blazor.FileReader/PlatformConfig.cs +++ b/src/Blazor.FileReader/PlatformConfig.cs @@ -19,7 +19,9 @@ private const string ComponentHubFullTypeName /// /// Returns true if the application is running on WASM. /// - public static bool IsWasm => _isWasm ??= RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")); + public static bool IsWasm => _isWasm ??= + RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) || + RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY")); /// /// Tries reading HubOptions<ComponentHub>.MaximumReceiveMessageSize using reflection. diff --git a/src/Blazor.FileReader/SetupExtension.cs b/src/Blazor.FileReader/SetupExtension.cs index 9f4c97ba..d40e038e 100644 --- a/src/Blazor.FileReader/SetupExtension.cs +++ b/src/Blazor.FileReader/SetupExtension.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using System; namespace Tewr.Blazor.FileReader @@ -36,10 +37,6 @@ public static IServiceCollection AddFileReaderService(this IServiceCollection se services.AddSingleton(si => { var o = new FileReaderServiceOptions(); setOptions(o); - if (o.UseWasmSharedBuffer && !IJSRuntimeExtensions.IsInvokeUnmarshalledSupported()) - { - throw new PlatformNotSupportedException($"{nameof(o.UseWasmSharedBuffer)}=true is not supported on this platform."); - } return o; }); diff --git a/src/Blazor.FileReader/script/FileReaderComponent.ts b/src/Blazor.FileReader/script/FileReaderComponent.ts index 8fdebcfa..b00b6cc0 100644 --- a/src/Blazor.FileReader/script/FileReaderComponent.ts +++ b/src/Blazor.FileReader/script/FileReaderComponent.ts @@ -254,7 +254,7 @@ class FileReaderComponent { resolve(); }, e => reject(e)); }); - + asyncCall.then( () => FileReaderJsInterop.endTask(readFileParams.taskId), error => { diff --git a/src/Blazor.FileReader/wwwroot/FileReaderComponent.js b/src/Blazor.FileReader/wwwroot/FileReaderComponent.js old mode 100755 new mode 100644 diff --git a/src/Blazor.FileReader/wwwroot/FileReaderComponent.js.map b/src/Blazor.FileReader/wwwroot/FileReaderComponent.js.map old mode 100755 new mode 100644 diff --git a/src/Demo/Blazor.FileReader.Demo.Common/Blazor.FileReader.Demo.Common.csproj b/src/Demo/Blazor.FileReader.Demo.Common/Blazor.FileReader.Demo.Common.csproj index d20154d9..8bd037a5 100644 --- a/src/Demo/Blazor.FileReader.Demo.Common/Blazor.FileReader.Demo.Common.csproj +++ b/src/Demo/Blazor.FileReader.Demo.Common/Blazor.FileReader.Demo.Common.csproj @@ -1,17 +1,24 @@  - netstandard2.1 + netstandard2.1;net5.0 3.0 - + + + + + + + + - + diff --git a/src/Demo/Blazor.FileReader.Demo.Common/KnuthCommon.razor b/src/Demo/Blazor.FileReader.Demo.Common/KnuthCommon.razor new file mode 100644 index 00000000..5333347e --- /dev/null +++ b/src/Demo/Blazor.FileReader.Demo.Common/KnuthCommon.razor @@ -0,0 +1,110 @@ +@using System.Diagnostics; +@using System.IO; +@inject IFileReaderService fileReaderService +@inject IJSRuntime CurrentJSRuntime + +

Hello, Donald Knuth!

+ +This demo calculates a Knuth hash. +
+ + + +
+
+ +
+ +@code { + private static string nl = Environment.NewLine; + [Parameter] + public int BufferSize { get; set; } = 20480; + public long max; + public long value; + ElementReference inputElement; + public System.Threading.CancellationTokenSource cancellationTokenSource; + string Output { get; set; } + + public bool CanCancel { get; set; } + public bool IsCancelDisabled => !CanCancel; + + public async Task ClearFile() + { + await fileReaderService.CreateReference(inputElement).ClearValue(); + } + + public async Task ReadFile() + { + max = 0; + value = 0; + Output = string.Empty; + this.StateHasChanged(); + var files = await fileReaderService.CreateReference(inputElement).EnumerateFilesAsync(); + foreach (var file in files) + { + var fileInfo = await file.ReadFileInfoAsync(); + max = fileInfo.Size; + + var stopwatch = new Stopwatch(); + stopwatch.Start(); + + + Output += $"{nameof(IFileInfo)}.{nameof(fileInfo.LastModifiedDate)}: {fileInfo.LastModifiedDate?.ToString() ?? "(N/A)"}{nl}"; + foreach (var property in fileInfo.NonStandardProperties.Keys) + { + Output += $"{nameof(IFileInfo)}.{property} (nonstandard): {fileInfo.NonStandardProperties[property]}{nl}"; + } + Output += $"Reading file..."; + this.StateHasChanged(); + Console.WriteLine(Output); + cancellationTokenSource?.Dispose(); + cancellationTokenSource = new System.Threading.CancellationTokenSource(); + CanCancel = true; + + const int onlyReportProgressAfterThisPercentDelta = 10; + + // Subscribe to progress (change of position) + fileInfo.PositionInfo.PositionChanged += (s, e) => + { + // (optional) Only report progress in console / progress bar if percentage has moved over 10% since last call to Acknowledge() + if (e.PercentageDeltaSinceAcknowledge > onlyReportProgressAfterThisPercentDelta) + { + stopwatch.Stop(); + Output += $"Read {(e.PositionDeltaSinceAcknowledge)} bytes ({e.Percentage:00}%). {e.Position} / {fileInfo.Size}{nl}"; + this.InvokeAsync(this.StateHasChanged); + e.Acknowledge(); + value = e.Position; + stopwatch.Start(); + } + }; + + using (var fs = await file.OpenReadAsync()) + { + var kHash = await CalculateKnuthHashAsync(fs, BufferSize); + value = fs.Position; + Output += $"Read 100%. {fileInfo.Size} / {fileInfo.Size}{nl}"; + Output += $"Knuth hash for {fileInfo.Name} : {kHash.ToString("X")}"; + stopwatch.Stop(); + this.InvokeAsync(this.StateHasChanged); + } + } + } + + + async Task CalculateKnuthHashAsync(Stream stream, int bufferSize) + { + var hashedValue = 3074457345618258791ul; + int bytesRead; + var buffer = new byte[bufferSize]; + while ((bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0) + { + for (int i = 0; i < bytesRead; i++) + { + hashedValue += buffer[i]; + hashedValue *= 3074457345618258799ul; + } + } + + return hashedValue; + } +} \ No newline at end of file diff --git a/src/Demo/Blazor.FileReader.Demo.Common/SHA256Common.razor b/src/Demo/Blazor.FileReader.Demo.Common/SHA256Common.razor index dc3fb4a9..42309d67 100644 --- a/src/Demo/Blazor.FileReader.Demo.Common/SHA256Common.razor +++ b/src/Demo/Blazor.FileReader.Demo.Common/SHA256Common.razor @@ -94,6 +94,18 @@ Transfer method :
} public async Task HashFile() + { + try + { + await InnerHashFile(); + } + catch (Exception e) + { + Output += e.ToString(); + } + } + + public async Task InnerHashFile() { Output = string.Empty; this.StateHasChanged(); diff --git a/src/Demo/Blazor.FileReader.ServerSide.Demo/Blazor.FileReader.ServerSide.Demo.csproj b/src/Demo/Blazor.FileReader.ServerSide.Demo/Blazor.FileReader.ServerSide.Demo.csproj index 64fb6577..b0e1ae68 100644 --- a/src/Demo/Blazor.FileReader.ServerSide.Demo/Blazor.FileReader.ServerSide.Demo.csproj +++ b/src/Demo/Blazor.FileReader.ServerSide.Demo/Blazor.FileReader.ServerSide.Demo.csproj @@ -1,8 +1,7 @@  - netcoreapp3.1 - 7.3 + net5.0 true diff --git a/src/Demo/Blazor.FileReader.ServerSide.Demo/Pages/Knuth.razor b/src/Demo/Blazor.FileReader.ServerSide.Demo/Pages/Knuth.razor new file mode 100644 index 00000000..f52b5a21 --- /dev/null +++ b/src/Demo/Blazor.FileReader.ServerSide.Demo/Pages/Knuth.razor @@ -0,0 +1,3 @@ +@page "/Knuth" + + \ No newline at end of file diff --git a/src/Demo/Blazor.FileReader.ServerSide.Demo/Shared/NavMenu.razor b/src/Demo/Blazor.FileReader.ServerSide.Demo/Shared/NavMenu.razor index 0685aaec..b31ab9f5 100644 --- a/src/Demo/Blazor.FileReader.ServerSide.Demo/Shared/NavMenu.razor +++ b/src/Demo/Blazor.FileReader.ServerSide.Demo/Shared/NavMenu.razor @@ -17,6 +17,11 @@ SHA256 Hash + +