Skip to content

Commit 5d831bd

Browse files
committed
Ordered children now get a list collection
1 parent 23befe7 commit 5d831bd

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/ImmutableObjectGraph.Generation/CodeGen+EnumerableRecursiveParentGen.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ private void ImplementOrderedChildrenInterface()
185185
this.baseTypes.Add(SyntaxFactory.SimpleBaseType(Syntax.GetTypeSyntax(typeof(IRecursiveParentWithOrderedChildren))));
186186
}
187187

188+
// IReadOnlyList<IRecursiveType> IRecursiveParentWithOrderedChildren.Children => this.children;
189+
this.innerMembers.Add(SyntaxFactory.PropertyDeclaration(
190+
Syntax.IReadOnlyListOf(Syntax.GetTypeSyntax(typeof(IRecursiveType))),
191+
nameof(IRecursiveParentWithOrderedChildren.Children))
192+
.WithExplicitInterfaceSpecifier(SyntaxFactory.ExplicitInterfaceSpecifier(SyntaxFactory.IdentifierName(nameof(IRecursiveParentWithOrderedChildren))))
193+
.WithExpressionBody(SyntaxFactory.ArrowExpressionClause(Syntax.ThisDot(SyntaxFactory.IdentifierName(this.generator.applyToMetaType.RecursiveField.Name))))
194+
.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken))
195+
.AddAttributeLists(SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(DebuggerBrowsableNeverAttribute))));
196+
188197
// int IRecursiveParentWithOrderedChildren.IndexOf(IRecursiveType value)
189198
var valueParameterName = SyntaxFactory.IdentifierName("value");
190199
this.innerMembers.Add(SyntaxFactory.MethodDeclaration(

src/ImmutableObjectGraph/IRecursiveCollection.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ public interface IRecursiveParentWithChildReplacement<TRecursiveType> : IRecursi
3030
}
3131

3232
public interface IRecursiveParentWithOrderedChildren : IRecursiveParent {
33-
int IndexOf(IRecursiveType value);
33+
new IReadOnlyList<IRecursiveType> Children { get; }
34+
35+
int IndexOf(IRecursiveType value);
3436
}
3537

3638
public interface IRecursiveParentWithSortedChildren : IRecursiveParentWithOrderedChildren {
37-
int Compare(IRecursiveType first, IRecursiveType second);
39+
int Compare(IRecursiveType first, IRecursiveType second);
3840
}
3941

4042
public interface IRecursiveParentWithLookupTable<TRecursiveType> : IRecursiveParent<TRecursiveType>

0 commit comments

Comments
 (0)