This pull request modernizes the OPC UA .NET codebase and tests, removes .NET Standard 2.0 support from certificate/security code, and updates test code to use C# 12 and .NET 8+ features for clarity and maintainability.
- Certificate and BouncyCastle interop files (e.g., CertificateBuilder.cs, X509Extensions.cs, X509SignatureFactory.cs) are refactored to drop NETSTANDARD2_0 support and use modern .NET APIs and conditional compilation.
- Test code across the codebase is updated to use default, strongly-typed Parse methods, collection expressions, and improved async/await patterns.
- Exception handling and assertions in tests are modernized, and test method naming is made consistent with Async suffixes.
- The project and build files are updated to clarify Roslynator analyzer usage and remove obsolete netstandard tags.
- General code and test cleanup includes improved null safety, type safety, and removal of deprecated or unused code.
- Replaced `IList<INode>` with `List<INode>` in
`ComplexTypeSystem.cs` and `BaseComplexType.cs` for
better type safety.
- Updated string comparison in `ReverseConnectManager.cs`
to `StringComparison.Ordinal` for improved performance.
- Added a method to `ISession.cs`, `Session.cs`, and
`SessionAsync.cs` to trigger reloading instance certificates.
- Minor fixes in error handling in `Subscription.cs` and using pattern matching for type checks in several locations to improve code readability.
- Made minor adjustments to comments and documentation
for clarity and improved code quality.
- Updated `Variant` handling in preparation for immutable struct.
- Changed return types in `BaseObjectState.cs` and `BaseVariableTypeState.cs` to use `ObjectTypeIds` for iperf
- Cleaned up `ExpandedNodeId`
- Enhanced memory management error handling and readabilityand error handling in encoders
* 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>
* Add missing constants for JSON encoding.
* Update generated files to 1.05.04.
* Update NuGets
* Fix compile errors due to abstract types.
* Update nodesets.
* Update JSON Encoder/Decoder.
* Update with JSON encoder.
* Change prefix char.
* Change prefix to uppercase.
* Fix JsonEncoder
* Fix null pointer.
* Update encoders to suppress artifacts.
* JSON encoding fixes.
* Fix JSON RawEncoding
* Update JSON encoders.
* Revert changes for Matrix in Variant.
* Update NodeSet.
* Resolve name conflict with new Opc.Ua types.
* Fix failing Tests
* Fix unit tests after change to Verbose/Compact encoding.
* Add final 1.05.04 generated classes and unit test fixes.
* Fix more unit tests.
* Update NodeSet to released version.
* Remove unintended changes to UANodeSet.xsd
* Update Schema/UANodeSet.xsd
* Merge breaking changes to JsonEncoder.cs from develop/main374
* Allow JObject in ExtensionObjects.
* fix version json
* Update generated files to UA-1.05.04-2025-01-08
* Some cleanup of the new APIs and Union implementation. (#2927)
* Some cleanup of the new APIs and Union implementation.
* fix build
* Handle status code Uncertain according to the specification (#2898)
* #2896: Write output arguments for good and uncertain status code
When a method state's call method is invoked the output arguments should be written in case the status code is good or uncertain. This behavior would be conform with the current specification.
* #2896: The service result corresponds the method call result
The result of the Call method in the CustomNodeManager2 class represents the status of the CallMethodResult. It does not correspond to the ServiceResult of the CallResponse, thus returning Good as a general response is incorrect behavior.
* Add SetHiResClockDisabled & fix Rejected Store Creation in ApplicationConfigurationBuilder (#2909)
Add the method SetHiResClockDisabled to IApplicationConfigurationBuilder
Fix the type of RejectedStore Created by the Builder to: CertificateStoreIdentifier
* revert based on feedback
* move some logic from class code to encoder/decoder
* Fix race condition on Nuget build (#2930)
- nodeset xmlzip is created in obj folders if multiple targets are built in parallel
* update common comments
* Update NodeSet files.
* Fix ReadSwitchField Implementation.
* Make UserIdentity.DisplayName writeable.
* Fix merge failures.
* Fix XmlElement encoding and bad NamespaceIndex fallback logic.
* Fix 2D array raw encoding.
* Add support for DesignToolOnly.
---------
Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
Co-authored-by: Martin Regen <mregen@microsoft.com>
Co-authored-by: Martin Regen <7962757+mregen@users.noreply.github.com>
- bug: if the nested complex type is derived from an abstract type like a Union, the decoder uses the abstract type instead of the actual type to decode
- fix: the loop to determine the supertype of the type to be decoded stops too early and returns an invalid type reference, e.g. for Unions. Instead the loop will now continue until a valid BuiltInType or a Structure or Enumeration type is found.
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.
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
Expose an 'ISession' interface as abstraction to ease unit testing.
Breaking changes are kept to minimal impact, but some changes maybe required to use ISession objects instead of Session.
Note: ISessionClientMethods is hand created, not yet by ModelCompiler
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.
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)
- support for Microsoft.Extensions.Logger.ILogger in Opc.Ua.Core as the new logging interface
- backward compatible with config and TraceEvents
- new API Utils.SetLogger allows to set ILogger
- updated Console samples to demonstrate ILogger support with Serilog
- support for EventSource logging
- see Docs/Logging.md for more info
- fix the complex types of the test nodeset (requires https://github.com/OPCFoundation/UA-ModelCompiler/pull/96)
- improve some client / server tests
- add tests for complex types datatype definition integrity on ref server, validate bsd and xml dictionaries in the test server (open issue: https://mantis.opcfoundation.org/view.php?id=7393, xml validation always failing)
- improve server fixture, to allow for custom config changes
- fix an issue that caused kestrel not start on windows/.NET Core 3.1 and above, when a new certificate was issued, thereby ignoring all https client tests.
-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
fixes#1476
Improve IOP, some recent ModelCompiler versions (starting with errata 1.04.9) produce invalid output and all IsOptional fields have become true by default, causing the complex types client to bail out for Structures created with this ModelCompiler release. However, the IsOptional field can be ignored.
ModelCompiler is fixed in 1.04.10 and greater
- 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
- improve cross platform support, replace CRLF by AppendLine
- replace $format trace messages with {} style
- fix warnings for comments and protected fields, null parameter checks
- replace cert factory calls with new API (obsolete warnings)
- allow to run cert validator tests in parallel using new temp cert validator class
- more test cases for cert validator, e.g wth cert validation callback
- improve cert validator for special cases
- 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)