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