private static SyntaxNode ReformatAccessorAsSingleLine(IndentationOptions indentationOptions, AccessorDeclarationSyntax accessor) { var newAccessor = accessor .WithModifiers(ReformatModifiersAsSingleLine(accessor.Modifiers)) .WithKeyword(ReformatKeywordAsSingleLine(accessor.Keyword)) .WithBody(ReformatBodyAsSingleLine(accessor.Body)); var accessorList = (AccessorListSyntax)accessor.Parent; var indentationSteps = IndentationHelper.GetIndentationSteps(indentationOptions, accessorList.OpenBraceToken); var indentation = IndentationHelper.GenerateWhitespaceTrivia(indentationOptions, indentationSteps + 1); newAccessor = newAccessor.WithLeadingTrivia(newAccessor.GetLeadingTrivia().Insert(0, indentation)); return newAccessor; }
private static SyntaxNode ReformatAccessorAsMultipleLines(IndentationOptions indentationOptions, AccessorDeclarationSyntax accessor) { var accessorList = (AccessorListSyntax)accessor.Parent; var indentationSteps = IndentationHelper.GetIndentationSteps(indentationOptions, accessorList.OpenBraceToken) + 1; var indentation = IndentationHelper.GenerateWhitespaceTrivia(indentationOptions, indentationSteps); var indentationStatements = IndentationHelper.GenerateWhitespaceTrivia(indentationOptions, indentationSteps + 1); var newAccessor = accessor .WithModifiers(ReformatModifiersAsMultipleLines(accessor.Modifiers, indentation)) .WithKeyword(ReformatKeywordAsMultipleLines(accessor.Keyword, indentation, accessor.Modifiers.Count == 0)) .WithBody(ReformatBodyAsMultipleLines(accessor.Body, indentation, indentationStatements)); return newAccessor; }
private static AccessorDeclarationSyntax MakeInterfaceAccessor(AccessorDeclarationSyntax accessorSyntax) { return accessorSyntax.WithModifiers(new SyntaxTokenList()) .WithBody(null) .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)); }