Resolve Worker-009..015 code-review findings

Worker-009: WorkerFrameWriter serialized twice and WorkerFrameReader
allocated a payload byte[] per frame. The writer now serializes once into a
single prefix+payload buffer; the reader rents the payload buffer from
ArrayPool and honors the logical frame length.

Worker-010: VariantConverter projected a uint+Time value as a full FILETIME,
producing a near-1601 timestamp. The FILETIME projection is now gated on
`value is long`; uint falls through to the integer projection.

Worker-011: replaced the opaque retryAttempts formula in WorkerPipeClient
with MaxRetryAttempts = int.MaxValue, leaving the connect deadline as the
sole bound.

Worker-012: rewrote stale "future PR / polls on a Timer" comments in
AlarmDispatcher, AlarmCommandHandler, MxAccessAlarmEventSink and
MxAccessEventMapper to match the shipped, post-Worker-001 behavior.

Worker-013 (re-triaged): already resolved — StaMessagePumpTests and
MxAccessStaSessionTests cover the pump and poll loop directly.

Worker-014: moved IAlarmCommandHandler into its own file so
AlarmCommandHandler.cs declares one public type.

Worker-015: clarified the MxAccessBaseEventSink.EnqueueEvent overflow-catch
comment explaining the deliberate double RecordFault no-op.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-05-18 22:42:17 -04:00
parent fe9044115b
commit 1764eff1cf
13 changed files with 229 additions and 127 deletions
@@ -60,6 +60,26 @@ public sealed class VariantConverterTests
Assert.Equal("VT_I8", converted.VariantType);
}
/// <summary>
/// Worker-010 regression: a 32-bit <see cref="uint"/> with an expected
/// data type of <see cref="MxDataType.Time"/> must not be projected as a
/// Windows FILETIME. A uint can only hold the low 32 bits of a FILETIME,
/// which would silently render as a near-1601 timestamp; the converter
/// must fall through to an integer projection instead.
/// </summary>
[Fact]
public void Convert_WithUInt32AndExpectedTime_DoesNotProjectFileTime()
{
const uint value = 123456789u;
MxValue converted = _converter.Convert(value, MxDataType.Time);
Assert.Equal(MxDataType.Integer, converted.DataType);
Assert.Equal(MxValue.KindOneofCase.Int64Value, converted.KindCase);
Assert.Equal(value, converted.Int64Value);
Assert.Equal("VT_UI4", converted.VariantType);
}
/// <summary>Verifies that null-like values preserve their null semantics and variant type.</summary>
/// <param name="value">Null-like value to convert.</param>
/// <param name="expectedVariantType">Expected variant type string.</param>