Page 24 - MSDN Magazine, November 2017
P. 24

Figure 7 Adding a Code Snippet
Notice that the $ symbol is used to mark identifiers for replace- ment, whereas the $selected$$end$ expression delimits the current snippet. When you mark identifiers for replacement, you can also provide additional information on the identifier itself, such as its default value and a tooltip that describes its meaning, in the boxes on the right side of the dialog. When you’re done, simply click OK and close the Preferences dialog. At this point, your new code snippet is in the snippet library and ready to be used in the code editor through IntelliSense. It’s worth noting that you can edit existing snippets to assign a keyboard shortcut if one’s not already available. This allows you to type the keyboard shortcut within the code editor and insert a snippet faster. If you’re like me and use code snippets a lot, having the option to create them from within the IDE will save you a huge amount of time.
Adding Custom Languages
One of the things you’ll love in Visual Studio for Mac is the ability to add new languages that aren’t included out of the box, whose grammar is based on the Text- Mate and Sublime Text de facto standards. In fact, Visual Studio for Mac supports both standards and allows adding language bundles offering editing fea- tures such as syntax colorization, code snippets and word completion. For example, suppose you want to add syntax support for editing Swift files, which could be very useful on a Mac. In either TextMate or Sublime Text, you install a Swift language bundle and then export the package of the language bundle to disk. Then you can import the language bundle into Visual Studio for Mac. To accomplish this, you use the Language Bundles node of the Preferences dialog. Here you’ll be able to click Add and select the language package exported before. At this point, you’ll be able to open .swift files (or other file types depending on the bundle you imported) and to take advantage of
features such as syntax colorization and code blocks folding.
One of the things you’ll love in Visual Studio for Mac is the ability to add new languages that aren’t included out of the box.
The code editor also lets you insert code snippets if the language bundle you selected contains any. Obviously, Visual Studio for Mac doesn’t support compiling source files or building and publishing
applications based on external language bundles. What you can do instead is automate the execution of external tools, such as compilers, with the Edit Custom Tools command in the Options menu.
Debugging Productivity
with Pads and the Debug Class
Debugging is tremendously important and Visual Studio for Mac ships with the kind of first-class debugging tools every developer needs to build high-quality applications in a productive way. The official documentation (bit.ly/2xgJkx0) describes the most commonly used tools, such as breakpoints, data visualizers and conditional flow control. I’m going to describe some other nice features you might want to know about, especially if you’re familiar with debugging in Visual Studio on Windows and you expect to see the same tools on the Mac. Let’s start with the System.Diag- nostics.Debug class, which lets you print the evaluation of an expression to the Application
Visual Studio
Figure 8 Creating a Custom Code Snippet 20 msdn magazine






















































































   22   23   24   25   26