@@ -62,13 +62,17 @@ private MethodDeclarationSyntax CreateGetParentMethod()
6262 . AddAttributeLists ( PureAttributeList )
6363 . AddParameterListParameters ( SyntaxFactory . Parameter ( descendentParam . Identifier ) . WithType ( this . applyTo . RecursiveType . TypeSyntax ) )
6464 . WithBody ( SyntaxFactory . Block (
65- // return this. GetParent<TRecursiveParent, TRecursiveType>(descendent);
65+ // return ImmutableObjectGraph.RecursiveTypeExtensions. GetParent<TRecursiveParent, TRecursiveType>(this, descendent);
6666 SyntaxFactory . ReturnStatement (
6767 SyntaxFactory . InvocationExpression (
68- Syntax . ThisDot (
68+ SyntaxFactory . MemberAccessExpression (
69+ SyntaxKind . SimpleMemberAccessExpression ,
70+ Syntax . GetTypeSyntax ( typeof ( RecursiveTypeExtensions ) ) ,
6971 SyntaxFactory . GenericName ( nameof ( RecursiveTypeExtensions . GetParent ) )
7072 . AddTypeArgumentListArguments ( this . applyTo . RecursiveParent . TypeSyntax , this . applyTo . RecursiveType . TypeSyntax ) ) )
71- . AddArgumentListArguments ( SyntaxFactory . Argument ( descendentParam ) ) ) ) ) ;
73+ . AddArgumentListArguments (
74+ SyntaxFactory . Argument ( SyntaxFactory . ThisExpression ( ) ) ,
75+ SyntaxFactory . Argument ( descendentParam ) ) ) ) ) ;
7276 }
7377
7478 private void ImplementIEnumerableInterfaces ( )
@@ -129,25 +133,32 @@ private void ImplementRecursiveParentInterface()
129133 . WithSemicolonToken ( SyntaxFactory . Token ( SyntaxKind . SemicolonToken ) )
130134 . AddAttributeLists ( SyntaxFactory . AttributeList ( SyntaxFactory . SingletonSeparatedList ( DebuggerBrowsableNeverAttribute ) ) ) ) ;
131135
132- // public ParentedRecursiveType<TRecursiveParent, TRecursiveType> GetParentedNode(uint identity)
136+ // public ImmutableObjectGraph. ParentedRecursiveType<TRecursiveParent, TRecursiveType> GetParentedNode(uint identity)
133137 this . innerMembers . Add (
134138 SyntaxFactory . MethodDeclaration (
135- SyntaxFactory . GenericName ( nameof ( ParentedRecursiveType < IRecursiveParent < IRecursiveType > , IRecursiveType > ) ) . AddTypeArgumentListArguments (
136- this . applyTo . RecursiveParent . TypeSyntax ,
137- this . applyTo . RecursiveType . TypeSyntax ) ,
139+ SyntaxFactory . QualifiedName (
140+ SyntaxFactory . IdentifierName ( nameof ( ImmutableObjectGraph ) ) ,
141+ SyntaxFactory . GenericName ( nameof ( ParentedRecursiveType < IRecursiveParent < IRecursiveType > , IRecursiveType > ) ) . AddTypeArgumentListArguments (
142+ this . applyTo . RecursiveParent . TypeSyntax ,
143+ this . applyTo . RecursiveType . TypeSyntax ) ) ,
138144 nameof ( IRecursiveParent . GetParentedNode ) )
139145 . AddModifiers ( SyntaxFactory . Token ( SyntaxKind . PublicKeyword ) )
140146 . AddAttributeLists ( PureAttributeList )
141147 //.WithExplicitInterfaceSpecifier(SyntaxFactory.ExplicitInterfaceSpecifier(Syntax.GetTypeSyntax(typeof(IRecursiveParent))))
142148 . AddParameterListParameters ( RequiredIdentityParameter )
143149 . WithBody ( SyntaxFactory . Block (
144- // return this. GetParentedNode<TRecursiveParent, TRecursiveType>(identity);
150+ // return ImmutableObjectGraph.RecursiveTypeExtensions. GetParentedNode<TRecursiveParent, TRecursiveType>(this, identity);
145151 SyntaxFactory . ReturnStatement (
146152 SyntaxFactory . InvocationExpression (
147- Syntax . ThisDot ( SyntaxFactory . GenericName ( nameof ( RecursiveTypeExtensions . GetParentedNode ) ) . AddTypeArgumentListArguments (
148- this . applyTo . RecursiveParent . TypeSyntax ,
149- this . applyTo . RecursiveType . TypeSyntax ) ) )
150- . AddArgumentListArguments ( SyntaxFactory . Argument ( IdentityParameterName ) ) ) ) ) ) ;
153+ SyntaxFactory . MemberAccessExpression (
154+ SyntaxKind . SimpleMemberAccessExpression ,
155+ Syntax . GetTypeSyntax ( typeof ( RecursiveTypeExtensions ) ) ,
156+ SyntaxFactory . GenericName ( nameof ( RecursiveTypeExtensions . GetParentedNode ) ) . AddTypeArgumentListArguments (
157+ this . applyTo . RecursiveParent . TypeSyntax ,
158+ this . applyTo . RecursiveType . TypeSyntax ) ) )
159+ . AddArgumentListArguments (
160+ SyntaxFactory . Argument ( SyntaxFactory . ThisExpression ( ) ) ,
161+ SyntaxFactory . Argument ( IdentityParameterName ) ) ) ) ) ) ;
151162
152163 // ParentedRecursiveType<IRecursiveParent<IRecursiveType>, IRecursiveType> IRecursiveParent.GetParentedNode(<#= templateType.RequiredIdentityField.TypeName #> identity) {
153164 var parentedVar = SyntaxFactory . IdentifierName ( "parented" ) ;
@@ -194,7 +205,7 @@ private void ImplementOrderedChildrenInterface()
194205 this . innerMembers . Add ( SyntaxFactory . PropertyDeclaration (
195206 Syntax . IReadOnlyListOf ( Syntax . GetTypeSyntax ( typeof ( IRecursiveType ) ) ) ,
196207 nameof ( IRecursiveParentWithOrderedChildren . Children ) )
197- . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( SyntaxFactory . IdentifierName ( nameof ( IRecursiveParentWithOrderedChildren ) ) ) )
208+ . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( Syntax . GetTypeSyntax ( typeof ( IRecursiveParentWithOrderedChildren ) ) ) )
198209 . WithExpressionBody ( SyntaxFactory . ArrowExpressionClause ( Syntax . ThisDot ( SyntaxFactory . IdentifierName ( this . generator . applyToMetaType . RecursiveField . Name ) ) ) )
199210 . WithSemicolonToken ( SyntaxFactory . Token ( SyntaxKind . SemicolonToken ) )
200211 . AddAttributeLists ( SyntaxFactory . AttributeList ( SyntaxFactory . SingletonSeparatedList ( DebuggerBrowsableNeverAttribute ) ) ) ) ;
@@ -204,7 +215,7 @@ private void ImplementOrderedChildrenInterface()
204215 this . innerMembers . Add ( SyntaxFactory . MethodDeclaration (
205216 SyntaxFactory . PredefinedType ( SyntaxFactory . Token ( SyntaxKind . IntKeyword ) ) ,
206217 nameof ( IRecursiveParentWithOrderedChildren . IndexOf ) )
207- . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( SyntaxFactory . IdentifierName ( nameof ( IRecursiveParentWithOrderedChildren ) ) ) )
218+ . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( Syntax . GetTypeSyntax ( typeof ( IRecursiveParentWithOrderedChildren ) ) ) )
208219 . AddParameterListParameters ( SyntaxFactory . Parameter ( valueParameterName . Identifier ) . WithType ( Syntax . GetTypeSyntax ( typeof ( IRecursiveType ) ) ) )
209220 . WithBody ( SyntaxFactory . Block (
210221 // return this.Children.IndexOf((<#= templateType.RecursiveType.TypeName #>)value);
0 commit comments