internal static Document Apply(this Document document, CodeAction action) { System.Collections.Immutable.ImmutableArray <CodeActionOperation> operations = action.GetOperationsAsync(CancellationToken.None).Result; Solution solution = operations.OfType <ApplyChangesOperation>().Single().ChangedSolution; return(solution.GetDocument(document.Id)); }
/// <summary> /// Apply the inputted CodeAction to the inputted document. /// Meant to be used to apply codefixes. /// </summary> /// <param name="document">The Document to apply the fix on</param> /// <param name="codeAction">A CodeAction that will be applied to the Document.</param> /// <returns>A Document with the changes from the CodeAction</returns> private static async Task <Document> ApplyFix(Document document, CodeAction codeAction) { System.Collections.Immutable.ImmutableArray <CodeActionOperation> operations = await codeAction.GetOperationsAsync(CancellationToken.None); Solution solution = operations.OfType <ApplyChangesOperation>().Single().ChangedSolution; return(solution.GetDocument(document.Id)); }
internal static Solution Apply(CodeAction action) { System.Collections.Immutable.ImmutableArray <CodeActionOperation> operations = action.GetOperationsAsync(CancellationToken.None).Result; return(operations.OfType <ApplyChangesOperation>().Single().ChangedSolution); }