2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-06-13 14:38:43 +00:00

Deadlock tests

This commit is contained in:
2026-06-03 13:02:56 +03:00
parent 3dc36149b7
commit 2431166f25
25 changed files with 2160 additions and 157 deletions
+3 -1
View File
@@ -489,7 +489,9 @@ public static class Codec
[typeof(Map<object?, object>)] = DataSerializer.MapComposer,
[typeof(Map<object, object?>)] = DataSerializer.MapComposer,
[typeof(Map<object?, object?>)] = DataSerializer.MapComposer,
[typeof(PropertyValue[])] = DataSerializer.PropertyValueArrayComposer
[typeof(PropertyValue[])] = DataSerializer.PropertyValueArrayComposer,
// Sparse property delta for the reattach reply (index -> value/age/date).
[typeof(Map<byte, PropertyValue>)] = DataSerializer.PropertyValueMapComposer
// Typed
// [typeof(bool[])] = (value, con) => DataSerializer.TypedListComposer((IEnumerable)value, typeof(bool), con),
// [typeof(bool?[])] = (value, con) => (TransmissionDataUnitIdentifier.TypedList, new byte[] { (byte)value }),
+25
View File
@@ -1898,6 +1898,31 @@ public static class DataDeserializer
}
/// <summary>
/// Parses a sparse property delta produced by <c>PropertyValueMapComposer</c> (the reattach
/// reply): a flat sequence of (index, age, date, value) TDUs, returned as a map keyed by the
/// property index. Mirrors <see cref="PropertyValueArrayParserAsync"/> but in groups of four.
/// </summary>
public static AsyncReply<Map<byte, PropertyValue>> PropertyValueMapParserAsync(byte[] data, uint offset, uint length, EpConnection connection, uint[] requestSequence)
{
var rt = new AsyncReply<Map<byte, PropertyValue>>();
ListParserAsync(new ParsedTdu() { Data = data, PayloadOffset = offset, PayloadLength = length }
, connection, requestSequence).Then(x =>
{
var ar = (object[])x;
var map = new Map<byte, PropertyValue>();
for (var i = 0; i + 3 < ar.Length; i += 4)
map[Convert.ToByte(ar[i])] =
new PropertyValue(ar[i + 3], Convert.ToUInt64(ar[i + 1]), (DateTime?)ar[i + 2]);
rt.Trigger(map);
});
return rt;
}
public static async AsyncReply<ParseResult<PropertyValue>> PropertyValueParserAsync(byte[] data, uint offset, EpConnection connection, uint[] requestSequence)//, bool ageIncluded = true)
{
+25
View File
@@ -630,6 +630,31 @@ public static class DataSerializer
(uint)rt.Count, null, null);
}
/// <summary>
/// Composes a sparse property delta (index -> value/age/date) used by the reattach reply, as
/// a flat sequence of (index, age, date, value) TDUs per modified property. PropertyValue is
/// not a self-describing type, so this dedicated composer is used instead of the generic map
/// path. Mirrors <see cref="PropertyValueArrayComposer"/> with a leading property index.
/// </summary>
public static Tdu PropertyValueMapComposer(object value, Warehouse warehouse, EpConnection connection)
{
if (value == null)
return new Tdu(TduIdentifier.Null, new byte[0], 0, null, null);
var rt = new List<byte>();
var map = (Map<byte, PropertyValue>)value;
foreach (var kv in map)
{
rt.AddRange(Codec.Compose(kv.Key, warehouse, connection)); // property index (u8)
rt.AddRange(Codec.Compose(kv.Value.Age, warehouse, connection)); // age
rt.AddRange(Codec.Compose(kv.Value.Date, warehouse, connection)); // modification date
rt.AddRange(Codec.Compose(kv.Value.Value, warehouse, connection)); // value
}
return new Tdu(TduIdentifier.RawData, rt.ToArray(), (uint)rt.Count, null, null);
}
public static Tdu TypedMapComposer(object value, Type keyType, Type valueType, Warehouse warehouse, EpConnection connection)
{
if (value == null)