Skip to content

Commit

Permalink
chore: Update CA rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Jan 4, 2024
1 parent 7e96973 commit b3ce536
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/TestApp/shared/HotReloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public async Task Is_SourcesEditable(CancellationToken ct)
var file = Path.Combine(dir, sutPath);

Assert.IsTrue(File.Exists(file));
Assert.IsTrue(File.ReadAllText(file).Contains("Original text"));
Assert.IsTrue((await File.ReadAllTextAsync(file, ct)).Contains("Original text"));

await using var _ = await HotReloadHelper.UpdateSourceFile(sutPath, "Original text", "Updated text from Can_Edit_File", waitForMetadataUpdate: false, ct);

await TestHelper.WaitFor(() => File.ReadAllText(file).Contains("Updated text from Can_Edit_File"), ct);

Assert.IsTrue(File.ReadAllText(file).Contains("Updated text from Can_Edit_File"));
Assert.IsTrue((await File.ReadAllTextAsync(file, ct)).Contains("Updated text from Can_Edit_File"));
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private static int GetTcpPort()
}
catch (global::System.Exception e)
{
global::Microsoft.Extensions.Logging.LoggerExtensions.LogError(_log, "Failed to kill dev server", e);
global::Microsoft.Extensions.Logging.LoggerExtensions.LogError(_log, e, "Failed to kill dev server");
}

await _process.WaitForExitAsync(global::System.Threading.CancellationToken.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ internal static partial class SecondaryApp
}
}

private static readonly global::System.Text.Json.JsonSerializerOptions _serializeOpts = new global::System.Text.Json.JsonSerializerOptions { DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault };
private static int _instance;

private static async global::System.Threading.Tasks.Task<string> RunLocalApp(string devServerHost, int devServerPort, UnitTestEngineConfig config, bool isAppVisible, global::System.Threading.CancellationToken ct)
{
var testOutput = global::System.IO.Path.GetTempFileName();
var configJson = global::System.Text.Json.JsonSerializer.Serialize(config, new global::System.Text.Json.JsonSerializerOptions { DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault });
var configJson = global::System.Text.Json.JsonSerializer.Serialize(config, _serializeOpts);

var childStartInfo = new global::System.Diagnostics.ProcessStartInfo(
global::System.Environment.ProcessPath ?? throw new global::System.InvalidOperationException("Cannot determine the current app executable path"),
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UI.RuntimeTests.Engine.Library/Engine/TestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#if !IS_UNO_RUNTIMETEST_PROJECT
#pragma warning disable
#endif
#pragma warning disable CA1852 // Make class final : unnecessary breaking change

using System;
using System.Linq;
Expand All @@ -11,7 +12,6 @@
namespace Uno.UI.RuntimeTests;

#if !UNO_RUNTIMETESTS_DISABLE_UI

internal record TestCase
{
public object[] Parameters { get; init; } = Array.Empty<object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#if !IS_UNO_RUNTIMETEST_PROJECT
#pragma warning disable
#endif
#pragma warning disable CA1852 // Make class final : unnecessary breaking change

using System;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Uno.UI.RuntimeTests
{
public sealed partial class UnitTestsControl
{
private class ConsoleOutputRecorder : IDisposable
private sealed class ConsoleOutputRecorder : IDisposable
{
private readonly TextWriterDuplicator _duplicator;
private readonly TextWriter _originalOutput;
Expand Down Expand Up @@ -52,7 +52,7 @@ public void Dispose()
}
}

private class TextWriterDuplicator : TextWriter
private sealed class TextWriterDuplicator : TextWriter
{
private readonly TextWriter _inner;
private readonly StringBuilder _accumulator = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#if !IS_UNO_RUNTIMETEST_PROJECT
#pragma warning disable
#endif
#pragma warning disable CA1852 // Make class final : unnecessary breaking change

public sealed partial class UnitTestsControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ private async Task ExecuteTestsForInstance(
.Select(method => new UnitTestMethodInfo(instance, method))
.ToArray();

if (!tests.Any() || testClassInfo.Type == null)
if (tests.Length <= 0 || testClassInfo.Type == null)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public UpdateFile ToMessage()
};
}

private class DevServerUpdater : IFileUpdater
private sealed class DevServerUpdater : IFileUpdater
{
/// <inheritdoc />
public async ValueTask EnsureReady(CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static partial void TryUseLocalFileUpdater()
public static void UseLocalFileUpdater()
=> Use(new LocalFileUpdater());

private class LocalFileUpdater : IFileUpdater
private sealed class LocalFileUpdater : IFileUpdater
{
/// <inheritdoc />
public async global::System.Threading.Tasks.ValueTask EnsureReady(global::System.Threading.CancellationToken ct) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Uno.UI.RuntimeTests;

public static partial class HotReloadHelper
{
private class NotSupported : IFileUpdater
private sealed class NotSupported : IFileUpdater
{
/// <inheritdoc />
public global::System.Threading.Tasks.ValueTask EnsureReady(global::System.Threading.CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial record FileEdit(string FilePath, string OldText, string NewText)
public FileEdit Revert() => this with { OldText = NewText, NewText = OldText };
}

private record RevertFileEdit(FileEdit Edition, bool WaitForMetadataUpdate) : global::System.IAsyncDisposable
private sealed record RevertFileEdit(FileEdit Edition, bool WaitForMetadataUpdate) : global::System.IAsyncDisposable
{
/// <inheritdoc />
public async global::System.Threading.Tasks.ValueTask DisposeAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void InjectMouseInput(IEnumerable<InjectedInputMouseInfo?> input)
public void InjectMouseInput(params InjectedInputMouseInfo?[] input)
=> Injector.InjectMouseInput(input.Where(i => i is not null).Cast<InjectedInputMouseInfo>());

private record PointerSubscription(InputInjectorHelper Injector, PointerDeviceType Previous, PointerDeviceType Current) : IDisposable
private sealed record PointerSubscription(InputInjectorHelper Injector, PointerDeviceType Previous, PointerDeviceType Current) : IDisposable
{
/// <inheritdoc />
public void Dispose()
Expand Down

0 comments on commit b3ce536

Please sign in to comment.