C# variables prefixed with '@' are not correctly handled by IntelliSense

In this screenshot you can see it seems to be ignoring the ‘@’ when searching for things with the same name. Ideally `@switch` should be at the top of the list. Is there a way to change this behavior in the settings or is it a bug?

I am using Rider 2024.2.1

0
3 comments

It's strange that you are using a keyword-like naming in your code and use the “@” out of the Razor pages. 

Have a try to disable Machine Learning-Assisted Completion sorting in File | Settings | Editor | General | Code Completion, see if it helps.

0

Hi Tao Sun 

Please see https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/

Using “@” is the correct syntax for variables with the same name as a keyword. While I generally try to use a different name when possible, sometimes the best option is to use a variable name that is the same as a keyword.

And I have just tested disabling Machine Learning-Assisted Completion (as per the instructions above) and can confirm that it makes no difference.

0

Maybe it's an ignored edge case there. 

I created a YouTrack ticket for further investigation:

RIDER-116140 Use reserved keywords as variable names is not prioritized in Code Completion

0

Please sign in to leave a comment.