Skip to content

docs: document three approaches for decoding ComplexTypes from OPC UA servers - #3664

Merged
marcschier merged 3 commits into
masterfrom
copilot/read-complex-types-from-server
Apr 15, 2026
Merged

marcschier merged 3 commits into
masterfrom
copilot/read-complex-types-from-server

Conversation

Copilot AI commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Users were unclear on how to decode ExtensionObject values into their own custom .NET types when reading complex types from an OPC UA server. The missing piece: custom IEncodeable implementations must be registered with the session's EncodeableFactory before reading — the ComplexTypeSystem alone is not sufficient.

Changes to Docs/ComplexTypes.md

  • New section: "Approaches for Working with Custom Types" — documents all three supported strategies side-by-side:

    • Approach 1 — Hand-written IEncodeable + EncodeableFactory registration: complete example including the critical registration step, assembly-level bulk registration, multi-type chaining, and a callout that BinaryEncodingId must exactly match the server's Binary Encoding NodeId
    • Approach 2 — Source-generated IEncodeable (new in 1.6): brief example + cross-reference to SourceGeneratedDataTypes.md
    • Approach 3 — Runtime IStructure via ComplexTypeSystem: already documented; now surfaced as an explicit choice with links to the existing sections
  • Updated troubleshooting ("Values Still Encoded as ExtensionObject"): covers the registration requirement for all three approaches, not just ComplexTypeSystem.LoadAsync()

  • "See Also" link to SourceGeneratedDataTypes.md added

Key usage pattern (Approach 1)

// Register before any reads — BinaryEncodingId on the type must match the server
session.Factory.Builder
    .AddEncodeableType(typeof(UDT_SemVer))
    .Commit();

DataValue result = await session.ReadValueAsync("ns=3;s=...");
if (result.WrappedValue.TryGet(out ExtensionObject ext) &&
    ext.Body is UDT_SemVer semVer)
{
    Console.WriteLine($"Major={semVer.Major} Minor={semVer.Minor} Patch={semVer.Patch}");
}

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

No code changes — documentation only. The three-approach structure maps directly to the options described in the issue thread and makes the EncodeableFactory registration requirement explicit, which was the root cause of the confusion.

Copilot AI linked an issue Apr 14, 2026 that may be closed by this pull request
2 of 5 tasks
@CLAassistant

CLAassistant commented Apr 14, 2026 •

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 all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ marcschier
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

…in ComplexTypes.md

Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/40780404-d86e-40c1-b099-e2400be745a4

Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix decoding issue for ExtensionObject into UDT docs: document three approaches for decoding ComplexTypes from OPC UA servers Apr 14, 2026
Copilot AI requested a review from marcschier April 14, 2026 09:18
@marcschier
marcschier marked this pull request as ready for review April 14, 2026 09:25
@codecov

codecov Bot commented Apr 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.24%. Comparing base (64ca85f) to head (2d94ab9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3664      +/-   ##
==========================================
+ Coverage   73.13%   73.24%   +0.11%     
==========================================
  Files         516      516              
  Lines      110789   110789              
  Branches    18172    18172              
==========================================
+ Hits        81023    81149     +126     
+ Misses      24515    24392     -123     
+ Partials     5251     5248       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Reading ComplexTypes from Server

5 participants