18

I'd like to exclude code-generated files from the Edit > Navigate To-list which appears when hitting Ctrl+, in Visual Studio 2013, as these files are never to be modified by me manually and in those rare cases where I want to see the contents of them, I'll use the solution browser. Is there any way to do this? They produce a lot of noise in my search and greatly reduces the value of the Navigate to-function.

Edit Nov 2016: added an image for illustration in VS 2015. Very much an issue still. The first search hit is a .g.cs file in the obj-folder:

enter image description here

Nilzor
  • 18,082
  • 22
  • 100
  • 167
  • Can you provide an example of your search and what you prefer not to be displayed? – alan Feb 20 '14 at 15:01
  • There are these VS Feedback items; sign in and upvote them if you like: https://developercommunity.visualstudio.com/t/All-in-one-Code-search-improperly-gives/10288101 and https://developercommunity.visualstudio.com/t/For-XAML-components-Go-to-all-always-/1470388 – Patrick Szalapski Feb 22 '23 at 16:11

1 Answers1

1

I assume that by "code-generated files" you are referring to files such as .designer that are also part of the solution (and found in solution explorer). After quite a bit of research into Navigate To I was unable to find any reference to such a configuration option. Currently there appears to be only 3 options for configuration (discussed in the MSDN blog below). A possible work around would be to leverage the built in filtering features of Navigate To (@, Capitalization and Whitespace) that are new to VS2013 as outlined in this MSDN blog:

http://blogs.msdn.com/b/mvpawardprogram/archive/2013/10/22/visual-studio-2013-navigate-to-improvements.aspx

Another article I found in my research: http://weblogs.asp.net/scottgu/archive/2009/10/21/searching-and-navigating-code-in-vs-2010-vs-2010-and-net-4-0-series.aspx

UPDATE: I use the ReSharper plugin and only after posting this answer realized there is a Filter results from generated files feature to exclude generated files and is discussed at the link below. Though it does not pertain to Navigate To, it may provide a satisfactory alternative:

http://www.jetbrains.com/resharper/webhelp/Reference__Options__Environment__Search_and_Navigation.html

UPDATE (12/1/2015): Now that some time has passed I decided to do a little more research and found a similar request posted on SO here. I found this to work pretty well, and VS will even save the list for you.

Community
  • 1
  • 1
alan
  • 6,705
  • 9
  • 40
  • 70
  • I was going to mention Resharper as well, as I found out about that feature today. That said, I can't get it to work. But that's a different issue: http://stackoverflow.com/questions/21933466/i-cant-get-the-filter-results-from-generated-files-to-work-in-resharper-8 . I'm accepting your answer as this seems the state of the functionality today. – Nilzor Feb 21 '14 at 17:10
  • Just a note on the resharper solution: It is highly limited: http://stackoverflow.com/questions/21933466/i-cant-get-the-filter-results-from-generated-files-to-work-in-resharper-8 Basically it does not solve my original problem – Nilzor Feb 26 '14 at 07:55
  • 1
    I just edited my question to include a screenshot from VS 2015. I'm really baffled Microsoft doesn't priortiize fixing this. BTW the SO-post you link to in the update from Dec 2015 is about the Quick Find-operation, not NavigateTo – Nilzor Nov 06 '16 at 15:02