Skip to content

Commit 1c17840

Browse files
authored
Refactor client state persistence and add more tests (#3303)
* State handling and better serialization * Nullable for almost everything inclient library * Additional testing of session
1 parent 8f5a042 commit 1c17840

File tree

82 files changed

+10942
-9936
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+10942
-9936
lines changed

Applications/ConsoleReferenceClient/ClientSamples.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public async Task BrowseAsync(ISession session, CancellationToken ct = default)
258258
try
259259
{
260260
// Create a Browser object
261-
var browser = new Browser(session, m_telemetry)
261+
var browser = new Browser(session)
262262
{
263263
// Set browse parameters
264264
BrowseDirection = BrowseDirection.Forward,
@@ -1192,7 +1192,7 @@ private static Task FetchReferenceIdTypesAsync(
11921192
/// <summary>
11931193
/// Output all values as JSON.
11941194
/// </summary>
1195-
public async Task<(DataValueCollection, IList<ServiceResult>)> ReadAllValuesAsync(
1195+
public async Task<ResultSet<DataValue>> ReadAllValuesAsync(
11961196
IUAClient uaClient,
11971197
NodeIdCollection variableIds,
11981198
CancellationToken ct = default)
@@ -1278,7 +1278,7 @@ private static Task FetchReferenceIdTypesAsync(
12781278
}
12791279
} while (retrySingleRead);
12801280

1281-
return (values, errors);
1281+
return ResultSet.From(values, errors);
12821282
}
12831283

12841284
/// <summary>

Applications/ConsoleReferenceClient/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,10 @@ r is VariableNode v &&
570570

571571
if (jsonvalues && variableIds != null)
572572
{
573-
(DataValueCollection allValues, IList<ServiceResult> results)
574-
= await samples
573+
(
574+
IReadOnlyList<DataValue> allValues,
575+
IReadOnlyList<ServiceResult> results
576+
) = await samples
575577
.ReadAllValuesAsync(uaClient, variableIds, ct)
576578
.ConfigureAwait(false);
577579
}

Applications/ConsoleReferenceClient/UAClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public async Task<bool> ConnectAsync(
245245
endpointConfiguration);
246246

247247
// Create the session factory. - we could take it as parameter or as member
248-
var sessionFactory = new TraceableSessionFactory(m_telemetry);
248+
var sessionFactory = new DefaultSessionFactory(m_telemetry);
249249

250250
// Create the session
251251
ISession session = await sessionFactory

Libraries/Opc.Ua.Client.ComplexTypes/TypeResolver/NodeCacheResolver.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public class NodeCacheResolver : IComplexTypeResolver
5252
/// Initializes the type resolver with a session to load the custom type information.
5353
/// </summary>
5454
public NodeCacheResolver(ISession session, ITelemetryContext telemetry)
55-
: this(new LruNodeCache(session, telemetry), telemetry)
55+
: this(session, new LruNodeCache(
56+
new NodeCacheContext(session),
57+
telemetry), telemetry)
5658
{
5759
}
5860

@@ -64,7 +66,10 @@ public NodeCacheResolver(
6466
ISession session,
6567
TimeSpan cacheExpiry,
6668
ITelemetryContext telemetry)
67-
: this(new LruNodeCache(session, telemetry, cacheExpiry), telemetry)
69+
: this(session, new LruNodeCache(
70+
new NodeCacheContext(session),
71+
telemetry,
72+
cacheExpiry), telemetry)
6873
{
6974
}
7075

@@ -76,17 +81,24 @@ public NodeCacheResolver(
7681
TimeSpan cacheExpiry,
7782
int capacity,
7883
ITelemetryContext telemetry)
79-
: this(new LruNodeCache(session, telemetry, cacheExpiry, capacity), telemetry)
84+
: this(session, new LruNodeCache(
85+
new NodeCacheContext(session),
86+
telemetry,
87+
cacheExpiry,
88+
capacity), telemetry)
8089
{
8190
}
8291

8392
/// <summary>
8493
/// Initializes the type resolver with a session and lru cache to load the
8594
/// custom type information with the specified expiry and cache size.
8695
/// </summary>
87-
public NodeCacheResolver(ILruNodeCache lruNodeCache, ITelemetryContext telemetry)
96+
public NodeCacheResolver(
97+
ISession session,
98+
ILruNodeCache lruNodeCache,
99+
ITelemetryContext telemetry)
88100
{
89-
m_session = lruNodeCache.Session;
101+
m_session = session;
90102
m_lruNodeCache = lruNodeCache;
91103
m_logger = telemetry.CreateLogger<NodeCacheResolver>();
92104
FactoryBuilder = m_session.Factory.Builder;

0 commit comments

Comments
 (0)