public static void ComputeRefactoring(RefactoringContext context, MemberDeclarationListSelection selectedMembers) { if (selectedMembers.Count == 1) { return; } int start = selectedMembers.First().Span.End; SyntaxTree syntaxTree = selectedMembers.Parent.SyntaxTree; for (int i = selectedMembers.FirstIndex + 1; i <= selectedMembers.LastIndex; i++) { MemberDeclarationSyntax member = selectedMembers.UnderlyingList[i]; SyntaxTrivia documentationCommentTrivia = member.GetDocumentationCommentTrivia(); TextSpan span = (documentationCommentTrivia.IsDocumentationCommentTrivia()) ? documentationCommentTrivia.Span : member.Span; if (syntaxTree.GetLineCount(TextSpan.FromBounds(start, span.Start), context.CancellationToken) != 2) { return; } start = member.Span.End; } context.RegisterRefactoring( "Add empty line between declarations", ct => RefactorAsync(context.Document, selectedMembers, ct), RefactoringIdentifiers.AddEmptyLineBetweenDeclarations); }