Skip to content

Adopt generated client stubs (source generation) across samples #769

Description

@romanett

Sub-issue of #755.

Why

Part of #755 is moving client samples onto generated client stubs — i.e. the C# source generator that implements IEncodeable (Encode/Decode/IsEqual/Clone) and type activators for custom OPC UA data types, instead of hand-written or ModelCompiler-emitted stub classes. The OPCFoundation.NetStandard.Opc.Ua.SourceGeneration analyzer package is already referenced by some projects in this repo.

Scope

Client-side custom data type / model stub code across the samples, e.g.:

  • Workshop/DataTypes (custom data types)
  • Workshop/Boiler, Workshop/SimpleEvents, Workshop/AlarmCondition model/type classes
  • Any other sample with hand-written or generated IEncodeable stub classes consumed by clients (audit repo-wide)

Tasks

  1. Add the OPCFoundation.NetStandard.Opc.Ua.SourceGeneration package as an analyzer (OutputItemType="Analyzer" ReferenceOutputAssembly="false") to the affected projects.
  2. Convert custom data types to partial classes/enums annotated with [DataType(Namespace = "...")]; remove hand-written Encode/Decode/IsEqual/Clone and manual activator registration — let the generator emit them.
  3. Verify complex-type reads/writes still round-trip on the client (works with Opc.Ua.Client.ComplexTypes).
  4. Confirm the generated TypeId/BinaryEncodingId/XmlEncodingId match the sample server nodesets.

Note: please confirm with maintainers whether "generated client stubs" in #755 also covers a specific typed service/method-stub generator beyond source-generated data types; adjust scope if so.

References

Acceptance criteria

  • Affected sample projects build with the source generator; no hand-written IEncodeable boilerplate remains for the converted types.
  • Clients still encode/decode and display custom data types correctly against the sample servers.

Dependencies

Can proceed in parallel with the session/subscription sub-issues; coordinate merge order to avoid churn in the same client files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions