private static SyntaxTokenList FixMethodModifiers(SyntaxTokenList modifiers, ref TypeSyntax newReturnType) { var asyncTokenIndex = modifiers.IndexOf(SyntaxKind.AsyncKeyword); SyntaxTokenList newModifiers; if (asyncTokenIndex == 0) { // Have to move the trivia on the async token appropriately. var asyncLeadingTrivia = modifiers[0].LeadingTrivia; if (modifiers.Count > 1) { // Move the trivia to the next modifier; newModifiers = modifiers.Replace( modifiers[1], modifiers[1].WithPrependedLeadingTrivia(asyncLeadingTrivia)); newModifiers = newModifiers.RemoveAt(0); } else { // move it to the return type. newModifiers = modifiers.RemoveAt(0); newReturnType = newReturnType.WithPrependedLeadingTrivia(asyncLeadingTrivia); } } else { newModifiers = modifiers.RemoveAt(asyncTokenIndex); } return(newModifiers); }