20

In Visual Studio (2013/2015/2017), the Document Outline window for C# files is always empty ("There are no items to show for the selected document."). It seems that this functionality is not (not yet / no more) implemented.

But then, how do I view the structure of the file? Is there any extension which implements this functionality?

  • showing only the selected/opened file
  • show regions
  • move/rename members
  • show documentation

Using the Solution Explorer and Class View are NOT the solution. In the old Visual Studio 2003, I did use a self written Add-In, because it was easy to read the structure. (There were also other tools but I cannot find them anymore). So I ask here which solution you know. :-)

EDIT: Similar question also found: How to show code outline in Visual Studio?

UPDATE: After 10 years the feature has finally arrived in VS 2022

Kux
  • 1,362
  • 1
  • 16
  • 31
  • 2
    I never understood the purpose of features like this. There's a *huge* code viewer window designed to let you "view the structure of the file". Why would you need some small, auxiliary view? If you can't figure out the outline of the code at a glance, it is poorly formatted. – Cody Gray - on strike Jul 17 '14 at 12:08
  • 4
    Microsoft has developed the outline window to get a fast overview and fast navigation. So we don't need to discus about the purpose. I don't need an extra tool I would use the existing one, but it is not implemented for C# (and also for other files) – Kux Jul 18 '14 at 05:11
  • 3
    Disabled now in 17.4.4 https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes#17.4.4 – MarkD Jan 10 '23 at 20:43
  • @MarkD Do you happen to know why it is now disabled? – Donny Kwitty Jan 10 '23 at 22:02
  • No - I tried to look around but did not see anything obvious in search results - I just saw the announcement. – MarkD Jan 11 '23 at 01:12

5 Answers5

16

This feature has been added in Visual Studio 2022 17.4.0:

You can now easily view a file’s structure at a glance in the Document Outline window. The Document Outline window displays the symbol tree of the file in the editor helping you quickly navigate and edit project files. You can open Document Outline by going to View > Other Windows > Document Outline or by using the shortcut Ctrl+Alt+T.


Update: This feature was disabled in v17.4.4 for the following reason:

After we released 17.4, we found some significant performance problems with the C# implementation of Document Outline that we didn’t catch during preview usage. We’ve temporarily disabled the feature, and are spending more time working on it to address these issues. These changes are larger than we’d usually like to include in a revision release, and need more bake time, so 17.4.3 [sic] onwards & 17.5 will both ship with the feature disabled. I know this is disappointing, but we have it back in no time and enabled in a future VS update.

Heinzi
  • 167,459
  • 57
  • 363
  • 519
  • 3
    Ohh, I have not even noticed. Thanks. It took 10 years of development time ;-) – Kux Nov 14 '22 at 14:23
  • @kux: I noticed it in the Release Notes, asked myself *"Why in the world would I need this? I can already see this information in Solution Explorer!"*, googled for "Document Outline" to find more information, and, thus, stumbled upon your question. – Heinzi Nov 14 '22 at 14:36
  • 1
    Just because you don't know what you're going to use it for doesn't mean no one knows or needs it. I don't understand why some still think they are the center of the world ;-) There are good reasons to use this. For example, I use it to easily structure my file. Sure, there is another way, otherwise you had not been able to work for the last 10 years, but it is easier that way. – Kux Nov 14 '22 at 14:46
  • In version 17.2.6 this is also already available, so the release note are to late ;-) – Kux Nov 14 '22 at 14:49
  • @kux: I didn't want to imply that no one needed it - if that were the case, MS would not have spent time implementing it. ;-) My question was one of genuine curiosity, since the release notes did not make clear to me what I could do with the new window that I couldn't already do with the Solution Explorer window. – Heinzi Nov 14 '22 at 15:28
  • 2
    (a) In Document outline, you have always the current file, The Solution explorer has all files. but you have to expand. and the more you expand, the more confusing the solution explorer becomes. whereas it is already confusing for larger projects without file contens. So 2 lists are better as one tree. one for the solution, one for the current file. (b) In document outline you can move members and this without selecting the code first. – Kux Nov 15 '22 at 21:21
  • Amazing, that I saw this in the release notes, forget where it was, spent ages looking, turned to google and eventually dug up this answer. Thank you! – Jaycee Dec 02 '22 at 10:33
  • In version 17.4.4 they disabled it again! Does anyone know why? – Vladislav Borovikov Jan 22 '23 at 14:33
  • 1
    @VladislavBorovikov: Because [it's buggy](https://developercommunity.visualstudio.com/t/document-outline-function-so-slow/10201114) and they need more time to fix it. I'll update my answer with details. – Heinzi Jan 22 '23 at 17:15
14

There is also CodeMaid which provides the same functionality as JetBrains Resharper, but is free.

enter image description here

enter image description here

ChrisB
  • 2,497
  • 2
  • 24
  • 43
  • 2
    +1 for a matching alternative. (compared with ReSharper, it seems to work only for code files) – Kux Aug 30 '16 at 08:59
10

The best solution I found at present is:

JetBrains ReSharper (v8.0+) has a File Structure window which shows the structure of the current file as tree (types/members) and regions are also supported.

*.cs

App.xaml

App.config

Pang
  • 9,564
  • 146
  • 81
  • 122
Kux
  • 1,362
  • 1
  • 16
  • 31
  • 5
    If you're going to mention a 3rd party product, you should mention it has a price tag. – mason Jul 16 '14 at 17:00
  • 1
    I dit not ask for free solution, but you are right, ReSharper is a non-free solution _for users which not already have ReSharper :-)_ – Kux Jul 17 '14 at 09:41
5

If you don´t have ReSharper, you can´t miss the Productivity Power Tools, made by Microsoft itself.

There's a specific version for each of Visual Studio versions. More info on these links:

They have a feature called Solution Navigator Solution Navigator

Also, there's this one that seems very interesting for bring alot of cool customizations to Visual Studio IDE, called VSCommands. It's worth to checkout their website => http://vscommands.squaredinfinity.com/features

Fernando Vieira
  • 3,177
  • 29
  • 26
  • +100! Sadly, it is VERY easy to miss this addon. Why is it not included with the IDE? Some of these featues are a must-have for any simple IDE. – Zanval Apr 02 '15 at 23:29
  • VSCommands.squaredinfinity.com site is offline. Look hear for existing codebase/comments on status of project but as of today, project appears dead as well: https://github.com/squaredinfinity/VSCommands – Doug Knudsen Apr 05 '17 at 14:21
4

It helps you look at the nested structure of certain types of files, e.g. windows forms designer file, open a form designer you should see all controls on the form shown in nested structure in the document outline window.

Xeon
  • 156
  • 8