Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[automated] Merge branch 'release/9.0-rc2' => 'release/9.0' #57975

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,31 +388,31 @@
<Uri>https://github.com/dotnet/winforms</Uri>
<Sha>b1fd89453ed5e3ad91e4f18c9386cac8dade6e36</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24463.2">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24466.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>bcba6939456aa552554eae9ea9538a039cc98d96</Sha>
<Sha>04b9022eba9c184a8036328af513c22e6949e8b6</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24463.2">
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.24466.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>bcba6939456aa552554eae9ea9538a039cc98d96</Sha>
<Sha>04b9022eba9c184a8036328af513c22e6949e8b6</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="9.0.0-beta.24463.2">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="9.0.0-beta.24466.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>bcba6939456aa552554eae9ea9538a039cc98d96</Sha>
<Sha>04b9022eba9c184a8036328af513c22e6949e8b6</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="9.0.0-beta.24463.2">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="9.0.0-beta.24466.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>bcba6939456aa552554eae9ea9538a039cc98d96</Sha>
<Sha>04b9022eba9c184a8036328af513c22e6949e8b6</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="9.0.0-beta.24463.2">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="9.0.0-beta.24466.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>bcba6939456aa552554eae9ea9538a039cc98d96</Sha>
<Sha>04b9022eba9c184a8036328af513c22e6949e8b6</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="9.0.0-beta.24463.2">
<Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="9.0.0-beta.24466.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>bcba6939456aa552554eae9ea9538a039cc98d96</Sha>
<Sha>04b9022eba9c184a8036328af513c22e6949e8b6</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Diagnostics.Testing" Version="9.0.0-preview.8.24456.2">
<Uri>https://github.com/dotnet/extensions</Uri>
Expand Down
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@
<NuGetVersioningVersion>6.2.4</NuGetVersioningVersion>
<NuGetFrameworksVersion>6.2.4</NuGetFrameworksVersion>
<!-- Packages from dotnet/arcade -->
<MicrosoftDotNetBuildTasksInstallersVersion>9.0.0-beta.24463.2</MicrosoftDotNetBuildTasksInstallersVersion>
<MicrosoftDotNetBuildTasksTemplatingVersion>9.0.0-beta.24463.2</MicrosoftDotNetBuildTasksTemplatingVersion>
<MicrosoftDotNetRemoteExecutorVersion>9.0.0-beta.24463.2</MicrosoftDotNetRemoteExecutorVersion>
<MicrosoftSourceBuildIntermediatearcadeVersion>9.0.0-beta.24463.2</MicrosoftSourceBuildIntermediatearcadeVersion>
<MicrosoftDotNetBuildTasksInstallersVersion>9.0.0-beta.24466.2</MicrosoftDotNetBuildTasksInstallersVersion>
<MicrosoftDotNetBuildTasksTemplatingVersion>9.0.0-beta.24466.2</MicrosoftDotNetBuildTasksTemplatingVersion>
<MicrosoftDotNetRemoteExecutorVersion>9.0.0-beta.24466.2</MicrosoftDotNetRemoteExecutorVersion>
<MicrosoftSourceBuildIntermediatearcadeVersion>9.0.0-beta.24466.2</MicrosoftSourceBuildIntermediatearcadeVersion>
<!-- Packages from dotnet/source-build-externals -->
<MicrosoftSourceBuildIntermediatesourcebuildexternalsVersion>9.0.0-alpha.1.24452.1</MicrosoftSourceBuildIntermediatesourcebuildexternalsVersion>
<!-- Packages from dotnet/source-build-reference-packages -->
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"jdk": "11"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24463.2",
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.24463.2"
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24466.2",
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.24466.2"
}
}
30 changes: 16 additions & 14 deletions src/Components/WebAssembly/DevServer/src/Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -29,27 +30,28 @@ public static void Configure(IApplicationBuilder app, IConfiguration configurati

app.UseWebAssemblyDebugging();

bool applyCopHeaders = configuration.GetValue<bool>("ApplyCopHeaders");
var webHostEnvironment = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
var applyCopHeaders = configuration.GetValue<bool>("ApplyCopHeaders");

if (applyCopHeaders)
app.Use(async (ctx, next) =>
{
app.Use(async (ctx, next) =>
if (ctx.Request.Path.StartsWithSegments("/_framework/blazor.boot.json"))
{
if (ctx.Request.Path.StartsWithSegments("/_framework") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.server.js") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.web.js"))
ctx.Response.Headers.Append("Blazor-Environment", webHostEnvironment.EnvironmentName);
}
else if (applyCopHeaders && ctx.Request.Path.StartsWithSegments("/_framework") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.server.js") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.web.js"))
{
var fileExtension = Path.GetExtension(ctx.Request.Path);
if (string.Equals(fileExtension, ".js", StringComparison.OrdinalIgnoreCase))
{
string fileExtension = Path.GetExtension(ctx.Request.Path);
if (string.Equals(fileExtension, ".js"))
{
// Browser multi-threaded runtime requires cross-origin policy headers to enable SharedArrayBuffer.
ApplyCrossOriginPolicyHeaders(ctx);
}
// Browser multi-threaded runtime requires cross-origin policy headers to enable SharedArrayBuffer.
ApplyCrossOriginPolicyHeaders(ctx);
}
}

await next(ctx);
});
}
await next(ctx);
});

//app.UseBlazorFrameworkFiles();
app.UseRouting();

app.UseStaticFiles(new StaticFileOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public void WebAssemblyConfiguration_Works()

if (_serverFixture.TestTrimmedOrMultithreadingApps)
{
// Verify that the environment gets detected as 'Production'.
Browser.Equal("Production", () => _appElement.FindElement(By.Id("environment")).Text);

// Verify values overriden by an environment specific 'appsettings.$(Environment).json are read
Assert.Equal("Prod key2-value", _appElement.FindElement(By.Id("key2")).Text);

Expand All @@ -47,6 +50,9 @@ public void WebAssemblyConfiguration_Works()
}
else
{
// Verify that the dev server always correctly serves the 'Blazor-Environment: Development' header.
Browser.Equal("Development", () => _appElement.FindElement(By.Id("environment")).Text);

// Verify values overriden by an environment specific 'appsettings.$(Environment).json are read
Assert.Equal("Development key2-value", _appElement.FindElement(By.Id("key2")).Text);

Expand Down
102 changes: 22 additions & 80 deletions src/Http/Http.Extensions/src/HttpResponseJsonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,12 @@ public static Task WriteAsJsonAsync<TValue>(

response.ContentType = contentType ?? ContentTypeConstants.JsonContentTypeWithCharset;

var startTask = Task.CompletedTask;
if (!response.HasStarted)
{
// Flush headers before starting Json serialization. This avoids an extra layer of buffering before the first flush.
startTask = response.StartAsync(cancellationToken);
}

// if no user provided token, pass the RequestAborted token and ignore OperationCanceledException
if (!startTask.IsCompleted || !cancellationToken.CanBeCanceled)
if (!cancellationToken.CanBeCanceled)
{
return WriteAsJsonAsyncSlow(startTask, response.BodyWriter, value, options,
ignoreOCE: !cancellationToken.CanBeCanceled,
cancellationToken.CanBeCanceled ? cancellationToken : response.HttpContext.RequestAborted);
return WriteAsJsonAsyncSlow(response.BodyWriter, value, options, response.HttpContext.RequestAborted);
}

startTask.GetAwaiter().GetResult();
return JsonSerializer.SerializeAsync(response.BodyWriter, value, options, cancellationToken);
}

Expand All @@ -131,33 +121,22 @@ public static Task WriteAsJsonAsync<TValue>(

response.ContentType = contentType ?? ContentTypeConstants.JsonContentTypeWithCharset;

var startTask = Task.CompletedTask;
if (!response.HasStarted)
{
// Flush headers before starting Json serialization. This avoids an extra layer of buffering before the first flush.
startTask = response.StartAsync(cancellationToken);
}

// if no user provided token, pass the RequestAborted token and ignore OperationCanceledException
if (!startTask.IsCompleted || !cancellationToken.CanBeCanceled)
if (!cancellationToken.CanBeCanceled)
{
return WriteAsJsonAsyncSlow(startTask, response, value, jsonTypeInfo,
ignoreOCE: !cancellationToken.CanBeCanceled,
cancellationToken.CanBeCanceled ? cancellationToken : response.HttpContext.RequestAborted);
return WriteAsJsonAsyncSlow(response, value, jsonTypeInfo, response.HttpContext.RequestAborted);
}

startTask.GetAwaiter().GetResult();
return JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);

static async Task WriteAsJsonAsyncSlow(Task startTask, HttpResponse response, TValue value, JsonTypeInfo<TValue> jsonTypeInfo,
bool ignoreOCE, CancellationToken cancellationToken)
static async Task WriteAsJsonAsyncSlow(HttpResponse response, TValue value, JsonTypeInfo<TValue> jsonTypeInfo,
CancellationToken cancellationToken)
{
try
{
await startTask;
await JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);
}
catch (OperationCanceledException) when (ignoreOCE) { }
catch (OperationCanceledException) { }
}
}

Expand All @@ -184,52 +163,38 @@ public static Task WriteAsJsonAsync(

response.ContentType = contentType ?? ContentTypeConstants.JsonContentTypeWithCharset;

var startTask = Task.CompletedTask;
if (!response.HasStarted)
{
// Flush headers before starting Json serialization. This avoids an extra layer of buffering before the first flush.
startTask = response.StartAsync(cancellationToken);
}

// if no user provided token, pass the RequestAborted token and ignore OperationCanceledException
if (!startTask.IsCompleted || !cancellationToken.CanBeCanceled)
if (!cancellationToken.CanBeCanceled)
{
return WriteAsJsonAsyncSlow(startTask, response, value, jsonTypeInfo,
ignoreOCE: !cancellationToken.CanBeCanceled,
cancellationToken.CanBeCanceled ? cancellationToken : response.HttpContext.RequestAborted);
return WriteAsJsonAsyncSlow(response, value, jsonTypeInfo, response.HttpContext.RequestAborted);
}

startTask.GetAwaiter().GetResult();
return JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);

static async Task WriteAsJsonAsyncSlow(Task startTask, HttpResponse response, object? value, JsonTypeInfo jsonTypeInfo,
bool ignoreOCE, CancellationToken cancellationToken)
static async Task WriteAsJsonAsyncSlow(HttpResponse response, object? value, JsonTypeInfo jsonTypeInfo,
CancellationToken cancellationToken)
{
try
{
await startTask;
await JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);
}
catch (OperationCanceledException) when (ignoreOCE) { }
catch (OperationCanceledException) { }
}
}

[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
private static async Task WriteAsJsonAsyncSlow<TValue>(
Task startTask,
PipeWriter body,
TValue value,
JsonSerializerOptions? options,
bool ignoreOCE,
CancellationToken cancellationToken)
{
try
{
await startTask;
await JsonSerializer.SerializeAsync(body, value, options, cancellationToken);
}
catch (OperationCanceledException) when (ignoreOCE) { }
catch (OperationCanceledException) { }
}

/// <summary>
Expand Down Expand Up @@ -304,42 +269,30 @@ public static Task WriteAsJsonAsync(

response.ContentType = contentType ?? ContentTypeConstants.JsonContentTypeWithCharset;

var startTask = Task.CompletedTask;
if (!response.HasStarted)
{
// Flush headers before starting Json serialization. This avoids an extra layer of buffering before the first flush.
startTask = response.StartAsync(cancellationToken);
}

// if no user provided token, pass the RequestAborted token and ignore OperationCanceledException
if (!startTask.IsCompleted || !cancellationToken.CanBeCanceled)
if (!cancellationToken.CanBeCanceled)
{
return WriteAsJsonAsyncSlow(startTask, response.BodyWriter, value, type, options,
ignoreOCE: !cancellationToken.CanBeCanceled,
cancellationToken.CanBeCanceled ? cancellationToken : response.HttpContext.RequestAborted);
return WriteAsJsonAsyncSlow(response.BodyWriter, value, type, options,
response.HttpContext.RequestAborted);
}

startTask.GetAwaiter().GetResult();
return JsonSerializer.SerializeAsync(response.BodyWriter, value, type, options, cancellationToken);
}

[RequiresUnreferencedCode(RequiresUnreferencedCodeMessage)]
[RequiresDynamicCode(RequiresDynamicCodeMessage)]
private static async Task WriteAsJsonAsyncSlow(
Task startTask,
PipeWriter body,
object? value,
Type type,
JsonSerializerOptions? options,
bool ignoreOCE,
CancellationToken cancellationToken)
{
try
{
await startTask;
await JsonSerializer.SerializeAsync(body, value, type, options, cancellationToken);
}
catch (OperationCanceledException) when (ignoreOCE) { }
catch (OperationCanceledException) { }
}

/// <summary>
Expand Down Expand Up @@ -367,33 +320,22 @@ public static Task WriteAsJsonAsync(

response.ContentType = contentType ?? ContentTypeConstants.JsonContentTypeWithCharset;

var startTask = Task.CompletedTask;
if (!response.HasStarted)
{
// Flush headers before starting Json serialization. This avoids an extra layer of buffering before the first flush.
startTask = response.StartAsync(cancellationToken);
}

// if no user provided token, pass the RequestAborted token and ignore OperationCanceledException
if (!startTask.IsCompleted || !cancellationToken.CanBeCanceled)
if (!cancellationToken.CanBeCanceled)
{
return WriteAsJsonAsyncSlow(startTask, response.BodyWriter, value, type, context,
ignoreOCE: !cancellationToken.CanBeCanceled,
cancellationToken.CanBeCanceled ? cancellationToken : response.HttpContext.RequestAborted);
return WriteAsJsonAsyncSlow(response.BodyWriter, value, type, context, response.HttpContext.RequestAborted);
}

startTask.GetAwaiter().GetResult();
return JsonSerializer.SerializeAsync(response.BodyWriter, value, type, context, cancellationToken);

static async Task WriteAsJsonAsyncSlow(Task startTask, PipeWriter body, object? value, Type type, JsonSerializerContext context,
bool ignoreOCE, CancellationToken cancellationToken)
static async Task WriteAsJsonAsyncSlow(PipeWriter body, object? value, Type type, JsonSerializerContext context,
CancellationToken cancellationToken)
{
try
{
await startTask;
await JsonSerializer.SerializeAsync(body, value, type, context, cancellationToken);
}
catch (OperationCanceledException) when (ignoreOCE) { }
catch (OperationCanceledException) { }
}
}

Expand Down
Loading
Loading