// Struct //public override SyntaxNode? VisitStructDeclaration(StructDeclarationSyntax node) { // return base.VisitStructDeclaration( node ); //} // Record //public override SyntaxNode? VisitRecordDeclaration(RecordDeclarationSyntax node) { // return base.VisitRecordDeclaration( node ); //} // Helpers private static MethodDeclarationSyntax CreateMethodDeclarationSyntax_ToString(ClassDeclarationSyntax node) { var type = node.GetAnnotations("Type").Single() !.Data !; var members = node.GetAnnotations("Type.Member").Select(i => i.Data !).ToArray(); return(CreateMethodDeclarationSyntax_ToString(GetStringValue(type, members))); }
public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node) { if (node.Modifiers.Any(a => a.IsKind(SyntaxKind.StaticKeyword))) { return(base.VisitClassDeclaration(node)); } var type = node.GetAnnotations("Type").Single().Data; var members = node.GetAnnotations("Type.Member").Select(i => i.Data).ToArray(); node = node.AddMembers(GetSyntax_ToString(type, members)); return(base.VisitClassDeclaration(node)); }