Page 20 - MSDN Magazine, November 2017
P. 20

VISUAL STUDIO
Code Editing and
Debugging in
Visual Studio for Mac
Alessandro Del Sole
Visual Studio for Mac is the powerful, new native development environment from Microsoft that perfectly embodies the company’s mobile-first, cloud-first vision. It helps you build cross-platform apps with Xamarin and .NET Core—and games with Unity—using your existing .NET skills and your favorite program- ming languages, such as C# and F#. You’ll find an introduction to Visual Studio for Mac at msdn.com/magazine/mt790182. In this article, I’ll focus on some powerful features in the code editor and the debugging tools that will help you increase your productivity.
A Roslyn-Powered Code Editor
Visual Studio for Mac allows you to write code in C# and F# on macOS. This is possible because the IDE leverages the .NET Compiler Platform, also known as Project “Roslyn” (github.com/dotnet/roslyn). Roslyn provides open source, cross-platform .NET compilers that
expose rich code analysis APIs. As in Visual Studio 2015 and 2017 on Windows, Roslyn powers the code editor in Visual Studio for Mac, providing an enhanced coding experience with syntax colorization, IntelliSense, live code issue detection, fixes and refac- torings. The official documentation explains how to use code fixes and refactorings in general (bit.ly/2jKt69D), so in this article I’ll focus more specifically on features and capabilities such as generating types, removing redundant code, navigating code, adding support for custom languages and code snippets. All of these features are available to both Xamarin and .NET Core projects.
Roslyn provides open source, cross-platform .NET compilers that expose rich code analysis APIs.
Generating Types On-the-Fly
One of the nicest productivity features in the code editor is the ability to generate new types while coding, without losing your focus on the active editor. For example, you can write the name of a type that doesn’t exist yet, and when the code editor highlights the type name as a code issue, you can right-click it (or press Alt+Enter), select Quick Fix | Generate Type. Figure 1 shows an example based on generating a type called Person.
This article discusses:
• Refactoring redundant code and generating types on-the-fly • Navigating between code files and code blocks
• Working with built-in and custom code snippets
• Support for custom languages
• Productivity tips for the built-in Debug pads Technologies discussed:
Visual Studio for Mac
16 msdn magazine
















































































   18   19   20   21   22