@@ -17,14 +17,14 @@ namespace Orleans.CodeGenerator
1717 /// </summary>
1818 internal class InvokableGenerator
1919 {
20- private readonly CodeGenerator _codeGenerator ;
20+ private readonly ProxyGenerationContext _generationContext ;
2121
22- public InvokableGenerator ( CodeGenerator codeGenerator )
22+ public InvokableGenerator ( ProxyGenerationContext generationContext )
2323 {
24- _codeGenerator = codeGenerator ;
24+ _generationContext = generationContext ;
2525 }
2626
27- private LibraryTypes LibraryTypes => _codeGenerator . LibraryTypes ;
27+ private LibraryTypes LibraryTypes => _generationContext . LibraryTypes ;
2828
2929 public GeneratedInvokableDescription Generate ( InvokableMethodDescription invokableMethodInfo )
3030 {
@@ -86,7 +86,7 @@ public GeneratedInvokableDescription Generate(InvokableMethodDescription invokab
8686 invokableMethodInfo ,
8787 accessibility ,
8888 generatedClassName ,
89- CodeGenerator . GetGeneratedNamespaceName ( invokableMethodInfo . ContainingInterface ) ,
89+ GeneratedCodeUtilities . GetGeneratedNamespaceName ( invokableMethodInfo . ContainingInterface ) ,
9090 fieldDescriptions . OfType < IMemberDescription > ( ) . ToList ( ) ,
9191 serializationHooks ,
9292 baseClassType ,
@@ -128,7 +128,7 @@ private ClassDeclarationSyntax GetClassDeclarationSyntax(
128128 var classDeclaration = ClassDeclaration ( generatedClassName )
129129 . AddBaseListTypes ( SimpleBaseType ( baseClassType . ToTypeSyntax ( method . TypeParameterSubstitutions ) ) )
130130 . AddModifiers ( Token ( accessibilityKind ) , Token ( SyntaxKind . SealedKeyword ) )
131- . AddAttributeLists ( CodeGenerator . GetGeneratedCodeAttributes ( ) )
131+ . AddAttributeLists ( GeneratedCodeUtilities . GetGeneratedCodeAttributes ( ) )
132132 . AddMembers ( fields ) ;
133133
134134 foreach ( var alias in compoundTypeAliases )
@@ -774,9 +774,7 @@ MemberDeclarationSyntax GetFieldDeclaration(InvokerFieldDescription description)
774774 else if ( description is PoolFieldDescription )
775775 {
776776 // Pool field: InvokablePool<ThisInvokableType>
777- var poolType = GenericName (
778- Identifier ( "InvokablePool" ) ,
779- TypeArgumentList ( SingletonSeparatedList ( invokableTypeSyntax ) ) ) ;
777+ var poolType = LibraryTypes . InvokablePool_1 . ToTypeSyntax ( invokableTypeSyntax ) ;
780778 field = FieldDeclaration (
781779 VariableDeclaration (
782780 poolType ,
@@ -828,9 +826,7 @@ private ExpressionSyntax GetTypesArray(InvokableMethodDescription method, IEnume
828826 var poolField = fieldDescriptions . OfType < PoolFieldDescription > ( ) . FirstOrDefault ( ) ;
829827 if ( poolField != null )
830828 {
831- var poolType = GenericName (
832- Identifier ( "InvokablePool" ) ,
833- TypeArgumentList ( SingletonSeparatedList ( invokableTypeSyntax ) ) ) ;
829+ var poolType = LibraryTypes . InvokablePool_1 . ToTypeSyntax ( invokableTypeSyntax ) ;
834830 constructorArgumentTypes . Add ( poolType ) ;
835831 parameters . Add ( Parameter ( Identifier ( "pool" ) ) . WithType ( poolType ) ) ;
836832 body . Add ( ExpressionStatement (
@@ -893,7 +889,7 @@ private List<InvokerFieldDescription> GetFieldDescriptions(InvokableMethodDescri
893889 foreach ( var parameter in method . Method . Parameters )
894890 {
895891 var isSerializable = ! SymbolEqualityComparer . Default . Equals ( LibraryTypes . CancellationToken , parameter . Type ) ;
896- fields . Add ( new MethodParameterFieldDescription ( method . CodeGenerator , parameter , $ "arg{ fieldId } ", fieldId , method . TypeParameterSubstitutions , isSerializable ) ) ;
892+ fields . Add ( new MethodParameterFieldDescription ( method . GenerationContext . LibraryTypes , parameter , $ "arg{ fieldId } ", fieldId , method . TypeParameterSubstitutions , isSerializable ) ) ;
897893 fieldId ++ ;
898894 }
899895
@@ -951,7 +947,7 @@ internal sealed class CancellationTokenFieldDescription(LibraryTypes libraryType
951947 internal class MethodParameterFieldDescription : InvokerFieldDescription , IMemberDescription
952948 {
953949 public MethodParameterFieldDescription (
954- CodeGenerator codeGenerator ,
950+ LibraryTypes libraryTypes ,
955951 IParameterSymbol parameter ,
956952 string fieldName ,
957953 uint fieldId ,
@@ -961,7 +957,7 @@ public MethodParameterFieldDescription(
961957 {
962958 TypeParameterSubstitutions = typeParameterSubstitutions ;
963959 FieldId = fieldId ;
964- CodeGenerator = codeGenerator ;
960+ LibraryTypes = libraryTypes ;
965961 Parameter = parameter ;
966962 if ( parameter . Type . TypeKind == TypeKind . Dynamic )
967963 {
@@ -978,8 +974,8 @@ public MethodParameterFieldDescription(
978974 IsSerializable = isSerializable ;
979975 }
980976
981- public CodeGenerator CodeGenerator { get ; }
982977 public ISymbol Symbol { get ; }
978+ public LibraryTypes LibraryTypes { get ; }
983979 public Dictionary < ITypeParameterSymbol , string > TypeParameterSubstitutions { get ; }
984980 public int ParameterOrdinal => Parameter . Ordinal ;
985981 public uint FieldId { get ; }
0 commit comments