Skip to content

Fix missing FactoryBuilder.Commit() in dictionary-based complex type loading paths#3630

Merged
marcschier merged 2 commits into
masterfrom
copilot/fix-broken-encodeablefactory-implementation
Mar 19, 2026
Merged

Fix missing FactoryBuilder.Commit() in dictionary-based complex type loading paths#3630
marcschier merged 2 commits into
masterfrom
copilot/fix-broken-encodeablefactory-implementation

Conversation

Copilot AI commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

FactoryBuilder.Commit() was never called when LoadDictionaryDataTypesAsync was the active loading path in LoadAsync and LoadNamespaceAsync. Both methods returned the dictionary load result directly, bypassing the commit. Any complex types registered during dictionary loading were silently dropped from the immutable EncodeableFactory, breaking all reads of those types.

Affected methods in ComplexTypeSystem.cs:

  • LoadAsync — triggered when DisableDataTypeDefinition is set or LoadBaseDataTypesAsync returns false
  • LoadNamespaceAsync — same condition

Fix: Replace the early return with a local allTypesLoaded variable, always call Commit(), then return the stored result — matching the pattern already used correctly in LoadTypeAsync:

// Before (broken): Commit() skipped
return await LoadDictionaryDataTypesAsync(serverEnumTypes, true, ct).ConfigureAwait(false);

// After (fixed): Commit() always called
bool allTypesLoaded;
if (DisableDataTypeDefinition || !await LoadBaseDataTypesAsync(...))
{
    allTypesLoaded = await LoadDictionaryDataTypesAsync(serverEnumTypes, true, ct).ConfigureAwait(false);
}
else
{
    allTypesLoaded = true;
}
m_complexTypeResolver.FactoryBuilder.Commit();
return allTypesLoaded;

Related Issues

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

The regression was introduced in #3241 which added the immutable EncodeableFactory builder pattern. The LoadTypeAsync method had the correct structure (commit outside the conditional), but LoadAsync and LoadNamespaceAsync were not updated consistently.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://api.nuget.org:443/DigiCertTrustedG4TimeStampingRSA4096SHA2562025CA1.crl
    • Triggering command: /usr/bin/dotnet dotnet restore UA.slnx (http block)
  • http://api.nuget.org:443/DigiCertTrustedRootG4.crl
    • Triggering command: /usr/bin/dotnet dotnet restore UA.slnx (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Broken immutable EncodeableFactory implementation</issue_title>
<issue_description>Hello,
pinging @marcschier directly as the author of #3241

I updated the NuGet versions referenced by my project to 1.5.378.106 from 1.5.376.244 and noticed that all reads relying on complex types stopped working.

The culprit seems to be that the m_complexTypeResolver.FactoryBuilder.Commit() call on line 353 is skipped if the code reaches line 349, which returns early.

return await LoadDictionaryDataTypesAsync(serverEnumTypes, true, ct)

After LoadDictionaryDataTypesAsync, m_complexTypeResolver.FactoryBuilder.KnownTypeIds does indeed contain the types I would expect, but they never make it into the Factory instance.

I believe the code should store the return value of LoadDictionaryDataTypesAsync, commit to the FactoryBuilder anyway and then return the result, but I don't have the full picture.

Thank you</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix broken immutable EncodeableFactory implementation Fix missing FactoryBuilder.Commit() in dictionary-based complex type loading paths Mar 19, 2026
Copilot AI requested a review from marcschier March 19, 2026 17:32
@marcschier
marcschier marked this pull request as ready for review March 19, 2026 17:35
@marcschier
marcschier merged commit 4c78751 into master Mar 19, 2026
137 of 141 checks passed
@marcschier
marcschier deleted the copilot/fix-broken-encodeablefactory-implementation branch March 19, 2026 20:10
mrsuciu pushed a commit to mrsuciu/UA-.NETStandard that referenced this pull request Mar 20, 2026
…loading paths (OPCFoundation#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]>
(cherry picked from commit 4c78751)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken immutable EncodeableFactory implementation

4 participants