public virtual void VisitProperty(Property property) { if (WriteMemberTypes) { VisitTypeSpec(property.PropertyType); writer.Write(' '); } if (WriteTypeBeforeMemberName) { VisitDeclaringTypeSpec(property.DeclaringType); writer.Write('.'); } writer.WriteMemberName(property.Name); writer.Write(' '); writer.Write('{'); writer.Write(' '); if (property.Getter != null) { writer.WriteKeyword("get"); writer.Write(';'); writer.Write(' '); } if (property.Setter != null) { writer.WriteKeyword("set"); writer.Write(';'); writer.Write(' '); } writer.Write('}'); }
void WriteMemberDeclarationName(IMember member, TokenWriter writer, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); EntityDeclaration node = astBuilder.ConvertEntity(member); switch (member.SymbolKind) { case SymbolKind.Indexer: writer.WriteKeyword(Roles.Identifier, "this"); break; case SymbolKind.Constructor: WriteQualifiedName(member.DeclaringType.Name, writer, formattingPolicy); var typeNode = astBuilder.ConvertEntity(member.DeclaringTypeDefinition); WriteTypeParameters(writer, typeNode.GetChildrenByRole(Roles.TypeParameter)); break; case SymbolKind.Destructor: writer.WriteToken(DestructorDeclaration.TildeRole, "~"); WriteQualifiedName(member.DeclaringType.Name, writer, formattingPolicy); break; case SymbolKind.Operator: switch (member.Name) { case "op_Implicit": writer.WriteKeyword(OperatorDeclaration.ImplicitRole, "implicit"); writer.Space(); writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); ConvertType(member.ReturnType, writer, formattingPolicy); break; case "op_Explicit": writer.WriteKeyword(OperatorDeclaration.ExplicitRole, "explicit"); writer.Space(); writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); ConvertType(member.ReturnType, writer, formattingPolicy); break; default: writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); var operatorType = OperatorDeclaration.GetOperatorType(member.Name); if (operatorType.HasValue) { writer.WriteToken(OperatorDeclaration.GetRole(operatorType.Value), OperatorDeclaration.GetToken(operatorType.Value)); } else { writer.WriteIdentifier(node.NameToken); } break; } break; default: writer.WriteIdentifier(Identifier.Create(member.Name)); IEnumerable <AstNode> typeArgs = node.GetChildrenByRole(Roles.TypeParameter); if (member is IMethod) { var typeArguments = ((IMethod)member).TypeArguments; if (typeArguments.Any() && typeArguments.First().Name == "TSource") { typeArgs = typeArgs.Skip(1); } } WriteTypeParameters(writer, typeArgs); break; } }
void WriteMemberDeclarationName(IMember member, TokenWriter writer, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); EntityDeclaration node = astBuilder.ConvertEntity(member); switch (member.SymbolKind) { case SymbolKind.Indexer: writer.WriteKeyword(Roles.Identifier, "this"); break; case SymbolKind.Constructor: WriteQualifiedName(member.DeclaringType.Name, writer, formattingPolicy); var typeNode = astBuilder.ConvertEntity(member.DeclaringTypeDefinition); WriteTypeParameters(writer, typeNode.GetChildrenByRole(Roles.TypeParameter)); break; case SymbolKind.Destructor: writer.WriteToken(DestructorDeclaration.TildeRole, "~"); WriteQualifiedName(member.DeclaringType.Name, writer, formattingPolicy); break; case SymbolKind.Operator: switch (member.Name) { case "op_Implicit": writer.WriteKeyword(OperatorDeclaration.ImplicitRole, "implicit"); writer.Space(); writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); ConvertType(member.ReturnType, writer, formattingPolicy); break; case "op_Explicit": writer.WriteKeyword(OperatorDeclaration.ExplicitRole, "explicit"); writer.Space(); writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); ConvertType(member.ReturnType, writer, formattingPolicy); break; default: writer.WriteKeyword(OperatorDeclaration.OperatorKeywordRole, "operator"); writer.Space(); var operatorType = OperatorDeclaration.GetOperatorType(member.Name); if (operatorType.HasValue) { writer.WriteToken(OperatorDeclaration.GetRole(operatorType.Value), OperatorDeclaration.GetToken(operatorType.Value)); } else { writer.WriteIdentifier(node.NameToken); } break; } break; default: writer.WriteIdentifier(Identifier.Create(member.Name)); if (member is IMethod) { var method = ((IMethod)member); var methodParameterTypeArguments = from p in method.Parameters from type in ExpandIntersections(p.Type) from typeArgument in type.TypeArguments select typeArgument.Name; IEnumerable <AstNode> typeArgs = node.GetChildrenByRole(Roles.TypeParameter).Where(arg => !methodParameterTypeArguments.Contains(arg.Name)); WriteTypeParameters(writer, typeArgs); } break; } }