Apply code style formatting and restore partial modifiers on Avalonia views

Linter/formatter pass across the full codebase. Restores required partial
keyword on AXAML code-behind classes that the formatter incorrectly removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-03-31 07:58:13 -04:00
parent 55ef854612
commit 41a6b66943
221 changed files with 4274 additions and 3823 deletions

View File

@@ -20,10 +20,7 @@ public class AlarmsCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -47,10 +44,7 @@ public class AlarmsCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -74,10 +68,7 @@ public class AlarmsCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -104,10 +95,7 @@ public class AlarmsCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -129,10 +117,7 @@ public class AlarmsCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -153,10 +138,7 @@ public class AlarmsCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -165,4 +147,4 @@ public class AlarmsCommandTests
fakeService.DisconnectCalled.ShouldBeTrue();
fakeService.DisposeCalled.ShouldBeTrue();
}
}
}

View File

@@ -2,7 +2,6 @@ using Shouldly;
using Xunit;
using ZB.MOM.WW.LmxOpcUa.Client.CLI.Commands;
using ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests.Fakes;
using ZB.MOM.WW.LmxOpcUa.Client.Shared.Models;
using BrowseResult = ZB.MOM.WW.LmxOpcUa.Client.Shared.Models.BrowseResult;
namespace ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests;
@@ -16,9 +15,9 @@ public class BrowseCommandTests
{
BrowseResults = new List<BrowseResult>
{
new BrowseResult("ns=2;s=Obj1", "Object1", "Object", true),
new BrowseResult("ns=2;s=Var1", "Variable1", "Variable", false),
new BrowseResult("ns=2;s=Meth1", "Method1", "Method", false)
new("ns=2;s=Obj1", "Object1", "Object", true),
new("ns=2;s=Var1", "Variable1", "Variable", false),
new("ns=2;s=Meth1", "Method1", "Method", false)
}
};
var factory = new FakeOpcUaClientServiceFactory(fakeService);
@@ -85,7 +84,7 @@ public class BrowseCommandTests
{
BrowseResults = new List<BrowseResult>
{
new BrowseResult("ns=2;s=Child", "Child", "Object", true)
new("ns=2;s=Child", "Child", "Object", true)
}
};
var factory = new FakeOpcUaClientServiceFactory(fakeService);
@@ -143,4 +142,4 @@ public class BrowseCommandTests
fakeService.DisconnectCalled.ShouldBeTrue();
fakeService.DisposeCalled.ShouldBeTrue();
}
}
}

View File

@@ -1,4 +1,3 @@
using CliFx.Infrastructure;
using Shouldly;
using Xunit;
using ZB.MOM.WW.LmxOpcUa.Client.CLI.Commands;
@@ -87,4 +86,4 @@ public class CommandBaseTests
fakeService.LastConnectionSettings!.FailoverUrls.ShouldBeNull();
}
}
}

View File

@@ -72,7 +72,6 @@ public class ConnectCommandTests
using var console = TestConsoleHelper.CreateConsole();
// The command should propagate the exception but still clean up.
// Since connect fails, service is null in finally, so no disconnect.
await Should.ThrowAsync<InvalidOperationException>(
async () => await command.ExecuteAsync(console));
await Should.ThrowAsync<InvalidOperationException>(async () => await command.ExecuteAsync(console));
}
}
}

View File

@@ -6,8 +6,8 @@ using BrowseResult = ZB.MOM.WW.LmxOpcUa.Client.Shared.Models.BrowseResult;
namespace ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests.Fakes;
/// <summary>
/// Fake implementation of <see cref="IOpcUaClientService"/> for unit testing commands.
/// Records all method calls and returns configurable results.
/// Fake implementation of <see cref="IOpcUaClientService" /> for unit testing commands.
/// Records all method calls and returns configurable results.
/// </summary>
public sealed class FakeOpcUaClientService : IOpcUaClientService
{
@@ -16,20 +16,24 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
public ConnectionSettings? LastConnectionSettings { get; private set; }
public bool DisconnectCalled { get; private set; }
public bool DisposeCalled { get; private set; }
public List<NodeId> ReadNodeIds { get; } = new();
public List<(NodeId NodeId, object Value)> WriteValues { get; } = new();
public List<NodeId?> BrowseNodeIds { get; } = new();
public List<(NodeId NodeId, int IntervalMs)> SubscribeCalls { get; } = new();
public List<NodeId> UnsubscribeCalls { get; } = new();
public List<(NodeId? SourceNodeId, int IntervalMs)> SubscribeAlarmsCalls { get; } = new();
public List<NodeId> ReadNodeIds { get; } = [];
public List<(NodeId NodeId, object Value)> WriteValues { get; } = [];
public List<NodeId?> BrowseNodeIds { get; } = [];
public List<(NodeId NodeId, int IntervalMs)> SubscribeCalls { get; } = [];
public List<NodeId> UnsubscribeCalls { get; } = [];
public List<(NodeId? SourceNodeId, int IntervalMs)> SubscribeAlarmsCalls { get; } = [];
public bool UnsubscribeAlarmsCalled { get; private set; }
public bool RequestConditionRefreshCalled { get; private set; }
public List<(NodeId NodeId, DateTime Start, DateTime End, int MaxValues)> HistoryReadRawCalls { get; } = new();
public List<(NodeId NodeId, DateTime Start, DateTime End, AggregateType Aggregate, double IntervalMs)> HistoryReadAggregateCalls { get; } = new();
public List<(NodeId NodeId, DateTime Start, DateTime End, int MaxValues)> HistoryReadRawCalls { get; } = [];
public List<(NodeId NodeId, DateTime Start, DateTime End, AggregateType Aggregate, double IntervalMs)>
HistoryReadAggregateCalls { get; } =
[];
public bool GetRedundancyInfoCalled { get; private set; }
// Configurable results
public ConnectionInfo ConnectionInfoResult { get; set; } = new ConnectionInfo(
public ConnectionInfo ConnectionInfoResult { get; set; } = new(
"opc.tcp://localhost:4840",
"TestServer",
"None",
@@ -37,7 +41,7 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
"session-1",
"TestSession");
public DataValue ReadValueResult { get; set; } = new DataValue(
public DataValue ReadValueResult { get; set; } = new(
new Variant(42),
StatusCodes.Good,
DateTime.UtcNow,
@@ -47,18 +51,18 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
public IReadOnlyList<BrowseResult> BrowseResults { get; set; } = new List<BrowseResult>
{
new BrowseResult("ns=2;s=Node1", "Node1", "Object", true),
new BrowseResult("ns=2;s=Node2", "Node2", "Variable", false)
new("ns=2;s=Node1", "Node1", "Object", true),
new("ns=2;s=Node2", "Node2", "Variable", false)
};
public IReadOnlyList<DataValue> HistoryReadResult { get; set; } = new List<DataValue>
{
new DataValue(new Variant(10.0), StatusCodes.Good, DateTime.UtcNow.AddHours(-1), DateTime.UtcNow),
new DataValue(new Variant(20.0), StatusCodes.Good, DateTime.UtcNow, DateTime.UtcNow)
new(new Variant(10.0), StatusCodes.Good, DateTime.UtcNow.AddHours(-1), DateTime.UtcNow),
new(new Variant(20.0), StatusCodes.Good, DateTime.UtcNow, DateTime.UtcNow)
};
public RedundancyInfo RedundancyInfoResult { get; set; } = new RedundancyInfo(
"Warm", 200, new[] { "urn:server1", "urn:server2" }, "urn:app:test");
public RedundancyInfo RedundancyInfoResult { get; set; } = new(
"Warm", 200, ["urn:server1", "urn:server2"], "urn:app:test");
public Exception? ConnectException { get; set; }
public Exception? ReadException { get; set; }
@@ -159,6 +163,11 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
return Task.FromResult(RedundancyInfoResult);
}
public void Dispose()
{
DisposeCalled = true;
}
/// <summary>Raises the DataChanged event for testing subscribe commands.</summary>
public void RaiseDataChanged(string nodeId, DataValue value)
{
@@ -176,9 +185,4 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
{
ConnectionStateChanged?.Invoke(this, new ConnectionStateChangedEventArgs(oldState, newState, endpointUrl));
}
public void Dispose()
{
DisposeCalled = true;
}
}
}

View File

@@ -3,7 +3,7 @@ using ZB.MOM.WW.LmxOpcUa.Client.Shared;
namespace ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests.Fakes;
/// <summary>
/// Fake factory that returns a pre-configured <see cref="FakeOpcUaClientService"/> for testing.
/// Fake factory that returns a pre-configured <see cref="FakeOpcUaClientService" /> for testing.
/// </summary>
public sealed class FakeOpcUaClientServiceFactory : IOpcUaClientServiceFactory
{
@@ -14,5 +14,8 @@ public sealed class FakeOpcUaClientServiceFactory : IOpcUaClientServiceFactory
_service = service;
}
public IOpcUaClientService Create() => _service;
}
public IOpcUaClientService Create()
{
return _service;
}
}

View File

@@ -18,8 +18,8 @@ public class HistoryReadCommandTests
{
HistoryReadResult = new List<DataValue>
{
new DataValue(new Variant(10.5), StatusCodes.Good, time1, time1),
new DataValue(new Variant(20.3), StatusCodes.Good, time2, time2)
new(new Variant(10.5), StatusCodes.Good, time1, time1),
new(new Variant(20.3), StatusCodes.Good, time2, time2)
}
};
var factory = new FakeOpcUaClientServiceFactory(fakeService);
@@ -117,8 +117,7 @@ public class HistoryReadCommandTests
};
using var console = TestConsoleHelper.CreateConsole();
await Should.ThrowAsync<ArgumentException>(
async () => await command.ExecuteAsync(console));
await Should.ThrowAsync<ArgumentException>(async () => await command.ExecuteAsync(console));
}
[Fact]
@@ -138,4 +137,4 @@ public class HistoryReadCommandTests
fakeService.DisconnectCalled.ShouldBeTrue();
fakeService.DisposeCalled.ShouldBeTrue();
}
}
}

View File

@@ -84,4 +84,4 @@ public class NodeIdParserTests
result.ShouldNotBeNull();
result.Identifier.ShouldBe("TestNode");
}
}
}

View File

@@ -1 +1,2 @@
// This file intentionally left empty. Real tests are in separate files.

View File

@@ -90,10 +90,9 @@ public class ReadCommandTests
};
using var console = TestConsoleHelper.CreateConsole();
await Should.ThrowAsync<InvalidOperationException>(
async () => await command.ExecuteAsync(console));
await Should.ThrowAsync<InvalidOperationException>(async () => await command.ExecuteAsync(console));
fakeService.DisconnectCalled.ShouldBeTrue();
fakeService.DisposeCalled.ShouldBeTrue();
}
}
}

View File

@@ -14,7 +14,7 @@ public class RedundancyCommandTests
var fakeService = new FakeOpcUaClientService
{
RedundancyInfoResult = new RedundancyInfo(
"Hot", 250, new[] { "urn:server:primary", "urn:server:secondary" }, "urn:app:myserver")
"Hot", 250, ["urn:server:primary", "urn:server:secondary"], "urn:app:myserver")
};
var factory = new FakeOpcUaClientServiceFactory(fakeService);
var command = new RedundancyCommand(factory)
@@ -40,7 +40,7 @@ public class RedundancyCommandTests
var fakeService = new FakeOpcUaClientService
{
RedundancyInfoResult = new RedundancyInfo(
"None", 100, Array.Empty<string>(), "urn:app:standalone")
"None", 100, [], "urn:app:standalone")
};
var factory = new FakeOpcUaClientServiceFactory(fakeService);
var command = new RedundancyCommand(factory)
@@ -90,4 +90,4 @@ public class RedundancyCommandTests
fakeService.DisconnectCalled.ShouldBeTrue();
fakeService.DisposeCalled.ShouldBeTrue();
}
}
}

View File

@@ -1,4 +1,3 @@
using Opc.Ua;
using Shouldly;
using Xunit;
using ZB.MOM.WW.LmxOpcUa.Client.CLI.Commands;
@@ -24,10 +23,7 @@ public class SubscribeCommandTests
// The subscribe command waits for cancellation. We need to cancel it.
// Use the console's cancellation to trigger stop.
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
// Give it a moment to subscribe, then cancel
await Task.Delay(100);
@@ -52,10 +48,7 @@ public class SubscribeCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -77,10 +70,7 @@ public class SubscribeCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -104,10 +94,7 @@ public class SubscribeCommandTests
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () =>
{
await command.ExecuteAsync(console);
});
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
await Task.Delay(100);
console.RequestCancellation();
@@ -117,4 +104,4 @@ public class SubscribeCommandTests
output.ShouldContain("Subscribed to ns=2;s=TestVar (interval: 2000ms)");
output.ShouldContain("Unsubscribed.");
}
}
}

View File

@@ -3,12 +3,12 @@ using CliFx.Infrastructure;
namespace ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests;
/// <summary>
/// Helper for creating CliFx <see cref="FakeInMemoryConsole"/> instances and reading their output.
/// Helper for creating CliFx <see cref="FakeInMemoryConsole" /> instances and reading their output.
/// </summary>
public static class TestConsoleHelper
{
/// <summary>
/// Creates a new <see cref="FakeInMemoryConsole"/> for testing.
/// Creates a new <see cref="FakeInMemoryConsole" /> for testing.
/// </summary>
public static FakeInMemoryConsole CreateConsole()
{
@@ -16,7 +16,7 @@ public static class TestConsoleHelper
}
/// <summary>
/// Reads all text written to the console's standard output.
/// Reads all text written to the console's standard output.
/// </summary>
public static string GetOutput(FakeInMemoryConsole console)
{
@@ -25,11 +25,11 @@ public static class TestConsoleHelper
}
/// <summary>
/// Reads all text written to the console's standard error.
/// Reads all text written to the console's standard error.
/// </summary>
public static string GetError(FakeInMemoryConsole console)
{
console.Error.Flush();
return console.ReadErrorString();
}
}
}

View File

@@ -100,4 +100,4 @@ public class WriteCommandTests
fakeService.DisconnectCalled.ShouldBeTrue();
fakeService.DisposeCalled.ShouldBeTrue();
}
}
}

View File

@@ -1,27 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<RootNamespace>ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<RootNamespace>ZB.MOM.WW.LmxOpcUa.Client.CLI.Tests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit.v3" Version="1.1.0" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="CliFx" Version="2.3.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="xunit.v3" Version="1.1.0"/>
<PackageReference Include="Shouldly" Version="4.3.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
<PackageReference Include="CliFx" Version="2.3.6"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\ZB.MOM.WW.LmxOpcUa.Client.CLI\ZB.MOM.WW.LmxOpcUa.Client.CLI.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\ZB.MOM.WW.LmxOpcUa.Client.CLI\ZB.MOM.WW.LmxOpcUa.Client.CLI.csproj"/>
</ItemGroup>
</Project>