Skip to content

Commit

Permalink
Fix .NET 8 breaking change (#320)
Browse files Browse the repository at this point in the history
* Cosmetic

* Update version

* Update nuget

* Fix nuget breaking changes

* Fix async issues

* Remove prefix for constants

* Cosmetic

* Fix build regression
  • Loading branch information
luiscantero authored Nov 27, 2023
1 parent b2867f3 commit 170c862
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ dotnet_naming_symbols.constants_with_k.applicable_accessibilities =
dotnet_naming_symbols.constants_with_k.required_modifiers = const

dotnet_naming_style.constants_with_k_style.capitalization = pascal_case
dotnet_naming_style.constants_with_k_style.required_prefix = k

# Constants are PascalCase
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
Expand Down Expand Up @@ -314,6 +313,6 @@ dotnet_diagnostic.CA1852.severity =
# CA1860: Avoid using 'Enumerable.Any()' extension method
dotnet_diagnostic.CA1860.severity = suggestion

# CA1861: Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array
# CA1861: Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array
dotnet_diagnostic.CA1861.severity = suggestion

4 changes: 2 additions & 2 deletions src/OpcApplicationConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public async Task<ApplicationConfiguration> ConfigureAsync()
var transportQuotas = new TransportQuotas
{
MaxStringLength = OpcMaxStringLength,
MaxMessageSize = 4 * 1024 * 1024, // 4MB.
MaxByteStringLength = 4 * 1024 * 1024, // 4MB.
MaxMessageSize = 4 * 1024 * 1024, // 4 MB.
MaxByteStringLength = 4 * 1024 * 1024, // 4 MB.
};

var operationLimits = new OperationLimits()
Expand Down
7 changes: 4 additions & 3 deletions tests/DataMonitoringTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace OpcPlc.Tests;

namespace OpcPlc.Tests;

using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
Expand All @@ -13,7 +14,7 @@ namespace OpcPlc.Tests;
public class DataMonitoringTests : SubscriptionTestsBase
{
// Set any cmd params needed for the plc server explicitly.
public DataMonitoringTests() : base(new string[] { })
public DataMonitoringTests() : base(Array.Empty<string>())
{
}

Expand Down
2 changes: 1 addition & 1 deletion tests/DeterministicAlarmsTests2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void VerifyThatTimeForEventsChanges()

NodeShouldHaveStates(doorOpen1, Inactive, Disabled);

Assert.AreNotEqual(timeForFirstEvent, timeForNextEvent);
timeForFirstEvent.Should().NotBe(timeForNextEvent);
}

private void AdvanceToNextStep()
Expand Down
12 changes: 6 additions & 6 deletions tests/PlcSimulatorFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public PlcSimulatorFixture(string[] args)
/// Configure and run the simulator in a background thread, run once for the entire assembly.
/// The simulator is instrumented with mock time services.
/// </summary>
public async Task Start()
public async Task StartAsync()
{
Reset();

Expand Down Expand Up @@ -137,7 +137,7 @@ public async Task Start()
.GetAwaiter().GetResult());

string endpointUrl = WaitForServerUp();
await _log.WriteAsync($"Found server at: {endpointUrl}");
await _log.WriteAsync($"Found server at: {endpointUrl}").ConfigureAwait(false);

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Expand All @@ -146,14 +146,14 @@ public async Task Start()
// Use the Loopback IP address as a workaround.
// In contrast, on Windows Azure DevOps builds, this results in issues.
endpointUrl = $"opc.tcp://{IPAddress.Loopback}:{Port}";
await _log.WriteAsync($"Connecting to server URL: {endpointUrl}");
await _log.WriteAsync($"Connecting to server URL: {endpointUrl}").ConfigureAwait(false);
}

_config = await GetConfigurationAsync();
_config = await GetConfigurationAsync().ConfigureAwait(false);
_serverEndpoint = GetServerEndpoint(endpointUrl);
}

public Task Stop()
public Task StopAsync()
{
// shutdown simulator
_serverCancellationTokenSource.Cancel();
Expand Down Expand Up @@ -223,7 +223,7 @@ private static void Reset()

private async Task<ApplicationConfiguration> GetConfigurationAsync()
{
await _log.WriteLineAsync("Create Application Configuration");
await _log.WriteLineAsync("Create Application Configuration").ConfigureAwait(false);

var application = new ApplicationInstance
{
Expand Down
8 changes: 4 additions & 4 deletions tests/SimulatorNodesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void Telemetry_FastNode()
}
else
{
Assert.AreEqual(lastValue + 1, value);
value.Should().Be(lastValue + 1);
lastValue = value;
}

Expand All @@ -85,17 +85,17 @@ public void Telemetry_FastNode()
CallMethod("StopUpdateFastNodes");

var nextValue = ReadValue<uint>(nodeId);
Assert.AreEqual(lastValue, nextValue);
nextValue.Should().Be(lastValue);
FireTimersWithPeriod(FromSeconds(1), numberOfTimes: 1);
nextValue = ReadValue<uint>(nodeId);
Assert.AreEqual(lastValue, nextValue);
nextValue.Should().Be(lastValue);
FireTimersWithPeriod(FromSeconds(1), numberOfTimes: 1);

CallMethod("StartUpdateFastNodes");
FireTimersWithPeriod(FromSeconds(1), numberOfTimes: 1);

nextValue = ReadValue<uint>(nodeId);
Assert.AreEqual(lastValue + 1, nextValue);
nextValue.Should().Be(lastValue + 1);
}

[TestCase("DipData", -1000)]
Expand Down
6 changes: 3 additions & 3 deletions tests/SimulatorTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ protected SimulatorTestsBase(string[] args = default)
[OneTimeSetUp]
public async Task Setup()
{
await _simulator.Start();
Session = await _simulator.CreateSessionAsync(GetType().Name);
await _simulator.StartAsync().ConfigureAwait(false);
Session = await _simulator.CreateSessionAsync(GetType().Name).ConfigureAwait(false);
}

/// <summary>Closes the OPC-UA session and stops the simulator.</summary>
[OneTimeTearDown]
public async Task TearDown()
{
Session.Close();
await _simulator.Stop();
await _simulator.StopAsync().ConfigureAwait(false);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion tests/opc-plc-tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit" Version="4.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/acr-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ if (![string]::IsNullOrEmpty($metadata.tag)) {
$fullImageName = "$($Registry).azurecr.io/$($namespace)$($imageName):$($tagPrefix)$($sourceTag)$($tagPostfix)"
Write-Host "Full image name: $($fullImageName)"

$manifest = @"
$manifest = @"
image: $($fullImageName)
tags: [$($tagPrefix)$($latestTag)$($tagPostfix)]
manifests:
Expand Down
1 change: 1 addition & 0 deletions tools/scripts/docker-source.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if ($projFile) {
$argumentList += "-r"
$argumentList += $runtimeId
$argumentList += "/p:TargetLatestRuntimePatch=true"
$argumentList += "--self-contained"
}
else {
$runtimeId = "portable"
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.9.14",
"version": "2.9.15",
"versionHeightOffset": -1,
"publicReleaseRefSpec": [
"^refs/heads/main$",
Expand Down

0 comments on commit 170c862

Please sign in to comment.