Files
romanett 8d2d363d04 Add MultiState Discrete write validation (#4255)
## Summary

Adds hand-written partial state classes that enforce OPC UA Part 8
§5.3.3 write validation for the `DiscreteItemType` subtypes, plus tests.

## Details

- **`MultiStateDiscreteState`** — a written value is treated as an index
into `EnumStrings`. Returns `BadOutOfRange` when the index is outside
`[0, len)`.
- **`MultiStateValueDiscreteState`** — a written value is matched
against the sparse `EnumValues` set. Returns `BadOutOfRange` when no
entry matches. On a good write, `ValueAsText` is refreshed from the
matching entry's display name.
- **`DiscreteItemState`** — provides the shared `TryGetIntegerValue`
helper that normalizes any scalar integer built-in type to `long` (the
exact-type `Variant` accessors return `default` on a built-in-type
mismatch, so a `BuiltInType` switch is required).
- **`TwoStateDiscreteType`** intentionally has no hand-written class.

These 3 classes are `public partial class` extending the
source-generated DataAccess partials already present on `master`. They
read via the typed properties (`EnumStrings`, `EnumValues`,
`ValueAsText`) rather than `FindChild`, because
`BaseDataVariableState.FindChild` special-cases the `EnumStrings`
BrowseName and never falls through to the `AddChild`'d children.

## Testing

- `dotnet build src\Opc.Ua.Core.Types\Opc.Ua.Core.Types.csproj -c
Release -f net10.0` → 0 warnings, 0 errors.
- 13 tests across `MultiStateDiscreteStateTests` and
`MultiStateValueDiscreteStateTests` pass (13 passed, 0 failed).

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-14 08:24:45 -07:00
..