fix(driver-ablegacy): fix CS9124 build error and update stale status-mapper test
EffectiveCipPath now references ParsedAddress/Profile properties instead of the captured primary-constructor parameters to avoid CS9124 (param captured into enclosing type AND used to init a member). NonZero_libplctag_status_maps_via_AbLegacyStatusMapper updated to pass (int)Status.ErrorNotFound rather than the stale magic integer -14 that the old mapper happened to handle but the new enum-based mapper does not. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -567,9 +567,9 @@ public sealed class AbLegacyDriver : IDriver, IReadable, IWritable, ITagDiscover
|
|||||||
/// that a SLC 500 misconfigured without an explicit path still gets the required
|
/// that a SLC 500 misconfigured without an explicit path still gets the required
|
||||||
/// <c>1,0</c> backplane route. MicroLogix has an empty default by design (direct EIP).
|
/// <c>1,0</c> backplane route. MicroLogix has an empty default by design (direct EIP).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string EffectiveCipPath => parsedAddress.CipPath.Length > 0
|
public string EffectiveCipPath => ParsedAddress.CipPath.Length > 0
|
||||||
? parsedAddress.CipPath
|
? ParsedAddress.CipPath
|
||||||
: profile.DefaultCipPath;
|
: Profile.DefaultCipPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Per-tag cached runtimes. <see cref="System.Collections.Concurrent.ConcurrentDictionary{TKey,TValue}"/>
|
/// Per-tag cached runtimes. <see cref="System.Collections.Concurrent.ConcurrentDictionary{TKey,TValue}"/>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using libplctag;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||||
@@ -65,10 +66,12 @@ public sealed class AbLegacyReadWriteTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task NonZero_libplctag_status_maps_via_AbLegacyStatusMapper()
|
public async Task NonZero_libplctag_status_maps_via_AbLegacyStatusMapper()
|
||||||
{
|
{
|
||||||
|
// Use the real libplctag.Status enum value rather than a raw integer so the test
|
||||||
|
// stays correct if the wrapper renumbers its ordinals (Driver.AbLegacy-010).
|
||||||
var (drv, factory) = NewDriver(
|
var (drv, factory) = NewDriver(
|
||||||
new AbLegacyTagDefinition("X", "ab://10.0.0.5/1,0", "N7:0", AbLegacyDataType.Int));
|
new AbLegacyTagDefinition("X", "ab://10.0.0.5/1,0", "N7:0", AbLegacyDataType.Int));
|
||||||
await drv.InitializeAsync("{}", CancellationToken.None);
|
await drv.InitializeAsync("{}", CancellationToken.None);
|
||||||
factory.Customise = p => new FakeAbLegacyTag(p) { Status = -14 };
|
factory.Customise = p => new FakeAbLegacyTag(p) { Status = (int)Status.ErrorNotFound };
|
||||||
|
|
||||||
var snapshots = await drv.ReadAsync(["X"], CancellationToken.None);
|
var snapshots = await drv.ReadAsync(["X"], CancellationToken.None);
|
||||||
snapshots.Single().StatusCode.ShouldBe(AbLegacyStatusMapper.BadNodeIdUnknown);
|
snapshots.Single().StatusCode.ShouldBe(AbLegacyStatusMapper.BadNodeIdUnknown);
|
||||||
|
|||||||
Reference in New Issue
Block a user