From 047f6315c549eede2e01c8c32b763664b015543b Mon Sep 17 00:00:00 2001 From: David Date: Thu, 11 Jan 2024 13:21:41 -0500 Subject: [PATCH] feat: Add partial construtor injection point in UnitTestControl + fix logging --- .../Engine/UI/UnitTestsControl.cs | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs index fffc6ac..6adbd31 100644 --- a/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs +++ b/src/Uno.UI.RuntimeTests.Engine.Library/Engine/UI/UnitTestsControl.cs @@ -6,6 +6,7 @@ #pragma warning disable #endif #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously +#pragma warning disable CA1848 // Use the LoggerMessage delegates using System; using System.Collections.Generic; @@ -28,11 +29,6 @@ using Uno.UI.RuntimeTests.Engine; using Uno.UI.RuntimeTests.Internal.Helpers; -#if HAS_UNO -using Uno.Foundation.Logging; -using Uno.Logging; -#endif - #if HAS_UNO_WINUI || WINDOWS_WINUI using Windows.UI; using Windows.UI.Core; @@ -66,9 +62,7 @@ namespace Uno.UI.RuntimeTests; public sealed partial class UnitTestsControl : UserControl { #pragma warning disable CS0109 -#if HAS_UNO private new readonly ILogger _log = Uno.Extensions.LogExtensionPoint.Log(typeof(UnitTestsControl)); -#endif #pragma warning restore CS0109 private Task? _runner; @@ -116,8 +110,12 @@ public UnitTestsControl() #if HAS_UNO _applicationView = ApplicationView.GetForCurrentView(); #endif + + ConstructPartial(); } + partial void ConstructPartial(); + internal IEnumerable Results => _testCases; private static void OverrideDebugProviderAsserts() @@ -262,9 +260,7 @@ private void StopRunningTests() private async Task ReportMessage(string message, bool isRunning = true) { -#if HAS_UNO - _log?.Info(message); -#endif + _log.LogInformation(message); void Setter() { @@ -358,12 +354,11 @@ private void ReportTestResult(params TestCaseResult[] results) UpdateUI(result); } }); -#if HAS_UNO + foreach (var result in results) { - _log?.Info($"Test completed '{result.TestName}'='{result.TestResult}'"); + _log.LogInformation($"Test completed '{result.TestName}'='{result.TestResult}'"); } -#endif void UpdateUI(TestCaseResult result) { @@ -536,10 +531,9 @@ private void EnableConfigPersistence() testFilter.Text = config.Filter; } } - catch (Exception) + catch (Exception error) { - // UNO MOVE - // _log.Error("Failed to restore runtime tests config", e); + _log.LogError(error, "Failed to restore runtime tests config."); } }