Skip to content

Commit 4c78751

Browse files
Copilotmarcschier
andauthored
Fix missing FactoryBuilder.Commit() in dictionary-based complex type loading paths (#3630)
* Fix missing Commit() after LoadDictionaryDataTypesAsync in ComplexTypeSystem Co-authored-by: marcschier <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: marcschier <[email protected]>
1 parent 5a1e547 commit 4c78751

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

Libraries/Opc.Ua.Client.ComplexTypes/ComplexTypeSystem.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ public async Task<bool> LoadNamespaceAsync(
264264
serverStructTypes = [.. serverStructTypes.Where(
265265
rd => rd.NodeId.NamespaceIndex == nameSpaceIndex)];
266266
// load types
267+
bool allTypesLoaded;
267268
if (DisableDataTypeDefinition ||
268269
!await LoadBaseDataTypesAsync(serverEnumTypes, serverStructTypes, ct)
269270
.ConfigureAwait(false))
@@ -272,12 +273,16 @@ public async Task<bool> LoadNamespaceAsync(
272273
{
273274
return false;
274275
}
275-
return await LoadDictionaryDataTypesAsync(serverEnumTypes, false, ct)
276+
allTypesLoaded = await LoadDictionaryDataTypesAsync(serverEnumTypes, false, ct)
276277
.ConfigureAwait(false);
277278
}
279+
else
280+
{
281+
allTypesLoaded = true;
282+
}
278283
// Commit the changes to the factory
279284
m_complexTypeResolver.FactoryBuilder.Commit();
280-
return true;
285+
return allTypesLoaded;
281286
}
282287
catch (Exception ex)
283288
{
@@ -338,6 +343,7 @@ public async ValueTask<bool> LoadAsync(
338343
: (await m_complexTypeResolver
339344
.LoadDataTypesAsync(DataTypeIds.Structure, true, ct: ct)
340345
.ConfigureAwait(false)).ToList();
346+
bool allTypesLoaded;
341347
if (DisableDataTypeDefinition ||
342348
!await LoadBaseDataTypesAsync(serverEnumTypes, serverStructTypes, ct)
343349
.ConfigureAwait(false))
@@ -346,12 +352,16 @@ public async ValueTask<bool> LoadAsync(
346352
{
347353
return false;
348354
}
349-
return await LoadDictionaryDataTypesAsync(serverEnumTypes, true, ct)
355+
allTypesLoaded = await LoadDictionaryDataTypesAsync(serverEnumTypes, true, ct)
350356
.ConfigureAwait(false);
351357
}
358+
else
359+
{
360+
allTypesLoaded = true;
361+
}
352362
// Commit the changes to the factory
353363
m_complexTypeResolver.FactoryBuilder.Commit();
354-
return true;
364+
return allTypesLoaded;
355365
}
356366
catch (Exception ex)
357367
{

0 commit comments

Comments
 (0)