Пример #1
0
        private RecordDeclarationSyntax SortRecordNode(RecordDeclarationSyntax recordDeclaration)
        {
            var membersOfRecord = recordDeclaration.Members.ToList();
            var nodeData        = membersOfRecord.ToDictionary(x => x, x => new CSharpSyntaxNodeData(x));

            IComparer <MemberDeclarationSyntax> comparer = new NodeSorter(nodeData, sortingConfiguration);

            membersOfRecord.Sort(comparer);

            RecordDeclarationSyntax recordDeclarationNodeWithoutNodes = recordDeclaration.RemoveNodes(membersOfRecord, SyntaxRemoveOptions.KeepNoTrivia);
            RecordDeclarationSyntax finalRecordDeclarationNode        = recordDeclarationNodeWithoutNodes.WithMembers(new SyntaxList <MemberDeclarationSyntax>(membersOfRecord));

            return(finalRecordDeclarationNode);
        }