mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-21 17:16:16 +08:00
a240bf8fe3
Backport of https://github.com/OPCFoundation/UA-.NETStandard/commit/9883c41e48992a7cbc7347f9b2f1e50c8a3c1df6 (#4055) from `master` to `master378`. ## Description `ValidateAsync(ApplicationType.Server)` accepted a null `TransportQuotas` without error, but the transport/secure-channel layers assume it is non-null, so `ApplicationInstance.StartAsync` later threw a `NullReferenceException`. The fluent builder path (`ApplicationInstance.Build`) already always initializes `TransportQuotas = new TransportQuotas()`; manually-assembled configurations could leave it null. Changes: - **`ApplicationConfiguration.ValidateAsync`**: default `TransportQuotas` when null, aligning the manual-construction path with the builder path. ```csharp // Transport/secure-channel layers rely on this being non-null during bring-up. TransportQuotas ??= new TransportQuotas(); ``` `TransportQuotas`'s default constructor yields complete, valid limits (`DefaultEncodingLimits` / `TcpMessageLimits`), so minimal server configs now start with sensible defaults instead of crashing. - **Tests** (`ApplicationConfigurationTests`, new file on this branch): `ValidateAsyncDefaultsTransportQuotasWhenNull`, `ValidateAsyncKeepsExplicitTransportQuotas`, and `ValidateAsyncDefaultsTransportQuotasWhenNullForClient`. ## Notes - Ported to `master378`. The test fixture did not exist on this branch, so it was added. - Built `Opc.Ua.Core.Tests` (net8.0) with 0 warnings; the 3 new tests pass. ## Checklist - [x] I have added tests that prove my fix is effective or that my feature works and increased code coverage. - [x] I have verified that my changes do not introduce (new) build or analyzer warnings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>