bzinchenko / bpmnview

Viewing and printing business process diagrams in a popular BPMN format
MIT License
92 stars 31 forks source link

Can't set ID in curly braces during BPMN.Element construction #14

Open kubajal opened 5 years ago

kubajal commented 5 years ago

Hi, please consider 3 scenarios in which we want to create instances of BPMN.Element and at the same time set their BPMN.Element.ID property:

  1. new BPMN.Element { ID = "task", TypeName = "sendTask", ParentID = "process" } This code sets the ID of the element to the expected value ("task").

  2. new BPMN.Element { ID = "mes", TypeName = "messageFlow", ParentID = "process", Attributes = new Dictionary<string, string>() { ["sourceRef"] = "task1", ["targetRef"] = "task" } } This code sets the ID property incorrectly to null. Please note that here I use BPMN.Elements.Attibutes to set some additional attributes.

  3. new BPMN.Element { TypeName = "messageFlow", ParentID = "process", Attributes = new Dictionary<string, string>() { ["id"] = "mes", ["sourceRef"] = "task1", ["targetRef"] = "task" } } This code sets the ID property to the expected value ("mes"), Note that I set the ID explicitly in the BPMN.Elements.Attibutes dictionary.

It seems that initializing BPMN.Element.Attributes disregards ID property that is supposed to be set.

IMHO it's a small flaw in the API. Definitely it isn't a major bug but it would be nice to fix this inconsistency, especially in the context of unit testing. BPMN.View version: 1.0.6 (Nuget package)