Přeskočit obsah

PQA036 — Reference identity target needs its own scalar identity

A type's identity: names a deviceRef whose target type is abstract, has no identity of its own, or is itself identified by a deviceRef.

A reference identity is paired in two passes. The first pass pairs every node identified by scalar properties, the target among them. The second pass pairs the referring node by the persisted id its target got in the first pass.

- type_id: PeridectLcp       # the target
  # no identity: re-discovery never pairs it
- type_id: PeridectLine
  identity: [master_lcp]
  unique: [master_lcp]
  properties:
    master_lcp:
      type: PeridectLcp
      required: true

Why the build refuses this

A target without identity is never paired. It gets a new id on every discovery, so the line that points to it gets a new id too, and everything that points to the line loses it.

An abstract target, or one that only inherits its identity, has no discovery node. Discovery builds the target from its generated <Target>DiscoveryNode, and only a concrete type that declares identity: itself gets one. Without this check the adapter fails with compiler error CS0246 on the missing class.

A target identified by a reference would need a chain of passes. A line identified by an LCP that is identified by another reference needs a third pass, and two such types that point to each other never finish. One pass for references keeps the rule simple and free of cycles.

How to fix it

Give the target a scalar identity, declared on the concrete type itself, the property the hardware determines:

- type_id: PeridectLcp
  identity: [lcp_index]

identity: type on a sole child is a valid target identity too.

What is not reported

A scalar identity. identity: [address] names no deviceRef, and this rule does not apply.

If you disagree with a report

Do not suppress it. A wrong report is a bug in the check — report it with the YAML that triggered it.