Can the team consider providing intellisense so that I can select a constant string literal and do "Find all references" and likewise for integer, float and other constants?
A reference to a constant is after all, a reference and I would imagine under the hood, the metadata is there to support this.
Right now we must use "Find in files" for this which is not as reliable as finding language references.
Thx
I'm pretty sure this works in Visual Studio 2017 RC.
I think @Korporal literally wants to search for the string literal. Not the symbol the string literal is assigned to.
The answer is: no, we haven't considered this at all. However, it would be fairly simple for you to do such a thing yourself with an extension that accessed the Roslyn services at runtime.
@CyrusNajmabadi,
If it's simple, perhaps you could write a nice blog post (assuming you blog) showing how to write such a thing? 馃槈
It should probably be a standard "Extract constant/resource" refactoring. Once you notice this code smell you typically fix it. ReSharper does this but only in a limited scope.
@Korporal
Can the team consider [...]
@CyrusNajmabadi
The answer is: no, we haven't considered this at all.
I think the question is would you please consider it; is the answer still no?
Side note but if you're after a quick jump, ReSharper has an extremely useful Go To Text feature (Ctrl+T+T+T) that searches all text: names, literals, comments; and it must do crazy indexing because it's faster than searches for names 馃槅
A reference to a constant is after all, a reference and I would imagine under the hood, the metadata is there to support this.
They do not "refer" to each other in the same sense that symbols do, they just happen to be of the same kind. You can also consider regex for that.
I think the question is would you please consider it; is the answer still no?
I don't see any reason not to do it. But it would also be extremely low priority. We could consider PRs for this though.
If it's simple, perhaps you could write a nice blog post (assuming you blog) showing how to write such a thing?
Literally, just walk all the syntax-trees and examine the .StringLiteral tokens for their .ValueText properties. :)
If anyone does want to take this as part of the core FindRefs experience, you'd probably want to add this to the bloom filters we store so that we can reduce the amount of files we search.
@CyrusNajmabadi I can take a look at it after the first PR will get accepted. :)
@CyrusNajmabadi,
I don't see any reason not to do it. But it would also be extremely low priority. We could consider PRs for this though.
Now that is a really nice idea. 馃憤
@CyrusNajmabadi Is it possible to tag it with Up for Grabs then?
@CyrusNajmabadi I can take a look at it after my first PR. :)
Nice! I still need to look at your existing one. I've just been totally swamped with teh RTM push.
@CyrusNajmabadi No problem, take your time! 馃槈
Note that extract to resource is tracked by #16624
Just to add a few more details, the "use case" here is that on large codebases that have embedded hard coded literals, it becomes very easy to change some string in some source file yet disregard other instances of the string. Once the string has changed (diverted into two strings) it no longer becomes possible to find all instances and so on.
I'd also love to see a warning about embedding literals like this, then we could also tweak our projects to elevate that warning to a compile error.
I've seen huge legacy solutions with large numbers of source files where hard coded strings were common, trying to bring this under control is just another aspect of refactoring.
I have a PR out for this now. It will find literals across both VB and C#.
@CyrusNajmabadi,
Could you provide a link to the PR, please? I'd be interested in looking through your code as a learning exercise in writing analyzers. Thanks.

:)
Note: my PR is def more complex than is necessary. I wanted to plug into our indexing service and i wanted to ensure that this could run out of proc easily.
Most helpful comment
I don't see any reason not to do it. But it would also be extremely low priority. We could consider PRs for this though.