-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve reliability of hot reload test engine
- Loading branch information
Showing
14 changed files
with
439 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/RuntimeTestDevServerAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#if !UNO_RUNTIMETESTS_DISABLE_EMBEDDEDRUNNER | ||
#nullable enable | ||
|
||
#if !IS_UNO_RUNTIMETEST_PROJECT | ||
#pragma warning disable | ||
#endif | ||
|
||
using System; | ||
using System.Linq; | ||
|
||
namespace Uno.UI.RuntimeTests.Engine; | ||
|
||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] | ||
public sealed class RuntimeTestDevServerAttribute : Attribute | ||
{ | ||
// Note: We prefer to capture it at compilation time instead of using reflection, | ||
// so if dev-server assembly has been overriden with invalid version (e.g. for debug purposes), | ||
// we are still able to get the right one. | ||
|
||
/// <summary> | ||
/// The version of the DevServer package used to compile the test engine. | ||
/// </summary> | ||
public string Version { get; } | ||
|
||
public RuntimeTestDevServerAttribute(string version) | ||
{ | ||
Version = version; | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Uno.UI.RuntimeTests.Engine.Library/Engine/ExternalRunner/_Private/LogScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#if !UNO_RUNTIMETESTS_DISABLE_UI | ||
using System; | ||
using System.Linq; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Uno.UI.RuntimeTests.Internal.Helpers; | ||
|
||
internal static class LoggerExtensions | ||
{ | ||
public static LogScope Scope(this ILogger log, string scopeName) | ||
#if false | ||
=> new(log, log.BeginScope(scopeName)); | ||
#else | ||
=> new (Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory.CreateLogger(typeof(DevServer).FullName + "#" + scopeName)); | ||
#endif | ||
} | ||
|
||
internal readonly struct LogScope : IDisposable, ILogger | ||
{ | ||
private readonly ILogger _logger; | ||
private readonly IDisposable? _scope; | ||
|
||
public LogScope(ILogger logger, IDisposable? scope = null) | ||
{ | ||
_logger = logger; | ||
_scope = scope; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) | ||
=> _logger.Log(logLevel, eventId, state, exception, formatter); | ||
|
||
/// <inheritdoc /> | ||
public bool IsEnabled(LogLevel logLevel) | ||
=> _logger.IsEnabled(logLevel); | ||
|
||
/// <inheritdoc /> | ||
public IDisposable BeginScope<TState>(TState state) | ||
=> _logger.BeginScope(state); | ||
|
||
/// <inheritdoc /> | ||
public void Dispose() | ||
=> _scope?.Dispose(); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.