Skip to content

Commit 960748b

Browse files
committed
Add a note about property collection multi-level ancestry
1 parent f2368ee commit 960748b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/MHServerEmu/Games/Properties/PropertyCollection.cs

+4
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ public void FlattenCopyFrom(PropertyCollection other, bool cleanCopy)
279279
/// <summary>
280280
/// Adds a child <see cref="PropertyCollection"/> and aggregates its values.
281281
/// </summary>
282+
/// <remarks>
283+
/// When you add a child collection make sure it's not a parent of parent of this collection, or things are going to break.
284+
/// </remarks>
282285
public bool AddChildCollection(PropertyCollection childCollection)
283286
{
284287
// Check child collection
@@ -288,6 +291,7 @@ public bool AddChildCollection(PropertyCollection childCollection)
288291
if (childCollection == this)
289292
return Logger.WarnReturn(false, "AddChildCollection(): Attempted to add itself as a child");
290293

294+
// To make this more safe we might want to add a recursive check of all ancestors here
291295
if (_parentCollections.Contains(childCollection))
292296
return Logger.WarnReturn(false, "AddChildCollection(): Attempted to add a parent as a child");
293297

0 commit comments

Comments
 (0)