Skip to content

Commit 5941385

Browse files
committed
Fixed bug in Move() related to updating AttributeDescriptors
When moving a `ContentTypeDescriptor` to a different parent, the `ContentTypeDescriptor.AttributeDescriptors` collections of each descendant `ContentTypeDescriptor` must be updated, since those will contain cached references to `AttributeDescriptor`s inherited from their parents. While this code was in place, it compared the `topic.Parent` to the `target` (parent) _after_ `topic` had _already_ been moved to `target`. As such, this code would never fire, because it would never appear as though the `ContentTypeDescriptor` was being moved to a _new_ parent. Oops. This fixes this by storing a reference to the previous parent, and then comparing that to the target after calling `SetParent()`.
1 parent 3f952a6 commit 5941385

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

OnTopic/Repositories/TopicRepositoryBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ public virtual void Move([ValidatedNotNull, NotNull]Topic topic, [ValidatedNotNu
434434
/*------------------------------------------------------------------------------------------------------------------------
435435
| Perform base logic
436436
\-----------------------------------------------------------------------------------------------------------------------*/
437+
var previousParent = topic.Parent;
437438
MoveEvent?.Invoke(this, new MoveEventArgs(topic, target));
438439
topic.SetParent(target, sibling);
439440

@@ -444,7 +445,7 @@ public virtual void Move([ValidatedNotNull, NotNull]Topic topic, [ValidatedNotNu
444445
| collection. As such, when a content type is moved to a new location, the attribute descriptors for itself and all
445446
| descendants needs to be reset to ensure the inheritance structure is updated.
446447
\-----------------------------------------------------------------------------------------------------------------------*/
447-
if (topic.Parent != target && topic is ContentTypeDescriptor) {
448+
if (previousParent != target && topic is ContentTypeDescriptor) {
448449
ResetAttributeDescriptors(topic);
449450
}
450451

0 commit comments

Comments
 (0)