Skip to content

Commit eccaf69

Browse files
committed
Fix rule example to underline the risk of infinite loop
1 parent 8580a77 commit eccaf69

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

doc/command-examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sample Aggregator CLI usage
22

3-
Remember that the Instance name must be unique in Azure.
3+
Remember that the Instance name must be unique in Azure (CLI automatical append `aggregator` suffix to help).
44

55
```
66
# logon

doc/rule-examples.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,22 @@ return self.PreviousRevision.PreviousRevision.Description;
4545
# Create new Work Item
4646
```
4747
var parent = self;
48-
var newChild = store.NewWorkItem("Task");
49-
newChild.Title = "Brand new child";
50-
parent.Relations.AddChild(newChild);
48+
49+
// test to avoid infinite loop
50+
if (parent.WorkItemType == "Task") {
51+
return "No root type";
52+
}
53+
54+
var children = parent.Children;
55+
// test to avoid infinite loop
56+
if (!children.Any(c => c.Title == "Brand new child"))
57+
{
58+
var newChild = store.NewWorkItem("Task");
59+
newChild.Title = "Brand new child";
60+
parent.Relations.AddChild(newChild);
61+
62+
return "Item added";
63+
}
5164
5265
return parent.Title;
5366
```

0 commit comments

Comments
 (0)