Skip to content

Commit cc1bef9

Browse files
committed
IRecursiveParent<T>.Children returns IReadOnlyCollection
1 parent 2877398 commit cc1bef9

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
@@ -164,11 +164,11 @@ private void ImplementRecursiveParentInterface()
164164
SyntaxFactory.Argument(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, parentedVar, SyntaxFactory.IdentifierName(nameof(ParentedRecursiveTypeNonGeneric.Value)))),
165165
SyntaxFactory.Argument(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, parentedVar, SyntaxFactory.IdentifierName(nameof(ParentedRecursiveTypeNonGeneric.Parent)))))))));
166166

167-
////System.Collections.Generic.IEnumerable<<#= templateType.RecursiveType.TypeName #>> IRecursiveParent<<#= templateType.RecursiveType.TypeName #>>.Children
167+
////System.Collections.Generic.IReadOnlyCollection<<#= templateType.RecursiveType.TypeName #>> IRecursiveParent<<#= templateType.RecursiveType.TypeName #>>.Children
168168
//// => return this.Children;
169169
this.innerMembers.Add(
170170
SyntaxFactory.PropertyDeclaration(
171-
Syntax.IEnumerableOf(this.generator.applyToMetaType.RecursiveType.TypeSyntax),
171+
Syntax.IReadOnlyCollectionOf(this.generator.applyToMetaType.RecursiveType.TypeSyntax),
172172
nameof(IRecursiveParent<IRecursiveType>.Children))
173173
.WithExplicitInterfaceSpecifier(SyntaxFactory.ExplicitInterfaceSpecifier(irecursiveParentOfT))
174174
.WithExpressionBody(SyntaxFactory.ArrowExpressionClause(thisDotChildren))

src/ImmutableObjectGraph.Generation/CodeGen+RootedStructGen.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,8 @@ protected PropertyDeclarationSyntax[] CreateChildrenProperties()
752752
Syntax.ThisDot(GreenNodeFieldName),
753753
this.applyTo.RecursiveParent.RecursiveField.NameAsProperty)))
754754
.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)),
755-
// IEnumerable<TRootedRecursiveType> IRecursiveParent<TRootedRecursiveType>.Children { get; }
756-
SyntaxFactory.PropertyDeclaration(Syntax.IEnumerableOf(this.rootedRecursiveType), nameof(IRecursiveParent<IRecursiveType>.Children))
755+
// IReadOnlyCollection<TRootedRecursiveType> IRecursiveParent<TRootedRecursiveType>.Children { get; }
756+
SyntaxFactory.PropertyDeclaration(Syntax.IReadOnlyCollectionOf(this.rootedRecursiveType), nameof(IRecursiveParent<IRecursiveType>.Children))
757757
.WithExplicitInterfaceSpecifier(SyntaxFactory.ExplicitInterfaceSpecifier(CreateIRecursiveParentOfTSyntax(this.rootedRecursiveType)))
758758
// => this.Children;
759759
.WithExpressionBody(SyntaxFactory.ArrowExpressionClause(Syntax.ThisDot(this.applyTo.RecursiveParent.RecursiveField.NameAsProperty)))

src/ImmutableObjectGraph/IRecursiveCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface IRecursiveParent : IRecursiveType {
2020

2121
public interface IRecursiveParent<out TRecursiveType> : IRecursiveParent
2222
where TRecursiveType : IRecursiveType {
23-
new IEnumerable<TRecursiveType> Children { get; }
23+
new IReadOnlyCollection<TRecursiveType> Children { get; }
2424
}
2525

2626
public interface IRecursiveParentWithChildReplacement<TRecursiveType> : IRecursiveParent

0 commit comments

Comments
 (0)