Expand DI / Fluent API: injectability + one-shot ergonomics (client, server, PubSub, discovery/bindings) - #3957
Merged
marcschier merged 12 commits intoJul 8, 2026
Conversation
…ient, server, PubSub and discovery/bindings Completes the dependency-injection / fluent-API review follow-up so every feature is reachable and configurable from the services.AddOpcUa() chain, while keeping all existing granular registrations and direct-construct fallbacks (backward compatible; the one rename keeps an [Obsolete] alias). Client: chainable IOpcUaClientBuilder overloads (AddComplexTypes/AddAlarms/ AddWebApiTransportChannel); ManagedSessionOptions.LoadComplexTypes + AddManagedClient(); injectable multi-endpoint IManagedSessionFactory; DI factories AddHistorian/ AddRoleManagement/AddFileTransfer/AddAliasNames; options fail-fast validation + AddDiscovery(). Server: IOpcUaServerFactory / AddServer<TServer>() seam -> injectable durable subscriptions, session/subscription managers; AddHistorian, AddFileSystem (Part 20), AddSecretStore/AddCertificateManager/AddAliasNameStore; secure-by-default anonymous authenticator (marker-guarded). PubSub: AddUdpPubSub()/AddMqttPubSub() one-shots; IPubSubBuilder anchor unification (SKS/schema/pcap); ConfigureConfiguration(); IMqttTransportBuilder parity; order-independent pcap decoration. Discovery/Bindings: fail-loud non-TCP endpoints; GDS AddInMemoryStores()/fast-fail; order-independent AddHttpsTransport() one-shot; AddAuthorizationService ([Obsolete] alias for WithAuthorizationService), root-level AddPcap(), WotCon prerequisite guard. Docs updated (DependencyInjection.md, PubSub.md, Transports.md, WebApi.md). Validated: 12 libraries + 9 test projects build clean on net10.0 and net48; full net10 sweep ~7,700 tests pass; net48 new-feature suites pass.
7 tasks
Address the bugs and gaps found re-reviewing the DI / Fluent API surface, completing Phases 0-3 of the follow-up plan across all areas. Phase 0 - defects: - Server B1: AddServer<TServer> no longer silently drops constructor-time hooks. Custom servers that do not derive from DependencyInjectionStandardServer now throw a clear InvalidOperationException when session/subscription manager, subscription store or queue-factory hooks are configured; DependencyInjection- StandardServer is public/derivable and post-start hooks apply generically. - Server B5a: ConfigureRoles is now real (RoleConfigurationOptions bound and applied); adds AddRoleManager and an AddNodeManager(Action<INodeManagerBuilder>) bridge, AddReverseConnect/ConfigureOperationLimits and transport forwarders. - PubSub B2/B3: PubSubBuilder.Build() bridges the DI security resolver and encoders; SKS server interfaces are registered so the remote SKS pull client works instead of being an options-only no-op. - WotCon B4: connectivity registration performs a runtime guard check. - Client B5b: LazyConnect is honored; reverse-connect connect path, GDS client depth, DiTransferClient factory and managed-session pool wired through DI. Additional review fixes: - Role-manager divergence: add a StandardServer.CreateRoleManager virtual seam resolved from DI (with base fallback); removes the post-start swap. - Role registration parity: the default configured IRoleManager is registered in the AddServer(IConfiguration) Roles block rather than unconditionally in RegisterCommonServices, so config-bound roles still apply while the GDS and plain-server ConfigureRoles registration deltas stay symmetric. - GDS AddCertificateManagement token-provider registration fix. - ManagedSessionPool.Dispose() leak fix and faulted-task eviction. Phases 1-3 - ergonomics and coverage: - One-shots and overload pairs across areas: AddReferenceServer/AddSecureServer/ AddHistorianFileStore, AddInMemoryGdsServer, AddEthPubSub/AddSecureUdpPubSub/ AddPubSubServer/AddServerAdapterPubSub, AddWotConClient/AddGdsClient client overloads, AddManagedClient(IConfiguration), Pcap/WSS transport overloads. - LDS/GDS stores, mDNS and transports made injectable; transport forwarders. - Docs: ClientDiFluentApi.md, ServerDiFluentApi.md, DependencyInjection.md and PubSub.md updates. Tests: add AddServerConfigurationWithRolesSectionSeedsConfiguredRoleManager and extensive builder/registration tests across client, server, PubSub, GDS, LDS and WotCon. Verified on net10.0 and net48.
marcschier
commented
Jul 6, 2026
Two CI failures introduced by the DI/Fluent API expansion: - aot-ubuntu-latest / aot-windows-latest (IL2091): annotate the generic TFactory parameter of PubSubTransportFactoryRegistration<TFactory> and the TryAddPubSubTransportFactory<TFactory> method with [DynamicallyAccessedMembers(PublicConstructors)] so ActivatorUtilities. CreateInstance<TFactory> is trim/AOT-safe. Verified with a local NativeAOT publish of Opc.Ua.Aot.Tests. - build-and-push-image (Docker Reference Server CI): the new HTTPS/WSS/Kestrel/ WebApi server-builder forwarders made Opc.Ua.Server and Opc.Ua.Gds.Server.Common reference Opc.Ua.Bindings.Https unconditionally, which pulls the ASP.NET Core shared framework into the runtime-only ConsoleReferenceServer image built with -p:NoHttps=true. Gate the Bindings.Https ProjectReference and the HTTPS-dependent forwarders (AddHttpsTransport/AddWssTransport/AddKestrelOpcTcpTransport/ AddWebApiTransport) behind NoHttps so the raw AddOpcTcpTransport forwarder and the rest of the API remain, while the NoHttps build excludes the HTTPS binding. Verified with normal and NoHttps builds plus a full NoHttps ConsoleReferenceServer publish (no Bindings.Https in output).
- Remove the [Obsolete] WithAuthorizationService aliases (and the doc note): AddAuthorizationService is new in 2.0 and unreleased, so no obsolete compatibility aliases are needed. - Consolidate the DI/fluent docs: merge ServerDiFluentApi.md and ClientDiFluentApi.md into DependencyInjection.md as "Fluent shortcuts" subsections under Server feature and Client feature, delete the standalone files, and drop the README link. - Fix CA1416 in the Core.Diagnostics tests: add an explicit return after the Assert.Ignore Windows guard (and add the missing guard in EncryptedKeyLogTests) so File.GetUnixFileMode / UnixFileMode are not flagged as reachable on Windows.
…t-api-completeness # Conflicts: # Libraries/Opc.Ua.Server/Hosting/OpcUaServerHostedService.cs
Add focused NUnit coverage tests for the highest-gap DI/fluent builder extension files so the PR's changed-line coverage clears the codecov patch gate. Tests are pure DI-registration style (build a ServiceCollection, call the AddOpcUa().Add*(...) extensions, BuildServiceProvider, assert resolves / registration-count deltas / options binding / null-arg guards / fluent return-same-builder) mirroring each area's existing *BuilderTests. No hosted servers, no network, deterministic. No production code changed. New test files: - Server: OpcUaServerBuilderExtensionsCoverageTests, FluentNodeManagerFactoryCoverageTests - Client: OpcUaClientBuilderExtensionsCoverageTests, OpcUaSubClientBuilderExtensionsCoverageTests - WotCon: OpcUaWotConServerBuilderCoverageTests - Lds: OpcUaLdsServerBuilderCoverageTests - Gds: OpcUaGdsClientBuilderCoverageTests, OpcUaGdsServerBuilderCoverageTests - PubSub: PubSubSecurityServiceCollectionExtensionsCoverageTests - PubSub.Udp: UdpTransportServiceCollectionExtensionsCoverageTests Verified on net10.0 (Release): all new coverage tests pass and full per-project suites show no regressions.
…lueTask.FromResult
marcschier
marked this pull request as ready for review
July 7, 2026 06:56
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Expands the DI + fluent API surface so client/server/PubSub/discovery features are consistently reachable from services.AddOpcUa() (including new one-shot registrations), while preserving granular registrations and backward compatibility.
Changes:
- Adds new DI seams/builders and one-shot registrations across Client/Server/PubSub/Discovery (e.g., managed client, PubSub transports, HTTPS/WebApi, GDS/LDS).
- Improves transport binding behavior (order-independence, DI registry usage, and fail-fast errors for missing bindings).
- Adds/updates extensive tests and documentation for new DI/fluent patterns.
Reviewed changes
Copilot reviewed 136 out of 136 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/Opc.Ua.WotCon.Tests/Opc.Ua.WotCon.Tests.csproj | Adds HTTPS bindings reference for WoTCon tests. |
| Tests/Opc.Ua.Server.Tests/Hosting/TransportBindingHostingTests.cs | New test ensuring hosted server uses DI transport registry. |
| Tests/Opc.Ua.Server.Tests/Hosting/IdentityHostingTests.cs | Adds hosted identity/default authenticator behavior coverage. |
| Tests/Opc.Ua.PubSub.Udp.Tests/UdpTransportServiceCollectionExtensionsTests.cs | Adds UDP one-shot + DTLS binding + secured PubSub tests. |
| Tests/Opc.Ua.PubSub.Tests/Security/Sks/PullSecurityKeyProviderTests.cs | Adds disposal-ownership behavior tests for pull provider. |
| Tests/Opc.Ua.PubSub.Tests/DependencyInjection/OpcUaPubSubBuilderExtensionsTests.cs | Adds tests for DI key providers and config-authoring bridge. |
| Tests/Opc.Ua.PubSub.Server.Tests/OpcUaServerBuilderPubSubExtensionsTests.cs | Adds coverage for PubSub server one-shot registration ordering. |
| Tests/Opc.Ua.PubSub.Schema.Tests/PubSubSchemaProviderTests.cs | Adds DI registration coverage for schema provider extension. |
| Tests/Opc.Ua.PubSub.Mqtt.Tests/MqttTransportServiceCollectionExtensionsTests.cs | Adds MQTT builder/one-shot tests and options binding. |
| Tests/Opc.Ua.PubSub.Eth.Tests/EthTransportServiceCollectionExtensionsTests.cs | Adds Ethernet one-shot PubSub registration coverage. |
| Tests/Opc.Ua.PubSub.Diagnostics.Tests/Opc.Ua.PubSub.Diagnostics.Tests.csproj | Suppresses legacy TFM empty-shell warnings for diagnostics tests. |
| Tests/Opc.Ua.PubSub.Diagnostics.Tests/Formats/FormatterPcapAndDependencyInjectionTests.cs | Adds order-independent pcap decoration tests. |
| Tests/Opc.Ua.PubSub.Adapter.Tests/OpcUaPubSubAdapterBuilderExtensionsTests.cs | Adds one-shot server adapter PubSub coverage. |
| Tests/Opc.Ua.Gds.Tests/Hosting/OpcUaGdsServerBuilderTests.cs | Adds in-memory store preset + transport + auth service tests. |
| Tests/Opc.Ua.Gds.Tests/Hosting/OpcUaGdsClientBuilderTests.cs | New fixture for GDS client builder chaining and factories. |
| Tests/Opc.Ua.Di.Tests/OpcUaClientDiBuilderExtensionsTests.cs | Adds DI transfer client factory coverage + idempotency check. |
| Tests/Opc.Ua.Core.Diagnostics.Tests/KeyLog/FilePermissionsTests.cs | Fixes unreachable code warnings after Assert.Ignore on Windows. |
| Tests/Opc.Ua.Core.Diagnostics.Tests/KeyLog/EncryptedKeyLogTests.cs | Adds explicit Windows ignore guard for file mode test. |
| Tests/Opc.Ua.Core.Diagnostics.Tests/DependencyInjection/PcapServiceCollectionExtensionsTests.cs | Adds builder overload coverage + Windows ignore return. |
| Tests/Opc.Ua.Core.Diagnostics.Tests/Audit/HashChainedAuditFileSinkTests.cs | Fixes unreachable code warnings after Assert.Ignore on Windows. |
| Tests/Opc.Ua.Client.Tests/Subscription/SetTriggeringFluentHelperTests.cs | Adjusts captured-name assertion helper (lambda capture). |
| Tests/Opc.Ua.Client.Tests/Session/ManagedSessionComplianceTests.cs | Updates compliance reflection for ReverseConnectManager parameter. |
| Tests/Opc.Ua.Client.Tests/ClientBuilder/OpcUaSubClientBuilderExtensionsCoverageTests.cs | New coverage for sub-client builder null guards + registrations. |
| Tests/Opc.Ua.Client.Tests/ClientBuilder/OpcUaClientBuilderExtensionsTests2.cs | Updates null-guard tests for builder overload signature. |
| Tests/Opc.Ua.Client.Tests/Alarms/AddAlarmsBuilderTests.cs | Updates null-guard tests for builder overload signature. |
| Tests/Opc.Ua.Client.ComplexTypes.Tests/Hosting/ManagedClientBuilderTests.cs | New tests for one-shot managed client + fluent chaining. |
| Tests/Opc.Ua.Client.ComplexTypes.Tests/Hosting/AddComplexTypesBuilderTests.cs | Updates null-guard tests for builder overload signature. |
| Tests/Opc.Ua.Bindings.Https.WebApi.Tests/PipeByteTransportTests.cs | Removes unused constant in WebApi pipe transport tests. |
| Tests/Opc.Ua.Bindings.Https.WebApi.Tests/DependencyInjection/OpcUaWebApiClientBuilderExtensionsTests.cs | Updates null-guard tests for builder overload signature. |
| Tests/Opc.Ua.Bindings.Https.WebApi.Tests/DependencyInjection/OpcUaWebApiBuilderExtensionsTests.cs | Adds order-independence tests for HTTPS/WebApi contributor attachment. |
| Tests/Opc.Ua.Bindings.Https.WebApi.Tests/DependencyInjection/OpcUaKestrelTcpBuilderExtensionsTests.cs | Adds coverage for transport override ordering and fallback. |
| Tests/Opc.Ua.Bindings.Https.WebApi.Tests/DependencyInjection/OpcUaHttpsBuilderExtensionsTests.cs | Adds WSS options overload chaining test. |
| Stack/Opc.Ua.Core/Stack/Server/ServerBase.cs | Updates docs to reflect hosted-service DI transport registry wiring. |
| Stack/Opc.Ua.Core/Stack/Bindings/OpcUaTransportBuilderExtensions.cs | Makes raw-socket TCP listener registration idempotent with overrides. |
| Stack/Opc.Ua.Core.Diagnostics/DependencyInjection/PcapServiceCollectionExtensions.cs | Adds IOpcUaBuilder overloads for pcap registrations. |
| Stack/Opc.Ua.Bindings.Https/DependencyInjection/OpcUaWebApiBuilderExtensions.cs | Makes HTTPS/WebApi contributor attachment order-independent. |
| Libraries/Opc.Ua.WotCon.Server/Opc.Ua.WotCon.Server.csproj | Adds HTTPS bindings project reference for WoTCon server. |
| Libraries/Opc.Ua.WotCon.Client/Hosting/OpcUaWotConClientBuilderExtensions.cs | Adds client-builder overloads + LazyConnect enforcement for accessor. |
| Libraries/Opc.Ua.Server/Server/StandardServer.cs | Adds role manager initialization seam before RoleSet binding. |
| Libraries/Opc.Ua.Server/RoleBasedUserManagement/RoleConfigurationOptions.cs | Introduces bindable role configuration options model. |
| Libraries/Opc.Ua.Server/Opc.Ua.Server.csproj | Adds optional NOHTTPS build flag + conditional HTTPS reference. |
| Libraries/Opc.Ua.Server/Hosting/OpcUaServerTransportBuilderExtensions.cs | Adds server-builder forwarding overloads for transports. |
| Libraries/Opc.Ua.Server/Hosting/OpcUaServerRoleManagerRegistration.cs | Adds marker for role manager registrations. |
| Libraries/Opc.Ua.Server/Hosting/OpcUaServerManagerRegistrations.cs | Adds DI registrars for session/subscription managers + stores. |
| Libraries/Opc.Ua.Server/Hosting/OpcUaServerIdentityAuthenticatorRegistration.cs | Adds fallback marker for anonymous authenticator registration. |
| Libraries/Opc.Ua.Server/Hosting/IOpcUaServerFactory.cs | New factory interface for injectable server instantiation. |
| Libraries/Opc.Ua.Server/Hosting/IOpcUaServerBuilder.cs | Adds fluent node manager builder overload and doc fix. |
| Libraries/Opc.Ua.Server/Hosting/FluentNodeManagerFactory.cs | Adds DI-friendly fluent node manager factory implementation. |
| Libraries/Opc.Ua.Server/Hosting/DependencyInjectionStandardServer.cs | Adds DI-aware StandardServer subclass applying DI hooks. |
| Libraries/Opc.Ua.Server/Hosting/DefaultOpcUaServerFactory.cs | Default server factory producing DI-aware server. |
| Libraries/Opc.Ua.Server/Hosting/ActivatorOpcUaServerFactory.cs | Adds validation for DI hooks when custom server type used. |
| Libraries/Opc.Ua.PubSub/Security/Sks/PullSecurityKeyProvider.cs | Adds ownership-based disposal of SKS client. |
| Libraries/Opc.Ua.PubSub/Security/Sks/PubSubSecurityKeyProviderStarter.cs | Adds hosted service to start pull providers on host start. |
| Libraries/Opc.Ua.PubSub/DependencyInjection/PubSubTransportFactoryServiceCollectionExtensions.cs | Adds decorator-based transport factory registration helpers. |
| Libraries/Opc.Ua.PubSub/DependencyInjection/PubSubConfigurationBuilderExtensions.cs | Adds config-authoring bridge ConfigureConfiguration(...). |
| Libraries/Opc.Ua.PubSub/DependencyInjection/PubSubBuilder.cs | Moves encoder/decoder registration to DI-based resolution. |
| Libraries/Opc.Ua.PubSub/Application/PubSubApplicationOptions.cs | Clarifies SKS endpoints list is diagnostic/discovery only. |
| Libraries/Opc.Ua.PubSub.Server/DependencyInjection/OpcUaServerBuilderPubSubExtensions.cs | Adds one-shot AddPubSubServer overloads on IOpcUaBuilder. |
| Libraries/Opc.Ua.PubSub.Schema/DependencyInjection/PubSubSchemaServiceCollectionExtensions.cs | Adds AddSchema() on IPubSubBuilder. |
| Libraries/Opc.Ua.PubSub.Mqtt/DependencyInjection/MqttTransportServiceCollectionExtensions.cs | Adds MQTT transport builder + one-shot registrations + options chaining. |
| Libraries/Opc.Ua.PubSub.Mqtt/DependencyInjection/MqttTransportBuilder.cs | Implements IMqttTransportBuilder decorator for fluent chaining. |
| Libraries/Opc.Ua.PubSub.Mqtt/DependencyInjection/IMqttTransportBuilder.cs | Adds MQTT-specific builder interface. |
| Libraries/Opc.Ua.PubSub.Eth/DependencyInjection/EthTransportServiceCollectionExtensions.cs | Adds Ethernet one-shot PubSub registrations + decorator-aware factory. |
| Libraries/Opc.Ua.PubSub.Diagnostics/Opc.Ua.PubSub.Diagnostics.csproj | Suppresses legacy TFM empty-shell warnings for diagnostics lib. |
| Libraries/Opc.Ua.PubSub.Diagnostics/DependencyInjection/PubSubPcapServiceCollectionExtensions.cs | Makes pcap decoration order-independent via transport decorators. |
| Libraries/Opc.Ua.PubSub.Adapter/DependencyInjection/OpcUaPubSubAdapterBuilderExtensions.cs | Adds one-shot server adapter PubSub registration overloads. |
| Libraries/Opc.Ua.Lds.Server/RegisteredServerStore.cs | Extracts store interface for DI/injectability. |
| Libraries/Opc.Ua.Lds.Server/Opc.Ua.Lds.Server.csproj | Adds HTTPS bindings project reference. |
| Libraries/Opc.Ua.Lds.Server/MulticastDiscovery.cs | Extracts multicast interface + injects store abstraction. |
| Libraries/Opc.Ua.Lds.Server/LdsServer.cs | Adds injectable store/multicast, owns-store semantics, + fail-fast transport binding. |
| Libraries/Opc.Ua.Lds.Server/IRegisteredServerStore.cs | New store interface for registrations/network records. |
| Libraries/Opc.Ua.Lds.Server/IMulticastDiscovery.cs | New multicast abstraction for LDS-ME component. |
| Libraries/Opc.Ua.Lds.Server/Hosting/OpcUaLdsServerBuilderExtensions.cs | Adds LDS builder forwarders for transports and injectable store/multicast factories. |
| Libraries/Opc.Ua.Lds.Server/Hosting/LdsServerOptions.cs | Adds reverse-connect options to hosted LDS. |
| Libraries/Opc.Ua.Lds.Server/Hosting/LdsServerHostedService.cs | Injects store/multicast/transports and disposes application instance. |
| Libraries/Opc.Ua.Lds.Server/Hosting/ILdsServerBuilder.cs | Adds DI hooks for store/multicast factory registration. |
| Libraries/Opc.Ua.Lds.Server/Hosting/ILdsMulticastDiscoveryFactory.cs | Adds LMDS multicast factory interface. |
| Libraries/Opc.Ua.Gds.Server.Common/Opc.Ua.Gds.Server.Common.csproj | Adds optional NOHTTPS flag + conditional HTTPS reference. |
| Libraries/Opc.Ua.Gds.Server.Common/Hosting/IGdsServerBuilder.cs | Adds AddInMemoryStores() builder API. |
| Libraries/Opc.Ua.Gds.Server.Common/Hosting/GdsServerOptions.cs | Adds reverse-connect options to hosted GDS. |
| Libraries/Opc.Ua.Gds.Server.Common/Hosting/GdsServerHostedService.cs | Adds store fast-fail + reverse-connect + DI transport binding wiring. |
| Libraries/Opc.Ua.Gds.Client.Common/GdsAccessTokenProvider.cs | Adds lazy auth client factory + cached client creation. |
| Libraries/Opc.Ua.Di.Client/Hosting/OpcUaClientDiBuilderExtensions.cs | Adds DI transfer client factory registration. |
| Libraries/Opc.Ua.Client/WebApi/OpcUaWebApiClientBuilderExtensions.cs | Adds IOpcUaClientBuilder overloads for WebApi transport channel. |
| Libraries/Opc.Ua.Client/Session/ManagedSessionPool.cs | Adds keyed managed session pool implementation. |
| Libraries/Opc.Ua.Client/Session/ManagedSessionOptions.cs | Adds LoadComplexTypes option. |
| Libraries/Opc.Ua.Client/Session/ManagedSession.cs | Adds reverse-connect support to managed session creation. |
| Libraries/Opc.Ua.Client/Session/IManagedSessionPool.cs | New managed session pool contract. |
| Libraries/Opc.Ua.Client/Session/IManagedSessionFactory.cs | New DI managed session factory contract. |
| Libraries/Opc.Ua.Client/Session/IManagedSessionConnector.cs | Adds internal connector seam for DI connection logic. |
| Libraries/Opc.Ua.Client/Session/DefaultManagedSessionFactory.cs | Adds DI-backed managed session factory implementation. |
| Libraries/Opc.Ua.Client/Session/DefaultManagedSessionConnector.cs | Default connector that forwards into existing connect helper. |
| Libraries/Opc.Ua.Client/Session/ChannelManagerSessionFactory.cs | Adds engine factory forwarding to managed channel sessions. |
| Libraries/Opc.Ua.Client/Roles/RoleManagementClientFactory.cs | Adds DI factory for role management client creation. |
| Libraries/Opc.Ua.Client/Historian/HistoryClientFactory.cs | Adds DI factory for historian client creation. |
| Libraries/Opc.Ua.Client/Fluent/OpcUaSubClientBuilderExtensions.cs | Adds fluent registrations for per-session feature client factories. |
| Libraries/Opc.Ua.Client/Fluent/ManagedSessionExtensions.cs | Adds subscription overload using IOptionsMonitor. |
| Libraries/Opc.Ua.Client/Fluent/ManagedSessionBuilder.cs | Adds reverse-connect and complex type auto-load support. |
| Libraries/Opc.Ua.Client/Fluent/DiscoveryConnectOptions.cs | Adds discovery-driven connect options model. |
| Libraries/Opc.Ua.Client/FileSystem/FileTransferClientFactory.cs | Adds DI factory for file transfer client creation. |
| Libraries/Opc.Ua.Client/Discovery/OpcUaDiscoveryService.cs | Adds injectable discovery service implementation. |
| Libraries/Opc.Ua.Client/Discovery/IOpcUaDiscoveryService.cs | Adds discovery service interface for DI. |
| Libraries/Opc.Ua.Client/ComplexTypes/IComplexTypeSystemFactory.cs | Adds factory interface for session-bound complex type systems. |
| Libraries/Opc.Ua.Client/ComplexTypes/DefaultComplexTypeSystemFactory.cs | Adds default complex type system factory implementation. |
| Libraries/Opc.Ua.Client/AliasNames/AliasNameClientFactory.cs | Adds DI factory for alias-name client creation. |
| Libraries/Opc.Ua.Client/Alarms/OpcUaAlarmsBuilderExtensions.cs | Adds IOpcUaClientBuilder overload for alarms registration. |
| Libraries/Opc.Ua.Client.ComplexTypes/OpcUaComplexTypesBuilderExtensions.cs | Adds client-builder overloads + managed client one-shot + DI factory wiring. |
| Libraries/Opc.Ua.Client.ComplexTypes/Opc.Ua.Client.ComplexTypes.csproj | Adds config abstractions dependency needed for new overloads. |
| Libraries/Opc.Ua.Client.ComplexTypes/ComplexTypeSystemFactory.cs | Implements IComplexTypeSystemFactory on existing factory. |
| Docs/Transports.md | Documents one-shot HTTPS transport + fail-fast binding behavior. |
Comments suppressed due to low confidence (3)
Libraries/Opc.Ua.PubSub/Security/Sks/PullSecurityKeyProvider.cs:1
- When
ownsSecurityKeyServiceis true,DisposeAsynconly disposes SKS clients that implementIAsyncDisposable. If the SKS client implementsIDisposable(but notIAsyncDisposable), it will never be disposed and can leak resources. Consider disposingIDisposableas well (while still preferringIAsyncDisposablewhen available).
Libraries/Opc.Ua.PubSub/DependencyInjection/PubSubBuilder.cs:1 - This removes the previous unconditional
.UseAllStandardEncoders()behavior and now relies entirely onINetworkMessageEncoder/INetworkMessageDecoderservices being registered in DI. If no encoders/decoders are registered (common for existing setups), the PubSub application can be built without any codec support. To preserve backward compatibility, consider falling back to registering/adding standard encoders/decoders when none are found (or retain.UseAllStandardEncoders()as a baseline and then add DI-provided codecs on top).
Stack/Opc.Ua.Bindings.Https/DependencyInjection/OpcUaWebApiBuilderExtensions.cs:1 AddWebApiTransportusesAddSingleton<IHttpsListenerStartupContributor>(...), which is not idempotent and will add duplicateIHttpsListenerStartupContributorregistrations ifAddWebApiTransport()is called more than once. If downstream HTTPS/WSS factories enumerate contributors, this can cause repeated mappings or repeated startup work. Consider usingTryAddEnumerable(ServiceDescriptor.Singleton<IHttpsListenerStartupContributor, WebApiHttpsStartupContributor>())(or equivalent) so the interface registration is deduped while still supporting multiple contributor types.
…t-api-completeness # Conflicts: # Libraries/Opc.Ua.Client/Fluent/ManagedSessionBuilder.cs # Libraries/Opc.Ua.Client/Fluent/OpcUaClientBuilderExtensions.cs # Libraries/Opc.Ua.Client/Session/ManagedSession.cs # Libraries/Opc.Ua.Server/Hosting/OpcUaServerHostedService.cs # Stack/Opc.Ua.Bindings.Https/DependencyInjection/OpcUaHttpsBuilderExtensions.cs # Tests/Opc.Ua.Client.Tests/Session/ManagedSessionComplianceTests.cs
…ns, not IServiceCollection scan Replace the brittle scan of IServiceCollection for an OpcUaClientOptions ImplementationInstance (in AddManagedClient(IConfigurationSection)) with an internal AddClient(section, postConfigure) overload that applies the LoadComplexTypes flag to the bound options before registration. Config binding stays in the Opc.Ua.Client assembly (AOT-safe via the binding source generator); no dependency on how options are later resolved.
cristipogacean
approved these changes
Jul 7, 2026
…t-api-completeness # Conflicts: # Docs/PubSub.md # Libraries/Opc.Ua.PubSub/DependencyInjection/PubSubBuilder.cs
Align the merged Kafka transport and PubSub HA/redundancy DI surface with this PR's conventions: - Route Kafka JSON+UADP IPubSubTransportFactory registration through AddPubSubTransportFactory(Func<>) so IPubSubTransportFactoryDecorator services apply uniformly (Udp/Eth/Mqtt already do). - Add generic WithActivationCoordinator<T>()/WithLeaseStore<T>() overloads and a WithLeaseActivation one-shot (LeaseActivationCoordinator + InMemoryPubSubLeaseStore) via PubSubRedundancyBuilderExtensions + LeaseActivationOptions. - Add AddKafkaPubSub one-shot (IServiceCollection + IOpcUaBuilder) mirroring AddEthPubSub. - Forward the new IPubSubBuilder.WithActivationCoordinator/WithLeaseStore members from MqttTransportBuilder. - Add NUnit coverage (redundancy 4, Kafka DI +2) and update Docs/PubSub.md.
marcschier
added a commit
to marcschier/UA-.NETStandard
that referenced
this pull request
Jul 9, 2026
Brings in 5 upstream commits: OPCFoundation#3957 (expand DI/Fluent API injectability + one-shot ergonomics across client/server/PubSub/discovery/bindings), OPCFoundation#3968 (fix false-positive MODELGEN010), OPCFoundation#3966 (fix source generator dropping BaseAnalogType EURange/EngineeringUnits), OPCFoundation#3949 (Apache Kafka PubSub transport, Part 14 Annex B.2), and OPCFoundation#3959 (MCP server stdio logs to stderr). Resolved one conflict in Directory.Packages.props (three regions), all from our UaLens-specific package entries interleaving with upstream's new Kafka dependency and a Microsoft.Extensions.* version bump: * Kept CommunityToolkit.Mvvm 8.4.2 and added upstream's new Confluent.Kafka 2.15.0. * Accepted upstream's Microsoft.Extensions.* bump (10.0.8 -> 10.0.9, 10.6.0 -> 10.7.0) while re-inserting our Microsoft.Extensions.Diagnostics.ResourceMonitoring 10.5.0 (a UaLens dependency absent from master) in alphabetical position. * Kept ScottPlot.Avalonia 5.1.58 and took upstream's SharpFuzz 2.2.0 -> 2.3.0 bump. UA.slnx auto-merged and retained our McpServer project path. UaLens build clean (0 warnings / 0 errors). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Completes a dependency-injection / fluent-API surface review follow-up so that every feature is reachable and configurable from the
services.AddOpcUa()chain, while keeping all existing granular registrations and direct-construct (new) fallbacks. The change is backward compatible — the single rename (WithAuthorizationService→AddAuthorizationService) keeps an[Obsolete]alias.Client — chainable
IOpcUaClientBuilderoverloads ofAddComplexTypes/AddAlarms/AddWebApiTransportChannel;ManagedSessionOptions.LoadComplexTypes+AddManagedClient()one-shot; injectable multi-endpointIManagedSessionFactory; DI factoriesAddHistorian/AddRoleManagement/AddFileTransfer/AddAliasNames; fail-fast options validation +AddDiscovery().Server —
IOpcUaServerFactory/AddServer<TServer>()seam (the hosted service no longer hardcodesnew StandardServer) unlocking injectable durable subscriptions and session/subscription managers; plusAddHistorian,AddFileSystem(Part 20),AddSecretStore/AddCertificateManager/AddAliasNameStore; secure-by-default anonymous authenticator (marker-guarded, no double-registration).PubSub —
AddUdpPubSub()/AddMqttPubSub()one-shots;IPubSubBuilderanchor unification (AddSecurityKeyServiceClient/Server/PushTarget,AddSchema,AddPcapCapture);ConfigureConfiguration()config-authoring bridge;IMqttTransportBuilderparity with UDP/Eth; order-independent pcap decoration.Discovery / Bindings — LDS/GDS non-TCP endpoints fail loudly instead of silently; GDS
AddInMemoryStores()+ fast-fail when stores are missing; order-independent one-shotAddHttpsTransport()(Kestrel + HTTPS/WSS + optional WebApi/auth);AddAuthorizationService([Obsolete]alias forWithAuthorizationService); root-levelIOpcUaBuilder.AddPcap(); WotCon-server-without-AddServerstartup guard.Docs updated:
Docs/DependencyInjection.md,Docs/PubSub.md,Docs/Transports.md,Docs/WebApi.md.Validation performed locally: the 12 changed libraries and 9 affected test projects build clean (0 warnings / 0 errors) on net10.0 and net48; the full net10.0 sweep of the affected suites passes (~7,700 tests — Server 1920, GDS 904, LDS 149, Client 1577, ComplexTypes 2733, PubSub 1141 + Diagnostics 53, WotCon 344, HTTPS.WebApi 319); the net48 new-feature suites pass (Client 123, Server 43, PubSub 49, GDS 21, LDS 10, WotCon 8, ComplexTypes 7).
Related Issues
Follow-up to an internal DI / Fluent-API surface review (no single tracking issue). Happy to open a tracking issue / ADR if maintainers prefer before merge.
Checklist
Put an
xin the boxes that apply. You can complete these step by step after opening the PR.