fix: preserve SDK 2.0 client value and lifetime contracts

This commit is contained in:
Joseph Doherty
2026-11-10 10:19:42 -05:00
parent 0ecea3c6be
commit 3ca06e1b87
38 changed files with 591 additions and 186 deletions
@@ -48,11 +48,15 @@ internal sealed class FakeSessionAdapter : ISessionAdapter
public bool ThrowOnBrowse { get; set; }
/// <summary>Gets or sets the browse references returned by browse operations.</summary>
public ReferenceDescriptionCollection BrowseResponse { get; set; } = [];
public ArrayOf<ReferenceDescription> BrowseResponse { get; set; } = [];
/// <summary>Gets or sets the continuation point for browse operations.</summary>
public byte[]? BrowseContinuationPoint { get; set; }
public Func<CancellationToken, Task>? BeforeBrowseNext { get; set; }
public List<(byte[] Point, bool Cancelled)> BrowseReleases { get; } = [];
public bool ThrowOnBrowseRelease { get; set; }
/// <summary>Gets or sets the browse references returned by browse-next operations.</summary>
public ReferenceDescriptionCollection BrowseNextResponse { get; set; } = [];
public ArrayOf<ReferenceDescription> BrowseNextResponse { get; set; } = [];
/// <summary>Gets or sets the continuation point for browse-next operations.</summary>
public byte[]? BrowseNextContinuationPoint { get; set; }
@@ -129,7 +133,7 @@ internal sealed class FakeSessionAdapter : ISessionAdapter
}
/// <inheritdoc />
public Task<(byte[]? ContinuationPoint, ReferenceDescriptionCollection References)> BrowseAsync(
public Task<(byte[]? ContinuationPoint, ArrayOf<ReferenceDescription> References)> BrowseAsync(
NodeId nodeId, uint nodeClassMask, CancellationToken ct)
{
BrowseCount++;
@@ -139,11 +143,19 @@ internal sealed class FakeSessionAdapter : ISessionAdapter
}
/// <inheritdoc />
public Task<(byte[]? ContinuationPoint, ReferenceDescriptionCollection References)> BrowseNextAsync(
public async Task<(byte[]? ContinuationPoint, ArrayOf<ReferenceDescription> References)> BrowseNextAsync(
byte[] continuationPoint, CancellationToken ct)
{
BrowseNextCount++;
return Task.FromResult((BrowseNextContinuationPoint, BrowseNextResponse));
if (BeforeBrowseNext != null) await BeforeBrowseNext(ct);
return (BrowseNextContinuationPoint, BrowseNextResponse);
}
public Task ReleaseBrowseContinuationPointAsync(byte[] continuationPoint, CancellationToken ct)
{
BrowseReleases.Add((continuationPoint, ct.IsCancellationRequested));
if (ThrowOnBrowseRelease) throw new ServiceResultException(StatusCodes.BadSessionClosed);
return Task.CompletedTask;
}
/// <inheritdoc />