@@ -62,13 +62,17 @@ private MethodDeclarationSyntax CreateGetParentMethod()
62
62
. AddAttributeLists ( PureAttributeList )
63
63
. AddParameterListParameters ( SyntaxFactory . Parameter ( descendentParam . Identifier ) . WithType ( this . applyTo . RecursiveType . TypeSyntax ) )
64
64
. WithBody ( SyntaxFactory . Block (
65
- // return this. GetParent<TRecursiveParent, TRecursiveType>(descendent);
65
+ // return ImmutableObjectGraph.RecursiveTypeExtensions. GetParent<TRecursiveParent, TRecursiveType>(this, descendent);
66
66
SyntaxFactory . ReturnStatement (
67
67
SyntaxFactory . InvocationExpression (
68
- Syntax . ThisDot (
68
+ SyntaxFactory . MemberAccessExpression (
69
+ SyntaxKind . SimpleMemberAccessExpression ,
70
+ Syntax . GetTypeSyntax ( typeof ( RecursiveTypeExtensions ) ) ,
69
71
SyntaxFactory . GenericName ( nameof ( RecursiveTypeExtensions . GetParent ) )
70
72
. 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 ) ) ) ) ) ;
72
76
}
73
77
74
78
private void ImplementIEnumerableInterfaces ( )
@@ -129,25 +133,32 @@ private void ImplementRecursiveParentInterface()
129
133
. WithSemicolonToken ( SyntaxFactory . Token ( SyntaxKind . SemicolonToken ) )
130
134
. AddAttributeLists ( SyntaxFactory . AttributeList ( SyntaxFactory . SingletonSeparatedList ( DebuggerBrowsableNeverAttribute ) ) ) ) ;
131
135
132
- // public ParentedRecursiveType<TRecursiveParent, TRecursiveType> GetParentedNode(uint identity)
136
+ // public ImmutableObjectGraph. ParentedRecursiveType<TRecursiveParent, TRecursiveType> GetParentedNode(uint identity)
133
137
this . innerMembers . Add (
134
138
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 ) ) ,
138
144
nameof ( IRecursiveParent . GetParentedNode ) )
139
145
. AddModifiers ( SyntaxFactory . Token ( SyntaxKind . PublicKeyword ) )
140
146
. AddAttributeLists ( PureAttributeList )
141
147
//.WithExplicitInterfaceSpecifier(SyntaxFactory.ExplicitInterfaceSpecifier(Syntax.GetTypeSyntax(typeof(IRecursiveParent))))
142
148
. AddParameterListParameters ( RequiredIdentityParameter )
143
149
. WithBody ( SyntaxFactory . Block (
144
- // return this. GetParentedNode<TRecursiveParent, TRecursiveType>(identity);
150
+ // return ImmutableObjectGraph.RecursiveTypeExtensions. GetParentedNode<TRecursiveParent, TRecursiveType>(this, identity);
145
151
SyntaxFactory . ReturnStatement (
146
152
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 ) ) ) ) ) ) ;
151
162
152
163
// ParentedRecursiveType<IRecursiveParent<IRecursiveType>, IRecursiveType> IRecursiveParent.GetParentedNode(<#= templateType.RequiredIdentityField.TypeName #> identity) {
153
164
var parentedVar = SyntaxFactory . IdentifierName ( "parented" ) ;
@@ -194,7 +205,7 @@ private void ImplementOrderedChildrenInterface()
194
205
this . innerMembers . Add ( SyntaxFactory . PropertyDeclaration (
195
206
Syntax . IReadOnlyListOf ( Syntax . GetTypeSyntax ( typeof ( IRecursiveType ) ) ) ,
196
207
nameof ( IRecursiveParentWithOrderedChildren . Children ) )
197
- . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( SyntaxFactory . IdentifierName ( nameof ( IRecursiveParentWithOrderedChildren ) ) ) )
208
+ . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( Syntax . GetTypeSyntax ( typeof ( IRecursiveParentWithOrderedChildren ) ) ) )
198
209
. WithExpressionBody ( SyntaxFactory . ArrowExpressionClause ( Syntax . ThisDot ( SyntaxFactory . IdentifierName ( this . generator . applyToMetaType . RecursiveField . Name ) ) ) )
199
210
. WithSemicolonToken ( SyntaxFactory . Token ( SyntaxKind . SemicolonToken ) )
200
211
. AddAttributeLists ( SyntaxFactory . AttributeList ( SyntaxFactory . SingletonSeparatedList ( DebuggerBrowsableNeverAttribute ) ) ) ) ;
@@ -204,7 +215,7 @@ private void ImplementOrderedChildrenInterface()
204
215
this . innerMembers . Add ( SyntaxFactory . MethodDeclaration (
205
216
SyntaxFactory . PredefinedType ( SyntaxFactory . Token ( SyntaxKind . IntKeyword ) ) ,
206
217
nameof ( IRecursiveParentWithOrderedChildren . IndexOf ) )
207
- . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( SyntaxFactory . IdentifierName ( nameof ( IRecursiveParentWithOrderedChildren ) ) ) )
218
+ . WithExplicitInterfaceSpecifier ( SyntaxFactory . ExplicitInterfaceSpecifier ( Syntax . GetTypeSyntax ( typeof ( IRecursiveParentWithOrderedChildren ) ) ) )
208
219
. AddParameterListParameters ( SyntaxFactory . Parameter ( valueParameterName . Identifier ) . WithType ( Syntax . GetTypeSyntax ( typeof ( IRecursiveType ) ) ) )
209
220
. WithBody ( SyntaxFactory . Block (
210
221
// return this.Children.IndexOf((<#= templateType.RecursiveType.TypeName #>)value);
0 commit comments