Gooz
Gooz

Reputation: 1136

Three gray dots under variable names in Visual Studio

Two variable names with three gray dots under each of them

What do these three gray dots mean? I recently updated to Visual Studio 2017, and I haven't ever seen them in other versions of VS.

Upvotes: 29

Views: 13332

Answers (3)

hanxu
hanxu

Reputation: 51

since it's quite unnoticeable, i always prefer to set a more colorful color for it. it's called "Suggesion ellipses (...)" in Display items.

Upvotes: 0

Will Croxford
Will Croxford

Reputation: 477

Just to make doubly clear for newish programmers, these are not in any sense error messages. They are merely suggestions for more "readable and efficient" code as @Oleksander states.

Some may not be the best advice for your application, unlike warning or error messages, which almost 100% are in my case at least.

I had suggestion in a Unity game engine C# application to make a variable "readonly". I'm not sure in my case it makes practical difference whether this is readonly or not, as in this case I think fairly obvious in the context: a private variable which is serialized and can be set in game's editor program, nobody likely to create new method in this game scene manager class to alter/assign this variable. Likewise it gave a suggestion to create property for a class private field, which I think extra code overkill.

At the least these are low priority messages to action.

Suppressing 3 Dot Symbols in Visual Studio

If you right click and read through one of these suggestions, you can find there is option to suppress these messages in global project file, with various optional parameters. So eg in my case, now I don't want any readonly message suggestions for whole project (welcome correct me anyone more experienced if this is bad idea!), so in the root of project, same level as .sln solution file, .csproj files, .git file in my case for C# project, it saves file called "GlobalSuppressions.cs". Root location and this exact file name is presumably crucial.

I guess if you want stop future coders / future you from fretting or spending time on these 3 dot messages when you think waste of time, could be useful. In my case, to get rid of all "readonly" keyword suggestions in this project, code is (comments are VS auto comments):

// This file is used by Code Analysis to maintain SuppressMessage 
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given 
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier")]

Upvotes: 3

Oleksandr Kobylianskyi
Oleksandr Kobylianskyi

Reputation: 3380

They indicate suggestion from Visual Studio to refactor your code to be simpler, more readable and efficient. See Quick Actions and Refactorings section of the Visual Studio 2017 (version 15.0) Release Notes.

Upvotes: 28

Related Questions