diff --git a/src/Yarhl.UnitTests/FileSystem/NodeTests.cs b/src/Yarhl.UnitTests/FileSystem/NodeTests.cs
index 37bdac36..0da6cf4e 100644
--- a/src/Yarhl.UnitTests/FileSystem/NodeTests.cs
+++ b/src/Yarhl.UnitTests/FileSystem/NodeTests.cs
@@ -137,9 +137,10 @@ public void ChangeFormat()
var dummyFormat1 = new StringFormat("3");
var dummyFormat2 = new IntFormat(4);
using var node = new Node("mytest", dummyFormat1);
- node.ChangeFormat(dummyFormat2);
+ Node output = node.ChangeFormat(dummyFormat2);
Assert.AreNotSame(node.Format, dummyFormat1);
Assert.AreSame(node.Format, dummyFormat2);
+ Assert.AreSame(node, output);
}
[Test]
diff --git a/src/Yarhl/FileSystem/Node.cs b/src/Yarhl/FileSystem/Node.cs
index 72d343e7..d16d0766 100644
--- a/src/Yarhl/FileSystem/Node.cs
+++ b/src/Yarhl/FileSystem/Node.cs
@@ -124,6 +124,7 @@ public Node(Node node)
///
/// Change the format of the current node.
///
+ /// This node.
///
/// If the previous format was a container, this method will
/// remove the children of the node.
@@ -137,14 +138,14 @@ public Node(Node node)
/// If the method will dispose the previous
/// format.
///
- public void ChangeFormat(IFormat? newFormat, bool disposePreviousFormat = true)
+ public Node ChangeFormat(IFormat? newFormat, bool disposePreviousFormat = true)
{
if (Disposed) {
throw new ObjectDisposedException(nameof(Node));
}
if (newFormat == Format) {
- return;
+ return this;
}
// If it was a container, clean children
@@ -162,6 +163,8 @@ public void ChangeFormat(IFormat? newFormat, bool disposePreviousFormat = true)
if (IsContainer) {
AddContainerChildren();
}
+
+ return this;
}
///