private MemberDeclarationSyntax ExplicitInterfaceMember() { var mockedIndexer = F.IndexerDeclaration(ValueWithReadonlyTypeSyntax) .WithParameterList(F.BracketedParameterList(F.SeparatedList(Symbol.Parameters.Select(a => F.Parameter(F.Identifier(a.Name)).WithType(TypesForSymbols.ParseTypeName(a.Type, a.NullableOrOblivious())))))) .WithExplicitInterfaceSpecifier(F.ExplicitInterfaceSpecifier(TypesForSymbols.ParseName(InterfaceSymbol))); if (Symbol.IsReadOnly) { ExpressionSyntax invocation = F.InvocationExpression(F.IdentifierName(MemberMockName), F.ArgumentList(F.SeparatedList(Symbol.Parameters.Select(a => F.Argument(F.IdentifierName(a.Name)))))); if (Symbol.ReturnsByRef || Symbol.ReturnsByRefReadonly) { invocation = F.RefExpression(invocation); } mockedIndexer = mockedIndexer .WithExpressionBody(F.ArrowExpressionClause(invocation)) .WithSemicolonToken(F.Token(SyntaxKind.SemicolonToken)); } else { if (!Symbol.IsWriteOnly) { var argumentList = F.SeparatedList(Symbol.Parameters.Select(a => F.Argument(F.IdentifierName(a.Name)))); mockedIndexer = mockedIndexer.AddAccessorListAccessors(F.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration) .WithExpressionBody(F.ArrowExpressionClause(F.InvocationExpression(F.IdentifierName(MemberMockName)) .WithArgumentList(F.ArgumentList(argumentList)))) .WithSemicolonToken(F.Token(SyntaxKind.SemicolonToken)) ); } if (!Symbol.IsReadOnly) { var argumentList = F.SeparatedList(Symbol.Parameters.Select(a => F.Argument(F.IdentifierName(a.Name)))) .Add(F.Argument(F.IdentifierName("value"))); mockedIndexer = mockedIndexer.AddAccessorListAccessors(F.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration) .WithExpressionBody(F.ArrowExpressionClause(F.InvocationExpression(F.IdentifierName(MemberMockName), F.ArgumentList(argumentList)))) .WithSemicolonToken(F.Token(SyntaxKind.SemicolonToken)) ); } } return(mockedIndexer); }