Skip to content

Commit 05d3b97

Browse files
Updates to work with Blazor 3.0.0-preview4
1 parent 8e1afee commit 05d3b97

16 files changed

+136
-62
lines changed

.vsts-ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,22 @@ variables:
44
buildConfiguration: 'Release'
55

66
steps:
7+
8+
- task: DotNetCoreInstaller@0
9+
inputs:
10+
packageType: 'sdk'
11+
version: '3.0.100-preview4-011223'
12+
713
- task: Npm@1
814
inputs:
915
command: 'install'
1016
workingDir: src/Blazor.Extensions.Logging.JS
17+
18+
- task: DotNetCoreCLI@2
19+
inputs:
20+
command: 'restore'
21+
projects: '**/*.csproj'
22+
1123
- task: DotNetCoreCLI@2
1224
inputs:
1325
command: 'build'

.vsts-release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@ variables:
44
buildConfiguration: 'Release'
55

66
steps:
7+
8+
- task: DotNetCoreInstaller@0
9+
inputs:
10+
packageType: 'sdk'
11+
version: '3.0.100-preview4-011223'
12+
713
- task: Npm@1
814
inputs:
915
command: 'install'
1016
workingDir: src/Blazor.Extensions.Logging.JS
1117

18+
- task: DotNetCoreCLI@2
19+
inputs:
20+
command: 'restore'
21+
projects: '**/*.csproj'
22+
1223
- task: DotNetCoreCLI@2
1324
inputs:
1425
command: 'build'

src/Blazor.Extensions.Logging.JS/Blazor.Extensions.Logging.JS.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
17+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
1818
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
1919
</ItemGroup>
2020

src/Blazor.Extensions.Logging.JS/package-lock.json

Lines changed: 65 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Blazor.Extensions.Logging/Blazor.Extensions.Logging.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<Title>Blazor Extensions Logging</Title>
@@ -11,8 +11,8 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
15-
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
14+
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
15+
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0-preview4.19216.2" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/Blazor.Extensions.Logging/BrowserConsoleLogger.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
using Microsoft.Extensions.Logging;
2-
using Microsoft.Extensions.Logging.Abstractions.Internal;
32
using Microsoft.JSInterop;
43
using System;
54

65
namespace Blazor.Extensions.Logging
76
{
87
internal class BrowserConsoleLogger : ILogger
98
{
9+
1010
#if !DESKTOP_BUILD
1111
private const string LoggerFunctionName = "BlazorExtensions.Logging.BrowserConsoleLogger.Log";
1212
#endif
1313

14+
private readonly IJSRuntime runtime;
1415
private Func<string, LogLevel, bool> filter;
1516

16-
public BrowserConsoleLogger(string name, Func<string, LogLevel, bool> filter)
17+
public BrowserConsoleLogger(IJSRuntime runtime, string name, Func<string, LogLevel, bool> filter)
1718
{
19+
this.runtime = runtime;
1820
this.filter = filter ?? ((category, logLevel) => true);
1921
this.Name = name ?? throw new ArgumentNullException(nameof(name));
2022
}
2123

22-
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
24+
public async void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
2325
{
24-
if (!IsEnabled(logLevel))
26+
if (!this.IsEnabled(logLevel))
2527
{
2628
return;
2729
}
@@ -39,9 +41,9 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
3941

4042
message = internalFormatter.ToString();
4143
}
42-
44+
4345
#if !DESKTOP_BUILD
44-
((IJSInProcessRuntime)JSRuntime.Current).Invoke<object>(LoggerFunctionName, message);
46+
await this.runtime.InvokeAsync<object>(LoggerFunctionName, message);
4547
#else
4648
Console.WriteLine(message);
4749
#endif
@@ -68,6 +70,6 @@ public Func<string, LogLevel, bool> Filter
6870

6971
public string Name { get; }
7072

71-
public IDisposable BeginScope<TState>(TState state) => NullScope.Instance;
73+
public IDisposable BeginScope<TState>(TState state) => null;
7274
}
7375
}

0 commit comments

Comments
 (0)