Skip to content

Commit

Permalink
Filter out code actions that are subclasses of CodeActionWithOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinCampbell committed Feb 5, 2017
1 parent a25c1a1 commit 8396cee
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ protected async Task<IEnumerable<AvailableCodeAction>> GetAvailableCodeActions(I
// TODO: Determine good way to order code actions.
actions.Reverse();

return ConvertToCodeActionAndParents(actions);
// Be sure to filter out any code actions that inherit from CodeActionWithOptions.
// This isn't a great solution and might need changing later, but every Roslyn code action
// derived from this type tries to display a dialog. For now, this is a reasonable solution.
var availableActions = ConvertToAvailableCodeAction(actions)
.Where(a => !a.CodeAction.GetType().GetTypeInfo().IsSubclassOf(typeof(CodeActionWithOptions)));

return availableActions;
}

private async Task<CodeRefactoringContext?> GetRefactoringContext(Document originalDocument, ICodeActionRequest request, List<CodeAction> actionsDestination)
Expand Down Expand Up @@ -142,7 +148,7 @@ private async Task CollectCodeFixActions(CodeFixContext context)
// TODO: This is a horrible hack! However, remove unnecessary usings only
// responds for diagnostics that are produced by its diagnostic analyzer.
// We need to provide a *real* diagnostic engine to address this.
if (codeFix.ToString() != CodeActionHelper.RemoveUnnecessaryUsingsProviderName)
if (codeFix.GetType().FullName != CodeActionHelper.RemoveUnnecessaryUsingsProviderName)
{
if (!diagnosticIds.Any(id => codeFix.FixableDiagnosticIds.Contains(id)))
{
Expand Down Expand Up @@ -185,7 +191,7 @@ private async Task CollectRefactoringActions(CodeRefactoringContext context)
}
}

private IEnumerable<AvailableCodeAction> ConvertToCodeActionAndParents(IEnumerable<CodeAction> actions)
private IEnumerable<AvailableCodeAction> ConvertToAvailableCodeAction(IEnumerable<CodeAction> actions)
{
var codeActions = new List<AvailableCodeAction>();

Expand Down

0 comments on commit 8396cee

Please sign in to comment.