fix(deploy): include ElementDataType in RevisionHashService.HashableAttribute (#290)
Fold a List attribute's ElementDataType into the hashable projection so a change to the element type (e.g. Int32 -> Double) with identical JSON-encoded values is detected as a staleness/revision change. Inserted in alphabetical position; null ElementDataType (scalars) is omitted by the canonical serializer (WhenWritingNull), so scalar-only configs hash identically to before. DiffService.AttributesEqual gains the same comparison to keep the structured diff in parity with the staleness hash. Adds tests for differing vs. equal ElementDataType (hash + diff) and the scalar no-op guard.
This commit is contained in:
@@ -162,6 +162,37 @@ public class DiffServiceTests
|
||||
Assert.Equal(DiffChangeType.Changed, diff.AttributeChanges[0].ChangeType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ComputeDiff_AttributeElementDataTypeChange_DetectedAsChanged()
|
||||
{
|
||||
// #290: ElementDataType is part of the revision hash, so AttributesEqual
|
||||
// must also compare it — a List element-type change (Int32 → Double) with
|
||||
// identical JSON-encoded values must surface as a Changed attribute,
|
||||
// keeping the structured diff in parity with the staleness hash.
|
||||
var oldConfig = new FlattenedConfiguration
|
||||
{
|
||||
InstanceUniqueName = "Instance1",
|
||||
Attributes =
|
||||
[
|
||||
new ResolvedAttribute { CanonicalName = "Readings", Value = "[1,2]", DataType = "List", ElementDataType = "Int32" }
|
||||
]
|
||||
};
|
||||
var newConfig = new FlattenedConfiguration
|
||||
{
|
||||
InstanceUniqueName = "Instance1",
|
||||
Attributes =
|
||||
[
|
||||
new ResolvedAttribute { CanonicalName = "Readings", Value = "[1,2]", DataType = "List", ElementDataType = "Double" }
|
||||
]
|
||||
};
|
||||
|
||||
var diff = _sut.ComputeDiff(oldConfig, newConfig);
|
||||
|
||||
Assert.True(diff.HasChanges);
|
||||
Assert.Single(diff.AttributeChanges);
|
||||
Assert.Equal(DiffChangeType.Changed, diff.AttributeChanges[0].ChangeType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ComputeDiff_AlarmDescriptionChange_DetectedAsChanged()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user