private static SyntaxTriviaList InsertDocumentationCommentTrivia(SyntaxTriviaList leadingTrivia, SyntaxTrivia commentTrivia) { int index = leadingTrivia.LastIndexOf(SyntaxKind.EndOfLineTrivia); if (index != -1) { return(leadingTrivia.Insert(index + 1, commentTrivia)); } else { return(leadingTrivia.Insert(0, commentTrivia)); } }