private async Task <Document> ImplementVirtualRaiseEventFieldAsync(Document document, EventFieldDeclarationSyntax declaration, CancellationToken c) { var eventName = declaration.Declaration.Variables.Single().Identifier.ValueText; var raiseMethod = CreateRaiseMethod(eventName, eventName, (declaration.Declaration.Type as GenericNameSyntax)); var root = await document.GetSyntaxRootAsync(c); var newRoot = root.InsertNodesAfter(declaration, new SyntaxNode[] { raiseMethod }); // Note that we need to find the node again declaration = newRoot.FindToken(declaration.Span.Start).Parent.AncestorsAndSelf() .OfType <EventFieldDeclarationSyntax>().First(); var modifiers = declaration.Modifiers; var virtualToken = modifiers.Single(m => m.Kind() == SyntaxKind.VirtualKeyword); var newDeclaration = declaration.ReplaceToken(virtualToken, Token(SyntaxKind.None)); newRoot = newRoot.ReplaceNode(declaration, newDeclaration .WithTrailingTrivia(TriviaList(CarriageReturnLineFeed, CarriageReturnLineFeed))); return(document.WithSyntaxRoot(newRoot)); }