private ClassDeclarationSyntax GenerateReadReplicaGrain(ClassDeclarationSyntax grainClass, ITypeSymbol swmrInterface) { string readReplicaGrainName = SwmrUtils.GetReadReplicaGrainName(grainClass.Identifier.Text); string readReplicaInterfaceName = SwmrUtils.GetReadReplicaInterfaceName(swmrInterface.Name); ClassDeclarationSyntax readReplicaGrain = GenerateClassSqueleton(readReplicaGrainName).WithBaseList(RoslynUtils.BaseList(new[] { "Grain", readReplicaInterfaceName })); string grainStateTypeName = FindGrainStateTypeName(grainClass); readReplicaGrain = readReplicaGrain.AddMembers(SF.FieldDeclaration(SF.VariableDeclaration(SF.ParseTypeName(grainStateTypeName), SF.SeparatedList(new[] { SF.VariableDeclarator(SF.Identifier("State")) }))).AddModifiers(SF.Token(SyntaxKind.PrivateKeyword))); readReplicaGrain = readReplicaGrain.AddMembers(GenerateReadReplicaOnActivateAsync(swmrInterface)); foreach (ISymbol member in swmrInterface.GetMembers()) { IMethodSymbol methodSymbol = member as IMethodSymbol; if (methodSymbol == null || !IsReadOnlyMethod(methodSymbol)) { continue; } MethodDeclarationSyntax methodImpl = RoslynUtils.FindImplementation(methodSymbol, grainClass); readReplicaGrain = readReplicaGrain.AddMembers(methodImpl.WithLeadingTrivia(SF.EndOfLine(""))); } readReplicaGrain = readReplicaGrain.AddMembers(GenerateSetStateMethod(grainStateTypeName)); return(readReplicaGrain); }