Visual Studio Code running on Windows 10, with the Search function shown. | |
Developer(s) | Microsoft |
---|---|
Initial release | April 29, 2015; 4 years ago |
Stable release | 1.38.0 (September 3, 2019; 22 days ago)[±][1] |
Preview release | 1.38.0-insider (August 29, 2019; 27 days ago)[±][2] |
Repository | |
Written in | TypeScript, JavaScript, CSS |
Operating system | Windows 7 or later, OS X 10.9 or later, Linux |
Platform | IA-32, x86-64 |
Size |
|
Available in | English (US), Simplified Chinese, Traditional Chinese, French, German, Italian, Portuguese (Brazil), Japanese, Korean, Russian, Spanish[3] |
Type | Source code editor, debugger |
License | |
Website | code.visualstudio.com |
- Visual Studio Basics Tutorial
- Microsoft Visual Studio 2010 Programming Tutorial
- Microsoft Visual Studio Code Tutorial C++
- Microsoft Visual Studio Code Tutorial Pdf
Thousands of Microsoft engineers use, contribute to, and release open source every day. Search MSDN. Search all blogs. Search this blog. Visual Studio Code Extension for Arduino is now open sourced! Our team at Visual Studio IoT Tooling researched the development tools developers are using today, interviewed many developers.
Visual Studio Code is a source-code editor developed by Microsoft for Windows, Linux and macOS.[7] It includes support for debugging, embedded Git control and GitHub, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is highly customizable, allowing users to change the theme, keyboard shortcuts, preferences, and install extensions that add additional functionality. The source code is free and open source and released under the permissive MIT License.[8] The compiled binaries are freeware and free for private or commercial use.[9]
Visual Studio Code is based on Electron, a framework which is used to deploy Node.js applications for the desktop running on the Blink layout engine. Although it uses the Electron framework,[10] the software does not use Atom and instead employs the same editor component (codenamed 'Monaco') used in Azure DevOps (formerly called Visual Studio Online and Visual Studio Team Services).[11]
In the Stack Overflow 2019 Developer Survey, Visual Studio Code was ranked the most popular developer environment tool, with 50.7% of 87,317 respondents claiming to use it.[12]
History[edit]
Visual Studio Code was announced on April 29, 2015, by Microsoft at the 2015 Build conference. A Preview build was released shortly thereafter.[13]
On November 18, 2015, Visual Studio Code was released under the MIT License and its source code posted to GitHub. Extension support was also announced.[14]
On April 14, 2016, Visual Studio Code graduated the public preview stage and was released to web.[15]
Features[edit]
Visual Studio Code Insiders logo
Visual Studio Code is a source code editor that can be used with a variety of programming languages. Instead of a project system it allows users to open one or more directories, which can then be saved in workspaces for future reuse. This allows it to operate as a language-agnostic code editor for any language, contrary to Microsoft Visual Studio which uses the proprietary
.sln
solution file and project-specific project files. It supports a number of programming languages and a set of features that differs per language. Unwanted files and folders can be excluded from the project tree via the settings. Many of Visual Studio Code features are not exposed through menus or the user interface, but can be accessed via the command palette.[16]Visual Studio Code can be extended via plug-ins,[17] available through a central repository. This includes additions to the editor[18] and language support.[16] A notable feature is the ability to create extensions that add support for new languages, themes, debuggers, perform static code analysis, add code linters, using the Language Server Protocol[19] and connect to additional services.
Visual Studio Code includes multiple extensions for FTP, allowing the software to be used as a free alternative for web development. Code can be synced between the editor and the server, without downloading any extra software.
Visual Studio Code allows users to set the code page in which the active document is saved, the newline character for Windows/Linux, and the programming language of the active document. This allows it to be used on any platform, in any locale, and for any given programming language.
Language support[edit]
Visual Studio Code has out-of-the-box support for almost every major programming language. Several are included by default, for example, JavaScript, TypeScript, CSS, and HTML but other language extensions can be found and downloaded for free from the VS Code Marketplace.[20]
Language | Snippets | Syntax highlighting | Brace matching | Code folding |
---|---|---|---|---|
ActionScript[21][22] | No | Yes | Yes | Yes |
C and C++[23] | Yes | Partial | Yes | Yes |
C#[24] | Yes | Yes | Yes | Yes |
Clojure[25][26] | No | Yes | Yes | No |
CoffeeScript[27] | Yes | Yes | Yes | Yes |
CSS[28][29] | No | Yes | Yes | No |
D (Dlang)[30] | No | Yes | Yes | Yes |
Dockerfile[31] | No | Yes | Yes | No |
Erlang[32] | No | Yes | Yes | Yes |
F#[33] | Yes | Yes | Yes | Yes |
Go[34][35] | No | Yes | Yes | Yes |
Groovy[36] | Yes | Yes | Yes | No |
Handlebars[37] | No | Yes | Yes | No |
Haxe[38] | No | Yes | Yes | Yes |
HLSL[39][40] | No | Yes | Yes | No |
HTML[41] | Yes | Yes | Yes | Yes |
INI file[42] | No | Yes | Yes | No |
Java[43] | Yes | Yes | Yes | Yes |
JavaScript[44] | Yes | Yes | Yes | Yes |
Julia[45][46] | Yes | Yes | ? | ? |
JSON[47] | No | Yes | Yes | Yes |
LESS[28][48] | No | Yes | Yes | Yes |
Log file[49] | No | Yes | No | No |
Lua[50] | No | Yes | Yes | No |
Makefile[51] | No | Yes | Yes | No |
Markdown[52] | Yes | Yes | No | No |
Nim[53] | No | Yes | Yes | Yes |
Perl[54] | No | Yes | Yes | No |
PHP[55][56] | No | Yes | Yes | No |
PowerShell[57] | Yes | Yes | Yes | Yes |
Python[58] | Yes | Yes | Yes | Yes |
R[59] | No | Yes | Yes | No |
Razor[60] | No | Yes | Yes | Yes |
Ruby[61][62] | No | Yes | Yes | Yes |
Rust[63] | No | Yes | Yes | No |
SCSS[28][64] | No | Yes | Yes | Yes |
Shaderlab[39][65] | No | Yes | Yes | No |
SQL[66][67][68] | No | Yes | Yes | No |
Swift[69][70] | Yes | Yes | Yes | No |
TypeScript[71][72] | Yes | Yes | Yes | Yes |
VBScript[73] | Yes | Yes | Yes | Yes |
XML[74] | No | Yes | Yes | Yes |
YAML[75] | No | Yes | Yes | Yes |
Synapse [76] | Yes | Yes | Yes | Yes |
Ballerina [77] | Yes | Yes | Yes | Yes |
Reception[edit]
In the 2016 Developers Survey of Stack Overflow, Visual Studio Code ranked #13 among the top popular development tools, with only 7.2% of the 46,613 respondents using it.[78] However, in the 2019 Developers Survey, Visual Studio Code was ranked #1, with 50.7% of the 87,317 respondents using it.[12]
Visual Studio Code is flexible across various domains such as Java, JavaScript, Go, Node.js and even C++.[79][80][81][82]
Data collection[edit]
Visual Studio Code is a distribution of the `Code - OSS` repository with Microsoft specific customizations released under a traditional Microsoft product license [83]. Visual Studio Code collects usage data and sends it to Microsoft, although this telemetry reporting can be disabled.[84] The data is shared among Microsoft-controlled affiliates and subsidiaries and with law enforcement, per the privacy statement.[85] Because of the open-source nature of the app, it is known exactly what is collected.[specify] Upstream's binary is shipped under a proprietary licence.[86]
VSCodium is an alternative binary distribution of the software which uses only the open-source parts and omits Microsoft’s trademarks and the telemetry component, while remaining fully functional and compatible in all other regards.[87]
See also[edit]
Visual Studio Basics Tutorial
References[edit]
- ^https://github.com/Microsoft/vscode/releases
- ^'Download VS Code Insiders'. code.visualstudio.com. Microsoft. Retrieved 15 March 2019.
- ^'Visual Studio Code Display Language (Locale)'. code.visualstudio.com. Microsoft. Retrieved 17 July 2017.
- ^'LICENSE.txt'. github.com/Microsoft/vscode. Microsoft. 17 November 2015.
- ^'Download Visual Studio Code'. code.visualstudio.com. Microsoft. Retrieved 16 August 2016.
- ^'Microsoft Software License Terms'. code.visualstudio.com. Microsoft. Retrieved 16 August 2016.
- ^Lardinois, Frederic (April 29, 2015). 'Microsoft Launches Visual Studio Code, A Free Cross-Platform Code Editor For OS X, Linux And Windows'. TechCrunch.
- ^Comment on Menu license links to non Open Source license, VS Code Repository on Github
- ^VS Code FAQ, VS Code, 'VS Code is free for private or commercial use.'
- ^'Microsoft's new Code editor is built on Google's Chromium'. Ars Technica. Retrieved 18 November 2015.
- ^'Monaco Editor'. microsoft.github.io/monaco-editor.
- ^ ab'Developer Survey Results 2019 - Most Popular Development Environments'. StackOverflow Insights. Stack Exchange. Retrieved 10 April 2019.
- ^Montgomery, John (April 29, 2015). 'BUILD 2015 News: Visual Studio Code, Visual Studio 2015 RC, Team Foundation Server 2015 RC, Visual Studio 2013 Update 5'.
- ^'Visual Studio now supports debugging Linux apps; Code editor now open source'. Ars Technica. Retrieved 18 November 2015.
- ^'Visual Studio Code editor hits version 1, has half a million users'. Ars Technica. Condé Nast. 15 April 2016.
- ^ ab'Language Support in Visual Studio Code'. Visual Studio Code. October 10, 2016. Retrieved 2016-10-12.
- ^'Extending Visual Studio Code'. Visual Studio Code. October 10, 2016. Retrieved 2016-10-12.
- ^'Managing Extensions in Visual Studio Code'. Visual Studio Code. October 10, 2016. Retrieved 2016-10-12.
- ^'Creating Language Servers for Visual Studio Code'. Retrieved 2017-02-27.
- ^'Programming Languages, Hundreds of programming languages supported'. Microsoft.
- ^'ActionScript & MXML in Visual Studio Code'. Bowler Hat LLC. Retrieved 2019-02-21.
- ^Bowler Hat LLC. 'ActionScript & MXML Extension'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'C/C++ for Visual Studio Code (Preview)'. Microsoft. Retrieved 2019-02-21.
- ^'Working with C# in VS Code'. Microsoft. Retrieved 2019-02-21.
- ^Andrey Lisin. 'Clojure support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Better Than Tomorrow. 'Calva: Clojure & Clojurescript Interactive Programming'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Yucheng Chuang. 'Coffeescript support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^ abc'CSS, SCSS and Less'. Microsoft. Retrieved 2019-02-21.
- ^'6 Awesome CSS Extensions for VS Code'. Scotch Tutorials. Retrieved 2019-02-21.
- ^WebFreak. 'D Programming Language (code-d)'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'Working with Docker in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^'Erlang Support for Visual Studio Code'. Retrieved 2019-04-23.
- ^'Get Started with F# in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^'Go in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^'Debugging Go Code with Visual Studio Code'. Scotch Tutorials. Retrieved 2019-02-21.
- ^Marlon Franca. 'Groovy support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^André Junges. 'Handlebars support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Nadako. 'Haxe support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^ abSlevesque. 'Shader languages support for VS Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Tim G. Jones. 'HLSL Tools for Visual Studio'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'HTML in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^David Wang. 'INI for VSCode'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'Java in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^'JavaScript in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^https://marketplace.visualstudio.com/items?itemName=julialang.language-julia
- ^'How to setup Julia in VS code?'. Stack Overflow. Retrieved 2018-07-02.
- ^'Editing JSON with Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^Mads Kristensen. 'LESS Compiler for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Emil Åström. 'Log File Highlighter for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Trix NZ. 'Lua support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Technosophos. 'Make support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'Markdown and Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^Konstantin Zaitsev. 'Nim for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-04-07.
- ^Henrik Sjööh. 'Perl support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'PHP in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^DEVSENSE. 'PHP support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'PowerShell in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^'Python in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^Yuki Ueda. 'R support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'Razor support in Visual Studio Code now in Preview'. Microsoft Blogs. Retrieved 2019-02-21.
- ^Peng Lv. 'Ruby support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Will Velida. 'Using Visual Studio Code for Ruby Development'. Medium. Retrieved 2019-02-21.
- ^Rust Team. 'Rust support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Ritwick Dey. 'Live Sass Compiler for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Amlovey. 'Shaderlab for VS Code Free'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'Transact-SQL in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^Matheus Teixeira. 'SQLTools - Database tools'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'Use Visual Studio Code to create and run Transact-SQL scripts on Linux'. Microsoft. Retrieved 2019-02-21.
- ^'Swift Development with Visual Studio Code'. NSHipster. Retrieved 2019-02-21.
- ^Martin Kase. 'Swift Language support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^'TypeScript in Visual Studio Code'. Microsoft. Retrieved 2019-02-21.
- ^'400 TypeScript extensions for VS Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Darfka. 'VBScript support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Josh Johnson. 'XML Formatting, XQuery, and XPath Tools for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^Red Hat Inc. 'YAML support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-02-21.
- ^WSO2 Inc. 'Synapse support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2019-05-09.
- ^Ballerina. 'Ballerina support for Visual Studio Code'. Visual Studio Marketplace. Retrieved 2018-04-27.
- ^'Developer Survey Results 2016'. Stack Overflow Insights. Stack Exchange. Retrieved 7 April 2018.
- ^Kanjilal, Joydip (2015-05-06). 'Visual Studio Code: A fast, lightweight, cross-platform code editor'. InfoWorld.
- ^Bisson, Simon (2018-09-11). 'It's gotten a little easier to develop PWAs in Windows'. InfoWorld.
- ^Krill, Paul (2018-02-24). 'What's new in Microsoft Visual Studio Code'. ChannelWorld.
- ^Wanyoike, Michael (2018-06-06). 'Debugging JavaScript Projects with VS Code & Chrome Debugger'. SitePoint.
- ^https://code.visualstudio.com/docs/supporting/faq#_what-is-the-difference-between-the-vscode-repository-and-the-microsoft-visual-studio-code-distribution
- ^'Visual Studio Code FAQ'. code.visualstudio.com. Microsoft. Archived from the original on 28 August 2016. Retrieved 4 November 2016.
VS Code collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more. If you don’t wish to send usage data to Microsoft, you can set the telemetry.enableTelemetry setting to false.
- ^'Microsoft Enterprise and Developer Privacy Statement'. privacy.microsoft.com. Microsoft. Archived from the original on 4 November 2016. Retrieved 4 November 2016.
- ^https://github.com/Microsoft/vscode/tree/master/src/vs/platform/telemetry
- ^binary releases of VS Code without MS branding/telemetry/licensing: VSCodium/vscodium, VSCodium, 2019-03-17, retrieved 2019-03-18
External links[edit]
- Official website
- Visual Studio Code on GitHub
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Visual_Studio_Code&oldid=917811809'
-->This article introduces the features of the Visual Studio debugger in a step-by-step walkthrough. If you want a higher-level view of the debugger features, see First look at the debugger. When you debug your app, it usually means that you are running your application with the debugger attached. When you do this, the debugger provides many ways to see what your code is doing while it runs. You can step through your code and look at the values stored in variables, you can set watches on variables to see when values change, you can examine the execution path of your code, see whether a branch of code is running, and so on. If this is the first time that you've tried to debug code, you may want to read Debugging for absolute beginners before going through this article.
Although the demo app is C#, most of the features are applicable to C++, Visual Basic, F#, Python, JavaScript, and other languages supported by Visual Studio (F# does not support Edit-and-continue. F# and JavaScript do not support the Autos window). The screenshots are in C#.
In this tutorial, you will:
- Start the debugger and hit breakpoints.
- Learn commands to step through code in the debugger
- Inspect variables in data tips and debugger windows
- Examine the call stack
Prerequisites
You must have Visual Studio 2019 installed and the .NET desktop development workload.
You must have Visual Studio 2017 installed and the .NET desktop development workload.
If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.
If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.
If you need to install the workload but already have Visual Studio, go to Tools > Get Tools and Features..., which opens the Visual Studio Installer. The Visual Studio Installer launches. Choose the .NET desktop development workload, then choose Modify.
Create a project
- Open Visual Studio.Press Esc to close the start window. Type Ctrl + Q to open the search box, type console, choose Templates, then choose Create new Console App (.NET Framework) project. In the dialog box that appears, type a name like get-started-debugging, and then choose Create.From the top menu bar, choose File > New > Project. In the left pane of the New project dialog box, under Visual C#, choose Windows Desktop, and then in the middle pane choose Console App (.NET Framework). Then, type a name like get-started-debugging and click OK.If you don't see the Console App (.NET Framework) project template, go to Tools > Get Tools and Features..., which opens the Visual Studio Installer. Choose the .NET desktop development workload, then choose Modify.Visual Studio creates the project.
- In Program.cs, replace the following codewith this code:
Start the debugger!
- Press F5 (Debug > Start Debugging) or the Start Debugging button in the Debug Toolbar.F5 starts the app with the debugger attached to the app process, but right now we haven't done anything special to examine the code. So the app just loads and you see the console output.In this tutorial, we'll take a closer look at this app using the debugger and get a look at the debugger features.
- Stop the debugger by pressing the red stop button.
Set a breakpoint and start the debugger
- In the
foreach
loop of theMain
function, set a breakpoint by clicking the left margin of the following line of code:shape.Draw()
A red circle appears where you set the breakpoint.Breakpoints are the most basic and essential feature of reliable debugging. A breakpoint indicates where Visual Studio should suspend your running code so you can take a look at the values of variables, or the behavior of memory, or whether or not a branch of code is getting run. - Press F5 or the Start Debugging button , the app starts, and the debugger runs to the line of code where you set the breakpoint.The yellow arrow represents the statement on which the debugger paused, which also suspends app execution at the same point (this statement has not yet executed).If the app is not yet running, F5 starts the debugger and stops at the first breakpoint. Otherwise, F5 continues running the app to the next breakpoint.Breakpoints are a useful feature when you know the line of code or the section of code that you want to examine in detail.
Navigate code in the debugger using step commands
Mostly, we use the keyboard shortcuts here, because it's a good way to get fast at executing your app in the debugger (equivalent commands such as menu commands are shown in parentheses).
- While paused in the
shape.Draw
method call in theMain
method, press F11 (or choose Debug > Step Into) to advance into code for theRectangle
class.F11 is the Step Into command and advances the app execution one statement at a time. F11 is a good way to examine the execution flow in the most detail. (To move faster through code, we show you some other options also.) By default, the debugger skips over non-user code (if you want more details, see Just My Code). - Press F10 (or choose Debug > Step Over) a few times until the debugger stops on the
base.Draw
method call, and then press F10 one more time.Notice this time that the debugger does not step into theDraw
method of the base class (Shape
). F10 advances the debugger without stepping into functions or methods in your app code (the code still executes). By pressing F10 on thebase.Draw
method call (instead of F11), we skipped over the implementation code forbase.Draw
(which maybe we're not interested in right now).
Navigate code using Run to Click
- In the code editor, scroll down and hover over the
Console.WriteLine
method in theTriangle
class until the green Run to Click button appears on the left. The tooltip for the button shows 'Run execution to here'.NoteThe Run to Click button is new in Visual Studio 2017. If you don't see the green arrow button, use F11 in this example instead to advance the debugger to the right place. - Click the Run to Click button .Using this button is similar to setting a temporary breakpoint. Run to Click is handy for getting around quickly within a visible region of app code (you can click in any open file).The debugger advances to the
Console.WriteLine
method implementation for theTriangle
class.While paused, you notice a typo! The output 'Drawing a trangle' is misspelled. We can fix it right here while running the app in the debugger.
Edit code and continue debugging
- Click into 'Drawing a trangle' and type a correction, changing 'trangle' to 'triangle'.
- Press F11 once and you see that the debugger advances again.NoteDepending on what type of code you edit in the debugger, you may see a warning message. In some scenarios, the code will need to recompile before you can continue.
Step out
Let's say that you are done examining the
Draw
method in the Triangle
class, and you want to get out of the function but stay in the debugger. You can do this using the Step Out command.- Press Shift + F11 (or Debug > Step Out).This command resumes app execution (and advances the debugger) until the current function returns.You should be back in the
foreach
loop in theMain
method.
Restart your app quickly
Click the Restart button in the Debug Toolbar (Ctrl + Shift + F5).
Microsoft Visual Studio 2010 Programming Tutorial
When you press Restart, it saves time versus stopping the app and restarting the debugger. The debugger pauses at the first breakpoint that is hit by executing code.
The debugger stops again at the breakpoint you set, on the
shape.Draw()
method.Inspect variables with data tips
Features that allow you to inspect variables are one of the most useful features of the debugger, and there are different ways to do it. Often, when you try to debug an issue, you are attempting to find out whether variables are storing the values that you expect them to have at a particular time.
- While paused on the
shape.Draw()
method, hover over theshape
object and you see its default property value, which is the object typeRectangle
. - Expand the
shape
object to see its properties, such as theHeight
property, which has a value of 0. - Press F10 (or Debug > Step Over) a few times to iterate once through the
foreach
loop, pausing again onshape.Draw()
. - Hover over the shape object again, and this time you see that you have a new object with a type
Triangle
.Often, when debugging, you want a quick way to check property values on variables, to see whether they are storing the values that you expect them to store, and the data tips are a good way to do it.
Inspect variables with the Autos and Locals windows
- Look at the Autos window at the bottom of the code editor.If it is closed, open it while paused in the debugger by choosing Debug > Windows > Autos.
- Expand the
shapes
object.In the Autos window, you see variables and their current value. The Autos window shows all variables used on the current line or the preceding line (Check documentation for language-specific behavior). - Next, look at the Locals window, in a tab next to the Autos window.The Locals window shows you the variables that are in the current scope, that is, the current execution context.
Set a watch
- In the main code editor window, right-click the
shapes
object and choose Add Watch.The Watch window opens at the bottom of the code editor. You can use a Watch window to specify a variable (or an expression) that you want to keep an eye on.Now, you have a watch set on theshapes
object, and you can see its value change as you move through the debugger. Unlike the other variable windows, the Watch window always shows the variables that you are watching (they're grayed out when out of scope).
Examine the call stack
Microsoft Visual Studio Code Tutorial C++
- While paused in the
foreach
loop, click the Call Stack window, which is by default open in the lower right pane.If it is closed, open it while paused in the debugger by choosing Debug > Windows > Call Stack. - Click F11 a few times until you see the debugger pause in the
Base.Draw
method for theTriangle
class in the code editor. Look at the Call Stack window.The Call Stack window shows the order in which methods and functions are getting called. The top line shows the current function (theTriangle.Draw
method in this app). The second line shows thatTriangle.Draw
was called from theMain
method, and so on.NoteThe Call Stack window is similar to the Debug perspective in some IDEs like Eclipse.The call stack is a good way to examine and understand the execution flow of an app.You can double-click a line of code to go look at that source code and that also changes the current scope being inspected by the debugger. This action does not advance the debugger.You can also use right-click menus from the Call Stack window to do other things. For example, you can insert breakpoints into specified functions, advance the debugger using Run to Cursor, and go examine source code. For more information, see How to: Examine the Call Stack.
Change the execution flow
- With the debugger paused in the
Circle.Draw
method call, use the mouse to grab the yellow arrow (the execution pointer) on the left and move the yellow arrow up one line to theConsole.WriteLine
method call. - Press F11.The debugger reruns the
Console.WriteLine
method (you see this in the console window output).By changing the execution flow, you can do things like test different code execution paths or rerun code without restarting the debugger.WarningOften you need to be careful with this feature, and you see a warning in the tooltip. You may see other warnings, too. Moving the pointer cannot revert your application to an earlier app state. - Press F5 to continue running the app.Congratulations on completing this tutorial!
Next steps
Microsoft Visual Studio Code Tutorial Pdf
In this tutorial, you've learned how to start the debugger, step through code, and inspect variables. You may want to get a high-level look at debugger features along with links to more information.