You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Device.RemoveDataItem(id) does not iterate the top-level DataItems collection when removing an entry — only the nested Component-tree DataItems are considered. A caller who registers a DataItem directly on a Device (as opposed to on one of its Components) cannot remove it through the public API.
Minimal repro
[Test]publicvoidDevice_RemoveDataItem_Removes_TopLevel_DataItem(){vardevice=newDevice{Id="d1",Uuid="d1-uuid",Name="d1",Type=Device.TypeId,};device.AddDataItem(newAvailabilityDataItem(device.Id));// ID: d1_availAssert.That(device.DataItems.Any(di =>di.Id=="d1_avail"),Is.True,"precondition — the DataItem is on the top-level Device");device.RemoveDataItem("d1_avail");Assert.That(device.DataItems.Any(di =>di.Id=="d1_avail"),Is.False,"post-condition — RemoveDataItem must clear the entry from the top-level DataItems collection");// Currently fails: the DataItem remains.}
Impact
AgentConfiguration.DeviceValidationLevel = Remove calls RemoveDataItem from MTConnectAgent.NormalizeDevice when a generic (unknown-Type) DataItem is encountered. If the offending DataItem sits directly on the Device rather than under a Component, the removal is a no-op and the Device is registered with the invalid DataItem still attached.
Note
Detected during PR #218's Ultrareview cycle 1 (finding F-TEST-009). Pre-existing on master — unrelated to PR #218's diff. Filed for follow-up.
Activity