Skip to content

AbstractSpellCheckCodeFixProvider depends on IDE completion options #58745

@tmat

Description

@tmat

The code fix provider reads CompletionOptions from Solution snapshot. These options are not configurable via .editorconfig, only in the IDE. Therefore this code fix provider will behave differently when executed from build vs IDE.

private async Task CreateSpellCheckCodeIssueAsync(
CodeFixContext context, SyntaxToken nameToken, bool isGeneric, CancellationToken cancellationToken)
{
var document = context.Document;
var service = CompletionService.GetService(document);
// Disable snippets and unimported types from ever appearing in the completion items.
// - It's very unlikely the user would ever misspell a snippet, then use spell-checking to fix it,
// then try to invoke the snippet.
// - We believe spell-check should only compare what you have typed to what symbol would be offered here.
var options = CompletionOptions.From(document.Project.Solution.Options, document.Project.Language) with
{
SnippetsBehavior = SnippetsRule.NeverInclude,
ShowItemsFromUnimportedNamespaces = false,
IsExpandedCompletion = false,
TargetTypedCompletionFilter = false
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions