28 Commits

Author SHA1 Message Date
Marc Schier 3e5f129c6f Enable nullable in Stack, Libraries (9), and Applications projects (#3732) 2026-05-17 12:55:24 +02:00
Copilot 54cc3d88b1 Prepare for C# 15 union types: UnionAttribute polyfill, TryGetValue rename, HasValue (#3727) 2026-05-02 18:33:46 +02:00
Marc Schier 70abb05841 Remove Default JSON encoding infrastructure (#3713)
* Remove Default JSON encoding infrastructure

Remove IJsonEncodeable interface, JsonEncodingId properties, DefaultJson
constants, and all source generator JSON encoding output. The actual
JsonEncoder/JsonDecoder and PubSub JSON encoding are not affected.

- Delete IJsonEncodeable interface from IEncodable.cs
- Remove DataTypeAttribute.JsonEncodingId and simplify TryGetTypeIdsFromType
- Remove JSON encoding from 9 source generator files
- Remove IJsonEncodeable from 13 built-in types and 12 node types
- Remove JSON registration from EncodeableFactory and unboundTypeIds infra
- Remove jsonEncodingId from OptionSet, ComplexTypeSystem, IComplexTypeFactory
- Remove BrowseNames.DefaultJson and 25 *_Encoding_DefaultJson constants
- Update ~14 test files and 2 documentation files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add IJsonEncodeable removal to migration guide

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* minor

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-29 17:39:43 +02:00
Marc Schier 34ed5716c0 Add structure-backed OptionSet DataType support in ComplexTypeSystem (#3672)
Concrete sub-types of the abstract OptionSet DataType (i=12755, e.g. AccessRights, CarExtras, OptionSetBase) were silently skipped by ComplexTypeSystem.LoadBaseStructureDataTypesAsync when only an EnumDefinition or OptionSetValues property was available. This change registers them with a new runtime class Opc.Ua.Encoders.OptionSet that reuses the generated Opc.Ua.OptionSet wire format (Value/ValidBits ByteStrings) and self-registers via IEncodeableType.

Key changes:

- New Stack/Opc.Ua/Types/OptionSet.cs with EnumDefinition-driven bit accessors (by name and index), GetSetFieldNames helper, and a fixed ByteLength derived from the highest declared bit per OPC UA Part 3 paragraph 8.40 / 3.2.8. SetBit throws ArgumentOutOfRangeException outside that range and always materializes Value/ValidBits to the fixed length.

- New AddOptionSetType entry point on IComplexTypeBuilder (source-breaking addition for custom implementations); DefaultComplexTypeBuilder implements it. The Reflection.Emit ComplexTypeBuilder throws NotSupportedException.

- ComplexTypeSystem detects OptionSet descendants via a HasSubtype walk and resolves the EnumDefinition from DataTypeDefinition or the OptionSetValues property fallback before the old skip path.

- Removed stale V1.04 OptionSet limitation remark from ComplexTypeSystem.

- 10 unit tests in Tests/Opc.Ua.Client.Tests/ComplexTypes/DefaultOptionSetTests.cs covering factory registration, bit accessors, binary round-trip via ExtensionObject, hand-crafted Part 6 wire format, Clone/CreateInstance semantics, and the ByteLength invariant.

- Live-verified against opc.tcp://DESKTOP-BGFJS91:48010 (UA C++ SDK demo): AccessRights/CarExtras/OptionSetBase now appear in the registered custom-type list; no skip-log entries; LoadAsync(throwOnError:true) returns true.

- Docs/ComplexTypes.md Known Limitations reworded; Docs/MigrationGuide.md gains an OptionSet DataType support subsection.

UInteger-backed OptionSet DataTypes remain intentionally opaque (carried as their unsigned integer in a Variant).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-17 21:16:55 +02:00
Marc Schier fd41681f4b Add support to publish OPC UA applications as Native AOT (#3633)
* make most ptojects aot compatible
* Remove newtonsoft
* Migrate all projects from Mono.Options to System.CommandLine 2.0.5
* Fix array clone
* Replace serializers for storage using new attribute driven  type geberator
* Add new AOT integration tests covering all functional areas
* Documentation updates
2026-04-13 20:52:29 +02:00
Marc Schier 03777ecb09 New Json decoder/encoders, array/matrix abstractions, ByteString, and more. (#3619)
- **Collections overhaul** — new/rewritten collection types (`ArrayOf`, `Collections` commits)
- **`Variant` builder/accessor** — new APIs for constructing and accessing Variants
- **`NodeId` operators made explicit** — breaking change for implicit conversions
- **Version bumped to 1.6** with preview build support
- **NumericRange** uses Variant
- **object** type accessors and general usage removed.

### 🏗️ Infrastructure
- Build config updated; `.NET 10` targeting
- InternalsVisibleTo moved to `.csproj`
- Pipeline/CI adjustments
2026-03-18 12:23:30 +01:00
Marc Schier f66ceffd75 Immutable built in types and code generation (#3534)
Generate stack and application code using source generators
Change built in types to readonly structs
  Update localized text implementation to use JSON text serializer
  Status code with symbolic names
  Immutable node ids
  No boxing for all built in types <= 8 bytes in Variant.
Split user identity token and token handling via token handler
Add migration guide for breaking changes
2026-02-12 16:27:07 +01:00
Marc Schier 2960388560 Update headers and license files (#3388)
Update license headers to copy right year 2025, replace RCL/GPL headers with MIT, replace the nuget license with MIT (via license expression).
2025-12-04 19:44:40 +01:00
Marc Schier 9830e5d53e Enable roslynizer and fix all analyzer issues (#3157)
* Fix warnings and suggestions
* Enable roslynator
2025-08-16 04:10:24 -07:00
Marc Schier 96efa0a88a Add a LRU node cache for complex type system (#3137) 2025-08-06 12:54:44 +02:00
Marc Schier eeb58c2fa6 Enhance enum definition handling and validation (#3124)
* Enhance enum definition handling and validation

Added a `string enumTypeName` parameter to the `ToEnumDefinition` methods in `ComplexTypeSystem.cs` and `DataTypeDefinitionExtension.cs` to improve enum field name generation, especially when original names are null or empty. Implemented a fallback mechanism to ensure robust naming.

In `ComplexTypeBuilder.cs`, added null checks for `typeName` to prevent runtime errors and ensure valid type definitions. Updated logic for defining enum literals to handle empty field names, ensuring unique names are generated based on `typeName` and enum value.

* Update Libraries/Opc.Ua.Client.ComplexTypes/TypeBuilder/ComplexTypeBuilder.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Libraries/Opc.Ua.Client.ComplexTypes/DataTypeDefinitionExtension.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix issue from code review

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-24 21:16:06 +02:00
mtx500 cf7f2219a1 Fixed Typos. No functional changes. (#2581)
* Fixed typos across the board. No functional changes.
2024-04-11 08:21:16 +02:00
Martin Regen 2b9d8f9de5 Fix warnings, no functional changes. Improve globalization. (#2445)
Fix warnings regarding localization, CLS compliance, performance. No functional changes.

Many but not all adressed:
CA1859
CA1868
CA1305
CA1310
CA1861

- based on the discussion, use IFormatProvider where appropriate in ToString
2024-02-14 17:17:21 +01:00
JSGInray e2b3f6f359 Complex types builder should emit BuiltInType.Variant for DataTypes.Decimal (#2426) 2023-12-14 16:44:09 +01:00
Martin Regen a109c81d22 fix .NET 8 build and warning (#2395)
Fix some warnings and build errors with .NET 8. To build as .NET 8, add net8.0 to target.props.
2023-11-27 18:35:47 +01:00
Martin Regen d65e1cfc27 Fixes to support structures with allowsubtypes (#2104)
Fixes an issue found with a server with an address model that implements structures with abstract complex types and with structures which allow subtypes. The client could hang endless when building the complex type system in this case.
The StructureFieldAttribute has the wrong AttributeTypeIds set.
2023-03-27 23:09:24 +02:00
Marc Schier 65f9757b91 Add an API to ComplexTypeSystem to retrieve data type definitions used during loading (#2039)
The changes add an API to ComplexTypeSystem to retrieve data type definitions that were created during type building to leverage them to build DataSetMetaDataType for OPC UA PubSub.  

The changes include the following:

* Combine all conversion of enumerations into EnumDefinition and use the resulting to build the type
* Remove all other API from the type builder interface and implementation. 
  > The assumption is that these interfaces are used internally and removal will not cause a breaking change.
* Combine everything previously covered elsewhere into existing AddEnumType function.
* Add a NodeIdDictionary cache and fill that cache during load, as well as API to retrieve the data type definitions
2023-01-09 16:08:06 +01:00
Martin Regen cf7e7ba651 Fix for handling complex type client special cases (#2009)
* A complex type which has a property with datatype Number, UInteger or Integer causes an exception on encoding/decoding because the BuiltInType which is used in the BaseComplexType is BuiltInType.Null instead of BuiltInType.Variant.
* BaseComplexType may not handle enumerations as property correctly on encoding/decoding and may cause an exception.
2022-12-05 19:14:58 +01:00
Martin Regen 1fec89b073 Complex types improvements (#1915)
Improvements for complex types.

- Support to encode/decode complex type structures with multidimensional arrays.
- Perf improvements for type loader using new NodeCache fetch multiple interfaces.
- DataTypeDictionary validation when dependencies are used.
- interface for complex type resolver, to build custom types in code.
- improvements of console client to demonstrate browse/read of custom values

+++ Breaking changes +++

IDecoder interface change of the `ReadArray` method

- Return type is now `Array` for all types of arrays. Previously the method returned an array for 1-dim and a `Matrix` type for multidimensional arrays. In addition the convention in generated code is to use `Collection` for all 1-dim arrays, and so was built the `BaseComplexType`. The new convention is to expose the native `Array` type from a complex type, in all cases, hence the return type of `ReadArray` was changed to reflect that for a consistent programming model.
- `ReadArray` has a new parameter `systemType` to efficiently read encodeable types. Previously the `Type` of an encodeable was determined by the encodingid and lookup in the type factory, even when the Type is already known by the caller.  The 'old' style is still supported.
- `ReadArray` supports to read encodeable type arrays which are directly encoded in structures. These arrays differ from standard encoding of arrays and they are handled when `BuiltInType.Null` is used as parameter.
2022-10-04 19:45:26 +02:00
Tim Jöhnk 5732286a11 Feature/recursive complex types (#1870)
* fixes recursive complex types 
* fix IComplexTypebuilder interface
2022-07-18 11:50:36 +02:00
Hermo Terblanche b41fb36020 Added support for recursive complex data type (#1656)
The Opc.Ua.Client.ComplexTypes package does not support recursive structs, i.e. a struct with a field that has the same data type as the struct.
An example of a recursive struct data type may look as follows:

PersonStructDataType
-  Name <String>
-  Age <Int32>
-  Children <PersonStructDataType[ ]>  (ValueRank == 1)
2022-01-11 14:20:12 +01:00
Martin Regen 53ec78f1bc IOP workshop 2021 fixes and build improvements (#1562)
-fixes for complex types:
  - a structure which contains an enum from namespace 0 can not be created. fixes #1561.
  - a structure with multidimensional array may lead to a endless loop in `ComplexTypeSystem.Load`
  - a malformed namespace Uri which contains a space character prevents creation of type system.
  - select endpoint doesn't pick the right scheme if the default endpoint must be picked
-prep for net472 or greater and net5.0 or greater build, only build #ifdef
2021-10-29 16:21:43 +02:00
Martin Regen 9923141e70 Enable .NET analyzers for all projects (#1414)
* Enable .NET analyzers for all projects
* fix all new warnings, mostly security and perf
2021-06-05 07:58:38 +02:00
Martin Regen 631e729787 Fix warnings, improve complex type exception handler (#1384)
- catch exception in complex type system not only for ServiceResultException
- add fast path for single type loader if type already exists
- fix many warnings, no function change
- fix template for legacy nuget packages to include cert lib
2021-04-28 18:34:43 +02:00
Sebastian Baeumler e8df315193 ComplexTypes Improvements (#1383)
- Fixed typo in StructureDefinitionAttribute
- Adapt using of fixed StructureDefinitionAttribute
- Resolve method internal name conflict
- Enable TypeInfo.GetSystemType to support ExpandedNodeId
- Redirect request with absolute NodeIds an directly use the EncodableFactory.GetSystemType method
2021-04-28 15:08:14 +02:00
Martin Regen 7f3f0dbbb4 Service update, fix many warnings for Xml comments (#1146)
- no bug fixes, just documentation and formatting
- fix all warnings for xml in core libraries, except
-- protected members
-- suppressed warnings in Opc.Ua.Gds libraries (tbd)
2020-10-14 12:00:01 +02:00
AlinMoldovean 764c481405 Update Copyright year to 2020 2020-10-07 18:04:34 +03:00
Alin Moldovean 195521719e Move SDK folder to "Libraries" (#1013)
* Move Client library

* Move Server library

* Move Configuration library

* Move Complex Types library

* Update paths in project references
2020-06-09 18:46:08 +03:00