Skip to content

Commit dbaafbd

Browse files
committed
Merge in 'release/6.0' changes
2 parents c4f7ea9 + 82ee208 commit dbaafbd

File tree

7 files changed

+167
-91
lines changed

7 files changed

+167
-91
lines changed

src/Components/Web.JS/src/Platform/BootConfig.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ export class BootConfigResult {
1212
loadBootResource('manifest', 'blazor.boot.json', '_framework/blazor.boot.json', '') :
1313
defaultLoadBlazorBootJson('_framework/blazor.boot.json');
1414

15-
const bootConfigResponse = loaderResponse instanceof Promise ?
16-
await loaderResponse :
17-
await defaultLoadBlazorBootJson(loaderResponse ?? '_framework/blazor.boot.json');
15+
let bootConfigResponse: Response;
16+
17+
if (!loaderResponse) {
18+
bootConfigResponse = await defaultLoadBlazorBootJson('_framework/blazor.boot.json');
19+
} else if (typeof loaderResponse === 'string') {
20+
bootConfigResponse = await defaultLoadBlazorBootJson(loaderResponse);
21+
} else {
22+
bootConfigResponse = await loaderResponse;
23+
}
1824

1925
// While we can expect an ASP.NET Core hosted application to include the environment, other
2026
// hosts may not. Assume 'Production' in the absence of any specified value.

src/Middleware/HttpLogging/src/FileLoggerProcessor.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal partial class FileLoggerProcessor : IAsyncDisposable
3030
private bool _maxFilesReached;
3131
private TimeSpan _flushInterval;
3232
private W3CLoggingFields _fields;
33-
private DateTime _today = DateTime.Now;
33+
private DateTime _today;
3434
private bool _firstFile = true;
3535

3636
private readonly IOptionsMonitor<W3CLoggerOptions> _options;
@@ -40,6 +40,9 @@ internal partial class FileLoggerProcessor : IAsyncDisposable
4040
private readonly Task _outputTask;
4141
private readonly CancellationTokenSource _cancellationTokenSource;
4242

43+
// Internal to allow for testing
44+
internal ISystemDateTime SystemDateTime {get; set;} = new SystemDateTime();
45+
4346
private readonly object _pathLock = new object();
4447

4548
public FileLoggerProcessor(IOptionsMonitor<W3CLoggerOptions> options, IHostEnvironment environment, ILoggerFactory factory)
@@ -98,6 +101,8 @@ public FileLoggerProcessor(IOptionsMonitor<W3CLoggerOptions> options, IHostEnvir
98101
}
99102
});
100103

104+
_today = SystemDateTime.Now;
105+
101106
// Start message queue processor
102107
_cancellationTokenSource = new CancellationTokenSource();
103108
_outputTask = Task.Run(ProcessLogQueue);
@@ -155,7 +160,7 @@ private async Task ProcessLogQueue()
155160
private async Task WriteMessagesAsync(List<string> messages, CancellationToken cancellationToken)
156161
{
157162
// Files are written up to _maxFileSize before rolling to a new file
158-
DateTime today = DateTime.Now;
163+
DateTime today = SystemDateTime.Now;
159164

160165
if (!TryCreateDirectory())
161166
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.HttpLogging
5+
{
6+
internal interface ISystemDateTime
7+
{
8+
/// <summary>
9+
/// Retrieves the date and time currently set for this machine.
10+
/// </summary>
11+
DateTime Now { get; }
12+
}
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.HttpLogging
5+
{
6+
internal class SystemDateTime : ISystemDateTime
7+
{
8+
public DateTime Now => DateTime.Now;
9+
}
10+
}

src/Middleware/HttpLogging/test/FileLoggerProcessorTests.cs

Lines changed: 116 additions & 84 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.HttpLogging
5+
{
6+
internal class MockSystemDateTime : ISystemDateTime
7+
{
8+
public DateTime Now { get; set; }
9+
}
10+
}

src/Middleware/Spa/SpaProxy/src/SpaProxyLaunchManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private void LaunchStopScriptMacOS(int spaProcessId)
251251
{
252252
var fileName = Guid.NewGuid().ToString("N") + ".sh";
253253
var scriptPath = Path.Combine(AppContext.BaseDirectory, fileName);
254-
var stopScript = @$"function list_child_processes(){{
254+
var stopScript = @$"function list_child_processes () {{
255255
local ppid=$1;
256256
local current_children=$(pgrep -P $ppid);
257257
local local_child;
@@ -282,7 +282,7 @@ private void LaunchStopScriptMacOS(int spaProcessId)
282282
done;
283283
rm {scriptPath};
284284
";
285-
File.WriteAllText(scriptPath, stopScript);
285+
File.WriteAllText(scriptPath, stopScript.ReplaceLineEndings());
286286

287287
var stopScriptInfo = new ProcessStartInfo("/bin/bash", scriptPath)
288288
{

0 commit comments

Comments
 (0)