Skip to content

Commit 2877398

Browse files
committed
IRecursiveParent.Children returns a collection instead of IEnumerable
1 parent 2991f6d commit 2877398

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/ImmutableObjectGraph.Generation/CodeGen+EnumerableRecursiveParentGen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ private void ImplementRecursiveParentInterface()
115115
// this.Children;
116116
var thisDotChildren = Syntax.ThisDot(SyntaxFactory.IdentifierName(this.generator.applyToMetaType.RecursiveField.Name.ToPascalCase()));
117117

118-
// System.Collections.Generic.IEnumerable<IRecursiveType> IRecursiveParent.Children
118+
// System.Collections.Generic.IReadOnlyCollection<IRecursiveType> IRecursiveParent.Children
119119
this.innerMembers.Add(
120120
SyntaxFactory.PropertyDeclaration(
121-
Syntax.GetTypeSyntax(typeof(IEnumerable<IRecursiveType>)),
121+
Syntax.GetTypeSyntax(typeof(IReadOnlyCollection<IRecursiveType>)),
122122
nameof(IRecursiveParent.Children))
123123
.WithExplicitInterfaceSpecifier(SyntaxFactory.ExplicitInterfaceSpecifier(Syntax.GetTypeSyntax(typeof(IRecursiveParent))))
124124
.WithExpressionBody(SyntaxFactory.ArrowExpressionClause(thisDotChildren))

src/ImmutableObjectGraph.Generation/CodeGen+RootedStructGen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ protected MethodDeclarationSyntax CreateParentedNodeMethod()
743743
protected PropertyDeclarationSyntax[] CreateChildrenProperties()
744744
{
745745
return new PropertyDeclarationSyntax[] {
746-
// IEnumerable<IRecursiveType> IRecursiveParent.Children => this.greenNode.Children;
747-
SyntaxFactory.PropertyDeclaration(Syntax.IEnumerableOf(Syntax.GetTypeSyntax(typeof(IRecursiveType))), nameof(IRecursiveParent.Children))
746+
// IReadOnlyCollection<IRecursiveType> IRecursiveParent.Children => this.greenNode.Children;
747+
SyntaxFactory.PropertyDeclaration(Syntax.IReadOnlyCollectionOf(Syntax.GetTypeSyntax(typeof(IRecursiveType))), nameof(IRecursiveParent.Children))
748748
.WithExplicitInterfaceSpecifier(SyntaxFactory.ExplicitInterfaceSpecifier(Syntax.GetTypeSyntax(typeof(IRecursiveParent))))
749749
.WithExpressionBody(SyntaxFactory.ArrowExpressionClause(
750750
SyntaxFactory.MemberAccessExpression(

src/ImmutableObjectGraph/IRecursiveCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface IRecursiveType {
1313
}
1414

1515
public interface IRecursiveParent : IRecursiveType {
16-
IEnumerable<IRecursiveType> Children { get; }
16+
IReadOnlyCollection<IRecursiveType> Children { get; }
1717

1818
ParentedRecursiveType<IRecursiveParent<IRecursiveType>, IRecursiveType> GetParentedNode(IdentityFieldType identity);
1919
}

0 commit comments

Comments
 (0)