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

C# auto-completion should not show type names after readonly and ref in namespace scope. #67061

Closed
acaly opened this issue Feb 26, 2023 · 1 comment · Fixed by #67097
Closed
Labels
Area-IDE Feature Request untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@acaly
Copy link

acaly commented Feb 26, 2023

Summary

Transferred from #66948.

When you type public readonly str in a namespace, public readonly string is selected as the first candidate over the desired public readonly struct, although C# does not allow field declaration in namespace scope.

Background and Motivation

I think the current behavior is probably because the compiler identifies readonly and ref as a "prefix of type name". However, it does not check whether such type names are allowed in the current scope.

Although this only affects a small number of cases, it sometimes becomes a problem because to get the correct public readonly struct, one needs to type in at least 4 letters of the word, or to press down arrow.

Proposed Feature

The auto-completion after keyword readonly and ref should check whether it's in namespace scope. If so, don't show type names as candidates.

There might be other cases to consider in addition to the readonly and ref.

Alternative Designs

No alternative design proposed.

@CyrusNajmabadi
Copy link
Member

Hey @acaly , feel free to open a PR here to fix this if you're interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
3 participants