Visual Studio Code View In Browser



-->

By default, Visual Studio uses your default browser to test pages. To use a different browser or Page Inspector, right-click the page in Solution Explorer and then click either Browse With or View in Page Inspector. The Browse With lets you select a browser from a list, add new browsers to the list, or set one as the default browser. Ctrl + F1 will open the default browser. Alternatively you can hit Ctrl + shift + P to open command window and select 'View in Browser'. The html code must be saved in a file (unsaved code on the editor - without extension, doesn't work). Code-Server on Github. Related Articles. Open Source Visual Studio Code Without Trackers Launched. Sourcegraph Powers Up Your Code Repository. Insight.io - Code Intelligence on GitHub. To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

You can examine classes and their members in Visual Studio using various tool windows, including Class View, Call Hierarchy, Object Browser, and Code Definition (C++ only). These tool windows can examine code in Visual Studio projects, .NET components, COM components, dynamic-link libraries (DLL), and type libraries (TLB).

You can also use Solution Explorer to browse the types and members in your projects, search for symbols, view a method's call hierarchy, find symbol references, and more, without having to switch between multiple tool windows.

If you have Visual Studio Enterprise edition, you can use code maps to visualize the structure of your code and its dependencies across the entire solution. For more information, see Map dependencies with code maps.

Class View (Visual Basic, C#, C++)

Class View is shown as part of Solution Explorer and as a separate window. Class View displays the elements of an application. The upper pane displays namespaces, types, interfaces, enumerations, and classes, and the lower pane displays the members that belong to the type selected in the upper pane. By using this window, you can move to member definitions in the source code (or in the Object Browser if the element is defined outside your solution).

You do not have to compile a project to view its elements in Class View. The window is refreshed as you modify the code in your project.

You can add code to your project by selecting the project node and choosing the Add button to open the Add New Item dialog box. The code is added in a separate file.

If your project is checked in to source code control, every Class View element displays an icon that indicates the source code status of the file. Common source code control commands such as Check Out, Check In, and Get Latest Version are also available on the shortcut menu for the element.

Class View toolbar

The Class View toolbar contains the following commands:

NameDescription
New FolderCreates a virtual folder or subfolder in which you can organize frequently used elements. They are saved in the active solution (.suo) file. After you rename or delete an element in your code, it might appear in a virtual folder as an error node. To correct this problem, delete the error node. If you renamed an element, you can move it from the project hierarchy into the folder again.
BackNavigates to the previously selected item.
ForwardNavigates to the next selected item.
View Class Diagram (managed code projects only)Becomes available when you select a namespace or type in Class View. When a namespace is selected, the class diagram shows all the types in it. When a type is selected, the class diagram shows only that type.

Class View settings

The Class View Settings button on the toolbar has the following settings:

NameDescription
Show Base TypesBase types are displayed.
Show Project ReferencesProject references are displayed.
Show Hidden Types and MembersHidden types and members (not intended for use by clients) are displayed in light gray text.
Show Public MembersPublic members are displayed.
Show Protected MembersProtected members are displayed.
Show Private MembersPrivate members are displayed.
Show Other MembersOther kinds of members are displayed, including internal (or Friend in Visual Basic) members.
Show Inherited MembersInherited members are displayed.

Class View shortcut menu

The shortcut (or right-click) menu in Class View may contain the following commands, depending on the kind of project selected:

View
NameDescription
Go To DefinitionFinds the definition of the element in the source code, or in the Object Browser, if the element is not defined in the open project.
Browse DefinitionDisplays the selected item in the Object Browser.
Find All ReferencesFinds the currently selected object item and displays the results in a Find Results window.
Filter To Type (managed code only)Displays only the selected type or namespace. You can remove the filter by choosing the Clear Find (X) button next to the Find box.
CopyCopies the fully qualified name of the item.
Sort AlphabeticallyLists types and members alphabetically by name.
Sort by Member TypeLists types and members in order by type (such that classes precede interfaces, interfaces precede delegates, and methods precede properties).
Sort by Member AccessLists types and members in order by access type, such as public or private.
Group by Member TypeSorts types and members into groups by object type.
Go To Declaration (C++ code only)Displays the declaration of the type or member in the source code, if available.
Go To DefinitionDisplays the definition of the type or member in the source code, if available.
Go To ReferenceDisplays a reference to the type or member in the source code, if available.
View Call HierarchyDisplays the selected method in the Call Hierarchy window.

Call Hierarchy window (Visual Basic, C#, C++)

The Call Hierarchy window shows where a given method or property is called. It also lists the methods that are called from that method. You can view multiple levels of the call graph, which shows the caller-callee relationships among the methods in a specified scope.

You can display the Call Hierarchy window by selecting a method (or property or constructor) in the editor and then choosing View Call Hierarchy on the shortcut menu. The display should resemble the following image:

By using the drop-down list on the toolbar, you can specify the scope of the hierarchy: the solution, current project, or current document.

The main pane displays the calls to and from the method, and the Call Sites pane displays the location of the selected call. For members that are virtual or abstract, an Overrides method name node appears. For interface members, an Implements method name node appears.

The Call Hierarchy window does not find method group references, which include places where a method is added as an event handler or is assigned to a delegate. To find these references, use the Find All References command.

The shortcut menu in the Call Hierarchy window contains the following commands:

NameDescription
Add as New RootAdds the selected node as a new root node.
Remove RootRemoves the selected root node from the tree view pane.
Go to DefinitionNavigates to the original definition of a method.
Find All ReferencesFinds in the project all the references to the selected method.
CopyCopies the selected node (but not its subnodes).
RefreshRefreshes the information.

Object Browser

The Object Browser window displays descriptions of the code in your projects.

You can filter the components you want to view by using the drop-down list at the top of the window. Custom components can include managed code executables, library assemblies, type libraries, and .ocx files. It is not possible to add C++ custom components.

Custom settings are saved in the Visual Studio user application directory, %APPDATA%MicrosoftVisualStudio15.0ObjBrowEX.dat.

Custom settings are saved in the Visual Studio user application directory, %APPDATA%MicrosoftVisualStudio16.0ObjBrowEX.dat.

Design

The left pane of the Object Browser shows assemblies. You can expand the assemblies to display the namespaces they contain, and then expand the namespaces to display the types they contain. When you select a type, its members (such as properties and methods) are listed in the right pane. The lower right pane displays detailed information about the selected item.

You can search for a specific item by using the Search box at the top of the window. Searches are case-insensitive. Search results are displayed in the left pane. To clear a search, choose the Clear Search (X) button next to the Search box.

The Object Browser keeps track of the selections you have made, and you can navigate among your selections by using the Forward and Back buttons on the toolbar.

You can use the Object Browser to add an assembly reference to an open solution by selecting an item (assembly, namespace, type, or member) and choosing the Add Reference button on the toolbar.

Object Browser settings

By using the Object Browser Settings button on the toolbar, you can specify one of the following views:

Vs Code Launch Browser

Visual studio code view in browser 2020
NameDescription
View NamespacesDisplays namespaces rather than physical containers, in the left pane. Namespaces stored in multiple physical containers are merged.
View ContainersDisplays physical containers rather than namespaces, in the left pane. View Namespaces and View Containers are mutually exclusive settings.
Show Base TypesDisplays base types.
Show Hidden Types and MembersDisplays hidden types and members (not intended for use by clients), in light gray text.
Show Public MembersDisplays public members.
Show Protected MembersDisplays protected members.
Show Private MembersDisplays private members.
Show Other MembersDisplays other types of members, including internal (or Friend in Visual Basic) members.
Show Inherited MembersDisplays inherited members.
Show Extension MethodsDisplays extension methods.

Object Browser shortcut menu commands

The shortcut (or right-click) menu in Object Browser may contain the following commands, depending on the kind of item selected:

NameDescription
Browse DefinitionShows the primary node for the selected item.
Find All ReferencesFinds the currently selected object item and displays the results in a Find Results window.
Filter To TypeDisplays only the selected type or namespace. You can remove the filter by choosing the Clear Search button.
CopyCopies the fully qualified name of the item.
RemoveIf the scope is a custom component set, removes the selected component from the scope.
Sort AlphabeticallyLists types and members alphabetically by name.
Sort by Object TypeLists types and members in order by type (such that classes precede interfaces, interfaces precede delegates, and methods precede properties).
Sort by Object AccessLists types and members in order by access type, such as public or private.
Group by Object TypeSorts types and members into groups by object type.
Go To Declaration (C++ projects only)Displays the declaration of the type or member in the source code, if available.
Go To DefinitionDisplays the definition of the type or member in the source code, if available.
Go To ReferenceDisplays a reference to the type or member in the source code, if available.
View Call HierarchyDisplays the selected method in the Call Hierarchy window.

Code Definition window (C++)

The Code Definition window displays the definition of a selected C++ type or member in the active project. The type or member can be selected in the code editor or in a code view window.

Although this window is read-only, you can set breakpoints or bookmarks in it. To modify the displayed definition, choose Edit Definition on the shortcut menu. This opens the source file in the code editor and moves the insertion point to the line where the definition begins.

Code

Note

Starting in Visual Studio 2015, the Code Definition window can only be used with C++ code.

Code Definition shortcut menu

The shortcut (or right-click) menu in the Code Definition window may contain the following commands:

Visual Studio Code View File In Browser

NameDescription
Quick Actions and Refactorings
Rename
Generate Graph of Include Files
Peek Definition
Go To DefinitionFinds the definition (or definitions, for partial classes) and displays them in a Find Results window.
Go To Declaration
Find All ReferencesFinds the references to the type or member in the solution.
View Call HierarchyDisplays the method in the Call Hierarchy window.
Toggle Header / Code File
Run TestsIf there are unit tests in the project, runs the tests for the selected code.
Debug Tests
BreakpointInserts a breakpoint (or a tracepoint).
Run to CursorRuns the program in debug mode to the location of the cursor.
Snippet
Cut, Copy, Paste
Annotation
OutliningStandard outlining commands.
Rescan
Edit DefinitionMoves the insertion point to the definition in the code window.
Choose EncodingOpens the Encoding window so that you can set an encoding for the file.

Document Outline window

You can use the Document Outline window in conjunction with designer views, such as the designer for a XAML page or a Windows Form designer, or with HTML pages. This window displays the elements in a tree view, so that you can view the logical structure of the form or page and find controls that are deeply embedded or hidden.

See also

View

Visual Studio Code doesn't have a built-in method for launching HTML and other files in Google Chrome, but you can configure it to do so.

Get the open in browser Extension

The free open in browser extension works well. After installing it, restart Visual Studio Code and then right-click on any HTML page. You will have options to open in your default browser or choose another browser.

Note that there is a bug in Open in Browser for Version 1.29.1 of Visual Studio Code (and likely other versions as well) that prevents the right-click context menu items from showing up. However, the shortcut key (Alt+B) still works.

Visual Studio Code View In Browser 2020

See this bug report for details.

Visual Studio Code View In Browser Download

If you have trouble getting Open in Browser working, you might give the Open PHP/HTML/JS In Browser extension a try.





Comments are closed.