Archive for the ‘Visual Studio’ Category
How to manage AllJoyn devices in C#: LIFX Color 1000 Example
In the previous video we discussed, how to onboard an AllJoyn device using Visual Studio, C# and Windows 10 AllJoyn features (How to onboard AllJoyn devices in C#: LIFX Color 1000 Example).
Today, I am going to show, how we can start working with an “onboarded” AllJoyn device.
About Extensions in Visual Studio Code
Finally, I have finished my series about VS Code. At the end I published couple videos about the most popular extensions (a short introduction, PowerShell, Google Chrome and Python extensions).
https://channel9.msdn.com/Series/Visual-Studio-Code-for-Mac-Developers/22-Python/player
ASP.NET Core and VS Code
.NET Core RC 2, ASP.NET Core RC 2 and even .NET Core SDK are available for download. I have tested if it work with Visual Studio Code and… It works great!!!
You should not use any dnx/think about available runtimes and select between mono and coreclr/understand what is dotnet package manager and so on. You can simply install .NET Core and start creating your ASP.NET applications.
My updated video about VS Code and ASP.NET is here:
And couple new videos in the series (about Express and Cordova tools):
https://channel9.msdn.com/Series/Visual-Studio-Code-for-Mac-Developers/17-Express/player
Visual Studio Code for Mac Developers 1.0
Finally, I updated all modules in my training using Visual Studio Code 1.0. Additionally, I published 6 more modules and 7 more are coming. Here is the full list of all available videos (Express, Intro to Extensions, Office Extensions, TACO, PowerShell, Google chrome Extensions and Python are coming next week):
8. A better way to integrate Code and Unity3D
11. How to deploy your site to Microsoft Azure
UWP: Profiling and debugging tools in Visual Studio 2015
I have already published a post about Live Visual Tree but Visual Studio 2015 has lots of different tools which allow you to tune your application on Universal Windows Platform. Let’s make an overview of some of these tools.
But before the start, just make sure that you switch the Enable Diagnostic Tools while debugging and PerfTip while debugging in the Debugging options. These tools should be enabled by default but it’s better to know how to disable/enable them:
Ok. Let’s talk about particular features, and I would like to start with the performance tips. Thanks to this feature you can use the breakpoints and debug mode to know exactly how much time has elapsed since the last breakpoint:
If you want to see this information for each line in your code you simply need to use debugger to go step by step through the code. But if you need to understand elapsed time for any of the blocks then you just need to set two breakpoints at the beginning and at the end of the block. So, using the performance tips you can easily locate problems with performance.
You can see that Visual Studio displays this information as tips and you can easily click these tips to navigate to Diagnostic Tools window, which is the second important tool which you can use together with performance tips:
Diagnostic Tools contains three sections. The first one shows events like information about exceptions, even if exception is caught; messages from output window which are generated by the Debug class; IntelliTrace events related to threads, assemblies etc. The next two sections show CPU utilization and usage of memory at runtime but you can easily pause the debugger and select any timeframe in order to check events and memory and CPU usage.
Additionally, you can take a snapshot of memory at any time during debugging of the application and check the number of references for each object, amount of memory etc.
The next set of tools you can find if you execute Start diagnostic tools without debugging… command.
These tools allow to collect information during runtime. Because these tools collect all information not in the debug mode, these data has better quality but you cannot check it in real time. Instead, the tools collect information about application until you stop them. Once they are stopped, the report abound the collected metrics is generated and you can analyze the data using dashboard.
Among all tools I would like to recommend Application Timeline. Thanks to this tool you can find problems with rendering and review the most critical parts of your application.
Visual Studio Tools for Unity
Lots of developers use Visual Studio like the default code editor for Unity engine for many years and looks like, since Visual Studio 2015 release, integration between both products are stronger than before. Since Unity3D 5.2, Visual Studio Community Edition 2015 is the default Unity3D code editor for developers on Windows.
First of all, both tools have cross-product installations. If you have fresh PC with Visual Studio 2015 installed you can find that New Project dialog contains a new category there – Game. You cannot use this category to create new projects because there are just links to some popular gaming frameworks including Unity.
Selecting Install Unity, Visual Studio will help you to install Unity and Visual Studio Tools for Unity:
In case of Unity installer, integration even much better: users can select and install Visual Studio Community Edition directly from Unity installer:
Pay special attention that starting with Visual Studio Community Edition announcement, game developers can use all important Visual Studio features for free including extensions (plug-ins) and debug features. If you want to download VS Community Edition separately, you can do it visiting https://www.visualstudio.com/ web site.
Visual Studio Community Edition has some licensing limitations. For example, you can use it for small teams only (up to 5 people) but if you work in a big company you can use Professional or Enterprise version of Visual Studio. In this case Unity installer will recognize existing version of Visual Studio and propose to install Visual Studio Tools for Unity only that is a bridge between Unity and Visual Studio 2015:
So, using Unity installer or Visual Studio, it’s really hard to miss installation opportunity for Microsoft Visual Studio Tools for Unity. Let’s see how to use the tools themselves.
The good news that Unity3D 5.2 has native support for Visual Studio Tools. So, you should not add any packages or something like before. So, you simply need to create a new project or open existing one. To make sure that Visual Studio is the default editor you can call Edit->Preferences menu item and open Unity Preferences window that contains information about external tools including script editor:
On this step you can start working with your Unity project, create scripts in C#, objects, assets etc. Once you want to open the project in Visual Studio you simply need to use Open in C# menu item.
It’s easy to do and Unity will open your project in Visual Studio. Let’s look at some important features that you can use there.
First of all you can use Unity Project Explorer (Shift+Alt+E):
This window is similar to Project window in Unity and can present project’s files in the same way. So, if you need to find some files very quickly you can use the same way like in Unity. Unity Project Explorer and Solution Explorer show project’s files in different ways. Especially you can see that difference for large projects.
The next two windows allows you to override MonoBehaviour class methods very quickly. You can use Ctrl+Shift+Q combinations to call Quick MonoBehaviours window. Just start typing name of the method and the window will help to select the right one:
The second window you can call using Ctrl+Shift+M combination:
Using MonoBehaviour wizard you can generate several method stubs at once.
Two more features of Visual Studio Tools for Unity is supporting shaders editing and integration with Unity output. Thanks to the first feature you can see coloring syntaxes and formatting features if you are working with shaders in Visual Studio. The second feature allows you to see Unity errors and warnings in Visual Studio error window.
Finally, the most important feature there is Debugging. You can connect to Unity Debugger using Debug -> Attach Unity Debugger menu item. Select Unity Instance window will show available Unity instances and you can select any of them:
Or you can simply click Attach to Unity button on Standard toolbar.
Once Visual Studio is connected, you can open Unity editor and use Play/Stop features. Of course, Visual Studio supports breakpoints, allows to evaluate expressions and variables and other debugging features.
XAML tools in Visual Studio 2015
Visual Studio is the best editor forever. So, it’s very hard to implement something new that can excite me but developers of Visual Studio 2015 made it and today I want to talk about several features related to XAML editor.
The first feature there is “peek window”. The feature can be used not just in XAML editor but in case of XAML it’s really valuable because it allows to do a lot of things that were not possible before. This feature allows to inject “dependent code” windows directly to my current window.
Thanks to that I can easily check styles even in generic.xaml, review definitions of controls, modify event handlers etc. And in order to do it I should not close my primary window.
You can call “peek window” using context menu or you can find this window using some features of Visual Studio 2015. For example, Visual Studio 2015 contains updated template editor. If you want to create a new template for any control you can use context menu and select Edit Template->Edit a Copy
If you use Application resources or Resource Dictionary, Visual Studio redirects you to the appropriate file. But in case if Visual Studio 2015 you continue to work with new template using the same window, editing the template in the designer and checking and modifying code using “peek window”.
Visual Studio 2015 applies color border to the visual editor in template editor mode.
One more feature in XAML editor is its ability to add named regions in XAML code like in C#. You can use the following syntaxes in order to create a marked region inside your XAML
As in C# you can collapse it:
You can use this feature in many ways: mark the existing code for some reason or create some templates for future work.
I showed three new features in XAML editor: peek window, updated template editor and marked XAML blocks. Let’s use these features to make coding more smoothly.