Skip to content

Commit

Permalink
1st try of migration to dotnet 8.
Browse files Browse the repository at this point in the history
rc.2 is failing miserably with impossible RCL error (dotnet/aspnetcore#42629) and requirement of some additional package reference to fix. Crazy but rc.1 works. Tests still failing on Inkball SignalR. Weird.
  • Loading branch information
ChaosEngine committed Nov 4, 2023
1 parent 7763752 commit 4aaedbb
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 60 deletions.
4 changes: 2 additions & 2 deletions src/InkBall.Module/Areas/InkBall/Pages/Game.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@
}
</environment>
<environment exclude="Development">
<script src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr@7.0.12/dist/browser/signalr.min.js" integrity="sha256-HyDVPs15b/gBlO8Pr9X68O3SYzA3w9rWN9/PSBedfsw=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr@8.0.0-rc.2.23480.2/dist/browser/signalr.min.js" integrity="sha256-I6GskY4OlV0Jd5ocip8Kjb3XJpwor/SagiB1Gdlrmx8=" crossorigin="anonymous"></script>
@if (useMessagePackBinaryTransport)
{
@:<script type='module' src="https://cdn.jsdelivr.net/npm/msgpack5@6.0.2/dist/msgpack5.min.js" integrity="sha256-AxiBUMElqJXwwKZro5eMMWVExjtxeZSUQ/4nC4oCU2E=" crossorigin="anonymous"></script>
@:<script type='module' src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr-protocol-msgpack@7.0.12/dist/browser/signalr-protocol-msgpack.min.js" integrity="sha256-EpY9P2G2MG6xNQJDa2DA1JmJaaaBqzFpJcrIO28fSv8=" crossorigin="anonymous"></script>
@:<script type='module' src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr-protocol-msgpack@8.0.0-rc.2.23480.2/dist/browser/signalr-protocol-msgpack.min.js" integrity="sha256-N2wxc3H+y/zqMul5+igzPeIIOkPsyowKEZ7OOO8Rmh8=" crossorigin="anonymous"></script>
}
</environment>
<script type='module'>
Expand Down
9 changes: 5 additions & 4 deletions src/InkBall.Module/Areas/InkBall/Pages/Game.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using InkBall.Module.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -58,8 +59,8 @@ public async Task<IActionResult> OnGetAsync()
GameHub.WebSocketAllowedOrigins.AddOrUpdate($"{Request.Scheme}://{Request.Host}");

//https://developer.chrome.com/blog/enabling-shared-array-buffer/
Response.Headers.Add("Cross-Origin-Embedder-Policy", "require-corp");
Response.Headers.Add("Cross-Origin-Opener-Policy", "same-origin");
Response.Headers.Append("Cross-Origin-Embedder-Policy", "require-corp");
Response.Headers.Append("Cross-Origin-Opener-Policy", "same-origin");

var token = HttpContext.RequestAborted;

Expand Down Expand Up @@ -93,8 +94,8 @@ public async Task<IActionResult> OnGetViewAsync([FromServices] IAuthorizationSer
GameHub.WebSocketAllowedOrigins.AddOrUpdate($"{Request.Scheme}://{Request.Host}");

//https://developer.chrome.com/blog/enabling-shared-array-buffer/
Response.Headers.Add("Cross-Origin-Embedder-Policy", "require-corp");
Response.Headers.Add("Cross-Origin-Opener-Policy", "same-origin");
Response.Headers.Append("Cross-Origin-Embedder-Policy", "require-corp");
Response.Headers.Append("Cross-Origin-Opener-Policy", "same-origin");


if (!ModelState.IsValid)//model.GameID <= 0
Expand Down
81 changes: 41 additions & 40 deletions src/InkBall.Module/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.StaticFiles;
Expand Down Expand Up @@ -80,44 +81,44 @@ public class InkBallOptions : IPostConfigureOptions<StaticFileOptions>

public void PostConfigure(string name, StaticFileOptions options)
{
#region Old code

//name = name ?? throw new ArgumentNullException(nameof(name));
//options = options ?? throw new ArgumentNullException(nameof(options));

// Basic initialization in case the options weren't initialized by any other component
// options.ContentTypeProvider = options.ContentTypeProvider ?? new FileExtensionContentTypeProvider();
// if (options.FileProvider == null && WebRootFileProvider == null)
// {
// throw new InvalidOperationException("Missing FileProvider.");
// }

// options.FileProvider = options.FileProvider ?? WebRootFileProvider;

// if (OnStaticFilePrepareResponse != null)
// options.OnPrepareResponse = OnStaticFilePrepareResponse;
// else
// {
// options.OnPrepareResponse = (ctx) =>
// {
// var path = ctx.Context.Request.Path.Value;
// if (path.StartsWith("/IB/js/AIWorker"))
// {
// //https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy
// //https://web.dev/coop-coep/
// ctx.Context.Response.Headers.Add("Cross-Origin-Embedder-Policy", "require-corp");
// ctx.Context.Response.Headers.Add("Cross-Origin-Opener-Policy", "same-origin");
// }
// };
// }

// Add our provider
// var filesProvider = new ManifestEmbeddedFileProvider(GetType().Assembly, WwwRoot);
// var filesProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(

#endregion Old code
}
}
#region Old code

//name = name ?? throw new ArgumentNullException(nameof(name));
//options = options ?? throw new ArgumentNullException(nameof(options));

// Basic initialization in case the options weren't initialized by any other component
// options.ContentTypeProvider = options.ContentTypeProvider ?? new FileExtensionContentTypeProvider();
// if (options.FileProvider == null && WebRootFileProvider == null)
// {
// throw new InvalidOperationException("Missing FileProvider.");
// }

// options.FileProvider = options.FileProvider ?? WebRootFileProvider;

// if (OnStaticFilePrepareResponse != null)
// options.OnPrepareResponse = OnStaticFilePrepareResponse;
// else
// {
// options.OnPrepareResponse = (ctx) =>
// {
// var path = ctx.Context.Request.Path.Value;
// if (path.StartsWith("/IB/js/AIWorker"))
// {
// //https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy
// //https://web.dev/coop-coep/
// ctx.Context.Response.Headers.Append("Cross-Origin-Embedder-Policy", "require-corp");
// ctx.Context.Response.Headers.Append("Cross-Origin-Opener-Policy", "same-origin");
// }
// };
// }

// Add our provider
// var filesProvider = new ManifestEmbeddedFileProvider(GetType().Assembly, WwwRoot);
// var filesProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(

#endregion Old code
}
}

public static class CommonUIServiceCollectionExtensions
{
Expand Down Expand Up @@ -218,8 +219,8 @@ public static IApplicationBuilder UseStaticFilesForInkBall(this IApplicationBuil
{
//https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy
//https://web.dev/coop-coep/
ctx.Context.Response.Headers.Add("Cross-Origin-Embedder-Policy", "require-corp");
ctx.Context.Response.Headers.Add("Cross-Origin-Opener-Policy", "same-origin");
ctx.Context.Response.Headers.Append("Cross-Origin-Embedder-Policy", "require-corp");
ctx.Context.Response.Headers.Append("Cross-Origin-Opener-Policy", "same-origin");
}
}
});
Expand Down
18 changes: 9 additions & 9 deletions src/InkBall.Module/InkBall.Module.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<!-- <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> -->
<LangVersion>latest</LangVersion>
Expand All @@ -21,15 +21,15 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.13" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="7.0.13" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" Condition="$(DefineConstants.Contains('INCLUDE_POSTGRES'))" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" Condition="$(DefineConstants.Contains('INCLUDE_MYSQL'))" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" Condition="$(DefineConstants.Contains('INCLUDE_SQLSERVER'))" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-rc.2" Condition="$(DefineConstants.Contains('INCLUDE_POSTGRES'))" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2.ci.20231014172607" Condition="$(DefineConstants.Contains('INCLUDE_MYSQL'))" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0-rc.2.23480.1" Condition="$(DefineConstants.Contains('INCLUDE_SQLSERVER'))" />
<PackageReference Include="Oracle.EntityFrameworkCore" Version="7.21.12" Condition="$(DefineConstants.Contains('INCLUDE_ORACLE'))" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.13" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="MessagePack" Version="2.5.129" />
</ItemGroup>
<!--
Expand Down
10 changes: 5 additions & 5 deletions test/InkBall.Tests/InkBall.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.13" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.13" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0-rc.2.23480.1" />
<PackageReference Include="Moq" Version="4.20.69" />
</ItemGroup>

Expand Down

0 comments on commit 4aaedbb

Please sign in to comment.