C# auto-completion should not show type names after readonly
and ref
in namespace scope.
#67061
Labels
readonly
and ref
in namespace scope.
#67061
Summary
Transferred from #66948.
When you type
public readonly str
in a namespace,public readonly string
is selected as the first candidate over the desiredpublic 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
andref
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
andref
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
andref
.Alternative Designs
No alternative design proposed.
The text was updated successfully, but these errors were encountered: