8 great features in Visual Studio 2013
In an earlier article I wrote about 10 ways to get more productive in Visual Studio. This is a follow up with new neat things coming with Visual Studio 2013.
- Open the Resolve menu when typing It happens once in a while that you haven’t included the namespace you need at the top of your file. One common example is
Tracefound inSystem.Diagnostics. If you writeTrace, Visual Studio suggestsTraceModeand other things, but noTrace. To quickly solve this, typeTracefollowed byCTRL+SPACE+.and theResolvemenu comes up where you can select to includeusing System.Diagnostics;to makeTraceavailable. Very handy… - Create a new Azure website from within VS There is no need anymore to open the Azure portal and create a website there before you publish it using Visual Studio. Now you can do it directly within. (You need to make sure you’ve installed Azure SDK 2.2 and can connect to Azure properly. You can check your connection to Azure by opening the Server Explorer window, click on Windows Azure and you should then be able to see your existing websites and other Azure things.)
- In the
Publish Webdialog click on theImportbutton. - In the next
Import Publish Settingsdialog click onNew - In the final dialog
Create a site on Windows Azure, enter the settings you want for your new website and clickCreate. Your publishing profile is now ready to be used and you can click on
Publishto upload your website, without going through the Azure portal. - In the
- Live debugging in Azure After you’ve published your website you can also, using live debugging, step through the executed code line by line as if it was on your local machine. Locate your published website under
Server Explorer->Windows Azure->Web Sites. Right-click on your website and selectAttach Debugger.
Your Visual Studio is now connected to Azure and each breakpoint you put in the code will work against the live website. - Live tracing from Azure In the same way you can do live debugging you can also make all trace messages, written in an Azure application, end up in your Visual Studio’s Output window.Add trace messages to your code simply by writing like this.
Trace.WriteLine("This is my trace message");
Don’t forget to re-publish your application if you make any changes to your code.
Locate your website under Server Explorer as you did in the previous step. Right click on it and selectView settings. ChangeApplication logging (File system)toVerboseand clickSaveas done in the picture.
Right click on the website again and this time selectView streaming logs in Output window. In the Output window you can then see all the trace messages as they are being processed.
Don’t forget to turn off Verbose debugging after having done your testing. You might end up with huge amounts of log files otherwise. - 64 bit Edit and Continue Have we been waiting for this one or what?!? Finally, by using .Net Framework 4.5.1, we can have the same edit and continue for 64 bits as we’ve been able to with 32 bit code for ages. So, good bye to this dialog!
- Return value inspection To help out the debugging process you can now easily see return values of functions being used as parameters in other function calls, for example if you nest several functions in each other.
public partial class MainWindow : Window
After you’ve stepped over line 7 (the call to
{
Random rnd = new Random();
public MainWindow()
{
InitializeComponent();
Foo(Bar() * Bar());
}
int Bar()
{
return rnd.Next(1,100);
}
void Foo(int p)
{
Console.WriteLine(p.ToString());
}
}Foo) this is what you’ll see in the Autos window. We calledBartwice inside the calling toFooand the results can be seen here. - Just my code This feature tells the debugger to only step through the code you’ve been writing yourself and ignore frameworks and other code. The system is doing this by looking at open projects,
.pbdfiles and program optimisations. For .Net Framework, this came before VS 2013, but what’s new now is that it’s available for C++ and JavaScript as well. To enable or disableJust My Code, openDebug->Options and Settings->Generaland change the value ofEnable Just My Code. - Peek a definition It’s now possible to open up a method definition without having to open that specific file. You can even open up a section located further up/down in your current file without having to leave the location you are at now. This feature is called Peek Definition and can be accessed through
ALT+F12or by right clicking the method and selectPeek Definition. Here is an example where I’m peeking on theInitializeComponent()method.
Note: If you, like I, have Telerik’s JustCode installed thenALT+F12is connected toFind all references. To change, go toTools->Customize->Keyboardand writePeekDefinitionin theShow Commands Containing:textbox. Mark theEdit.PeekDefinitioncommand and click in thePress shortcut keys:box. PressALT+F12and then click onAssign. Done! Telerik’s shortcut had to move for this new excellent feature!