Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractSpellCheckCodeFixProvider depends on IDE completion options #58745

Closed
Tracked by #58717
tmat opened this issue Jan 10, 2022 · 6 comments
Closed
Tracked by #58717

AbstractSpellCheckCodeFixProvider depends on IDE completion options #58745

tmat opened this issue Jan 10, 2022 · 6 comments

Comments

@tmat
Copy link
Member

tmat commented Jan 10, 2022

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
};

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 10, 2022
@tmat
Copy link
Member Author

tmat commented Jan 10, 2022

@CyrusNajmabadi What's the logic behind using completion items in spell checker? Should the spell checker use constant, non-configurable set of completion options rather then reading them from the solution options?

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi What's the logic behind using completion items in spell checker?

Basically, the idea is: completion already is the reverse side of this process. It informs us as to what names we already think are valid in this location (through all of our completion logic systems). So if you misspell something, we can just use completion to guess as to what they may have meant instead.

Should the spell checker use constant, non-configurable set of completion options rather then reading them from the solution options?

I think a constant set of options is entirely fine.

@tmat
Copy link
Member Author

tmat commented Jan 10, 2022

Sounds reasonable.

@tmat
Copy link
Member Author

tmat commented Jan 10, 2022

@sharwell

We do have other code fix providers that depend on IDE options, e.g. Add Import.
Do we explicitly distinguish between code fix providers that are expected to be only invoked from IDE and those we want to potentially invoke from dotnet-format?

@tmat tmat mentioned this issue Jan 11, 2022
73 tasks
@jinujoseph jinujoseph added Concept-Continuous Improvement and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 13, 2022
@jinujoseph jinujoseph added this to the 17.2 milestone Jan 13, 2022
@sharwell
Copy link
Member

this code fix provider will behave differently when executed from build vs IDE.

Code fixes are only executed in the IDE.

Analyzers execute in both, but NuGet-installed analyzers are blocked from accessing the IDE definitions of options.

@jinujoseph jinujoseph modified the milestones: 17.2, 17.3 May 5, 2022
@arunchndr arunchndr modified the milestones: 17.3, 17.6 P2 Jan 17, 2023
@arunchndr arunchndr modified the milestones: 17.6 P2, Backlog Oct 29, 2024
@CyrusNajmabadi
Copy link
Member

Closing out as by design.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants