Родитель
182d2ff174
Коммит
51270e6f88
|
@ -1,6 +1,3 @@
|
|||
pool:
|
||||
vmImage: 'windows-2022'
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
|
@ -16,15 +13,37 @@ pr:
|
|||
- release/stable/*
|
||||
|
||||
variables:
|
||||
# net6 preview install related
|
||||
DotNet.Cli.Telemetry.OptOut: true
|
||||
|
||||
jobs:
|
||||
- job: Packages
|
||||
|
||||
pool:
|
||||
vmImage: 'windows-2022'
|
||||
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
variables:
|
||||
NUGET_PACKAGES: $(build.sourcesdirectory)/.nuget
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
OSLog:
|
||||
ProjectToBuild: '$(build.sourcesdirectory)/src/Uno.Extensions.Logging.OSLog/Uno.Extensions.Logging.OSLog.csproj'
|
||||
DotNetVersion: 6.0.300
|
||||
UnoCheck.Version: '1.3.1'
|
||||
DotNet.Cli.Telemetry.OptOut: true
|
||||
UnoCheck.Manifest: https://raw.githubusercontent.com/unoplatform/uno.check/8c7f669060a6cca50f71bb0845281c424ad7eb0d/manifests/uno.ui-preview.manifest.json
|
||||
|
||||
steps:
|
||||
WebAssembly:
|
||||
ProjectToBuild: '$(build.sourcesdirectory)/src/Uno.Extensions.Logging.WebAssembly.Console/Uno.Extensions.Logging.WebAssembly.Console.csproj'
|
||||
DotNetVersion: 7.0.102
|
||||
UnoCheck.Version: '1.11.0-dev.2'
|
||||
UnoCheck.Manifest: https://raw.githubusercontent.com/unoplatform/uno.check/146b0b4b23d866bef455494a12ad7ffd2f6f2d20/manifests/uno.ui.manifest.json
|
||||
|
||||
steps:
|
||||
- checkout: self
|
||||
clean: "true"
|
||||
clean: true
|
||||
|
||||
- task: gitversion/setup@0
|
||||
inputs:
|
||||
|
@ -43,20 +62,26 @@ steps:
|
|||
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1
|
||||
& .\dotnet-install.ps1 -Version $(DotNetVersion) -InstallDir "$env:ProgramFiles\dotnet\" -Verbose
|
||||
& dotnet --list-sdks
|
||||
displayName: install .NET $(DotNetVersion)
|
||||
displayName: Install .NET $(DotNetVersion)
|
||||
errorActionPreference: stop
|
||||
|
||||
- powershell: |
|
||||
& dotnet tool update --global uno.check --version $(UnoCheck.Version) --add-source https://api.nuget.org/v3/index.json
|
||||
& uno-check --ci --non-interactive --fix --skip androidsdk --skip androidemulator --skip xcode --skip vswin --skip vsmac --manifest $(UnoCheck.Manifest)
|
||||
displayName: Install .NET 6 Workloads
|
||||
displayName: Install .NET Workloads
|
||||
errorActionPreference: continue
|
||||
ignoreLASTEXITCODE: true
|
||||
|
||||
- powershell: |
|
||||
rm src/global.json
|
||||
mv src/global.net6.json src/global.json
|
||||
displayName: Replace global.json
|
||||
condition: eq(variables['DotNetVersion'], '6.0.300')
|
||||
|
||||
- task: MSBuild@1
|
||||
displayName: Build Package
|
||||
inputs:
|
||||
solution: $(build.sourcesdirectory)/src/Uno.Extensions.Logging.sln
|
||||
solution: $(ProjectToBuild)
|
||||
msbuildLocationMethod: version
|
||||
msbuildVersion: latest
|
||||
msbuildArchitecture: x86
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<TargetFrameworks>netstandard2.0;net5.0;net7.0</TargetFrameworks>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -8,9 +8,13 @@ using System.Text;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Uno.Foundation;
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
using System.Runtime.InteropServices.JavaScript;
|
||||
#endif
|
||||
|
||||
namespace Uno.Extensions.Logging.WebAssembly
|
||||
{
|
||||
internal class WebAssemblyConsoleLogger : ILogger<object>, ILogger
|
||||
internal partial class WebAssemblyConsoleLogger : ILogger<object>, ILogger
|
||||
{
|
||||
private static readonly string _loglevelPadding = ": ";
|
||||
private static readonly string _messagePadding;
|
||||
|
@ -75,8 +79,6 @@ namespace Uno.Extensions.Logging.WebAssembly
|
|||
CreateDefaultLogMessage(_logBuilder, logLevel, logName, eventId, message, exception);
|
||||
var formattedMessage = _logBuilder.ToString();
|
||||
|
||||
void Invoke(string method, string message) => WebAssemblyRuntime.InvokeJS($"{method}(\"{WebAssemblyRuntime.EscapeJs(message)}\")");
|
||||
|
||||
switch (logLevel)
|
||||
{
|
||||
case LogLevel.Trace:
|
||||
|
@ -87,16 +89,16 @@ namespace Uno.Extensions.Logging.WebAssembly
|
|||
// messages if you enable "Verbose" in the filter dropdown (which is off
|
||||
// by default). As such "console.debug" is the best choice for messages
|
||||
// with a lower severity level than "Information".
|
||||
Invoke("console.debug", formattedMessage);
|
||||
NativeMethods.LogDebug(formattedMessage);
|
||||
break;
|
||||
case LogLevel.Information:
|
||||
Invoke("console.info", formattedMessage);
|
||||
NativeMethods.LogInfo(formattedMessage);
|
||||
break;
|
||||
case LogLevel.Warning:
|
||||
Invoke("console.warn", formattedMessage);
|
||||
NativeMethods.LogWarning(formattedMessage);
|
||||
break;
|
||||
case LogLevel.Error:
|
||||
Invoke("console.error", formattedMessage);
|
||||
NativeMethods.LogError(formattedMessage);
|
||||
break;
|
||||
case LogLevel.Critical:
|
||||
// Writing to Console.Error is even more severe than calling console.error,
|
||||
|
@ -108,7 +110,7 @@ namespace Uno.Extensions.Logging.WebAssembly
|
|||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"Failed to log \"{message}\": {ex}");
|
||||
}
|
||||
|
@ -177,5 +179,51 @@ namespace Uno.Extensions.Logging.WebAssembly
|
|||
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
private static partial class NativeMethods
|
||||
{
|
||||
private static void Invoke(string method, string message)
|
||||
=> WebAssemblyRuntime.InvokeJS($"{method}(\"{WebAssemblyRuntime.EscapeJs(message)}\")");
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[JSImport("globalThis.console.debug")]
|
||||
#endif
|
||||
public static partial void LogDebug(string message);
|
||||
|
||||
#if !NET7_0_OR_GREATER
|
||||
public static partial void LogDebug(string message)
|
||||
=> Invoke("console.debug", message);
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[JSImport("globalThis.console.info")]
|
||||
#endif
|
||||
public static partial void LogInfo(string message);
|
||||
|
||||
#if !NET7_0_OR_GREATER
|
||||
public static partial void LogInfo(string message)
|
||||
=> Invoke("console.info", message);
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[JSImport("globalThis.console.warn")]
|
||||
#endif
|
||||
public static partial void LogWarning(string message);
|
||||
|
||||
#if !NET7_0_OR_GREATER
|
||||
public static partial void LogWarning(string message)
|
||||
=> Invoke("console.warn", message);
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[JSImport("globalThis.console.error")]
|
||||
#endif
|
||||
public static partial void LogError(string message);
|
||||
|
||||
#if !NET7_0_OR_GREATER
|
||||
public static partial void LogError(string message)
|
||||
=> Invoke("console.error", message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
"msbuild-sdks": {
|
||||
"MSBuild.Sdk.Extras": "3.0.44"
|
||||
},
|
||||
"sdk": { "allowPrerelease": true }
|
||||
"sdk": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"msbuild-sdks": {
|
||||
"MSBuild.Sdk.Extras": "3.0.44"
|
||||
},
|
||||
"sdk": {
|
||||
"version": "6.0.300",
|
||||
"rollForward": "patch"
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче