Статьи

5 Невероятных функций в Visual Studio 2015 Preview

Автор Майкл Крамп для Telerik Mobile Blog.

Visual Studio 2015 Preview включены многие новые функции , которые способствовали активизации работы путь разработчиков со всем из Интернета и настольных компьютеров до мобильных приложений. В центре внимания оказались некоторые функции, такие как поддержка жестов в редакторе, инструменты Cordova, улучшения C ++ и новый эмулятор Android. Но есть несколько других, менее обсуждаемых функций, которые, на мой взгляд , выиграют у каждого разработчика, использующего Visual Studio 2015. С учетом сказанного, давайте прыгать прямо в!

1. Пользовательские макеты Windows

Эта функция пригодится, если вы разрабатываете на нескольких устройствах. Скажем, например, что вы используете Surface Pro для разработки на поезде домой и 23-дюймовый монитор в течение дня. Вы можете быстро переключаться между устройствами, перейдя в Window -> Apply Window Layout и выбрав тот, который вы создали ранее. У них также есть поддержка сочетаний клавиш, так что вы можете быстро переходить к своей любимой раскладке, и профиль перемещается вместе с вами, пока вы вошли в Visual Studio 2015.

Ниже приведен пример переключения между моим устройством Surface и настольным монитором. Вы заметите, что с Surface я хочу показать только файл XAML, тогда как на моем большом мониторе я хочу видеть все.

windowswitch

2. Лучший редактор кода

The code editor has been replaced with “Roslyn” to give you a new and improved code editing experience. Light bulbs are shown when you need to include fixes to your code or refactor it. Whenever you see a light bulb appear, then click it and it will give you suggestions based upon the code it has analyzed.

In this sample, it has determined that we included unnecessary “using” statements and helps remove them. Before doing so, you can generate a preview and have the changes affect the whole document, project or solution. While these features have appeared in JustCode and earlier versions of Visual Studio for years, we will be releasing a new version of JustCode for Visual Studio 2015 that will take advantage of Rosyln for enhanced productivity tools.

лампочка

3. Shared Project – “All the Things!”

How many times have you wanted to use a Shared Project outside of a Windows Universal App? Now you can! After you open Visual Studio 2015 and search for “shared” then you will see the following:

sharedproject

Go ahead and select the Visual C# Shared Project and create a class named Person.cs and add the following code:

class Person
{
    public string FirstName { get; set; }
    public Person()
    {
        FirstName = "Michael";
    }
}

Create a new Console application and reference the Shared Project that we just created. Now you can write code such as :

var person = new Person();
Console.WriteLine(person.FirstName);
Console.ReadLine();

If you run the console app, you will see it retrieved the FirstName from our Shared Project. Go ahead and add a WPF or Windows Form application and access the Person class like you normally would. This also works for class libraries as well. After I’ve added several projects, my solution explorer looks like the following:

multipleproj

Notice that the only thing I had to do was reference the Shared Project.

4. IntelliSense for Bower and NPM

If you create a new ASP.NET 5 Web Project, you will notice several things that the new project template loads as shown below.

IntelliSense for Bower and NPM

Besides a updated file structure, you now have a folder called Dependencies that contains Bower and NPM. Generally speaking, you can think of Bower for client-side packages (such as jQuery and Angular) and NPM for developer tools (such as Grunt and Gulp). Both of these package managers are controlled by JSON files found in the solution.

  • bower.json for Bower
  • config.json for NPM

If we wanted to add a library using Bower, we would simply open the bower.json file and add the package that we want. In this case, I want to add the latest version of Angular without having to go to the Angular site and manually download it and add it to my project.

DataBinding for XAML

Once added, you will see that we have the option to install/update or delete the package or view the homepage from the drop-down menu. This will come in handy as you are working with web projects.

5. Debug Lambdas

Yes, the time has finally come where we can debug lambda expressions. Let’s take a look at the following code:

List<int> elements = new List<int>() { 10, 20, 31, 40 };
// ... Find index of first odd element.
int oddIndex = elements.FindIndex(x => x % 2 != 0);
Console.WriteLine(oddIndex);

The console will return the value of 2. But what if we wanted to add a watch and perform additional analysis of the expression as shown below.

DataBinding for XAML

In this sample, we added a watch on the breakpoint and added the following code:

elements.Where(v => (int)v > 11).ToArray()

As expected, it returned 3 items that were greater than 11. This will be a lot of help as you can use this in the immediate, and other debugger windows as well. It is also supported in both C# and Visual Basic.

BONUS TIP!!! Blend for Visual Studio 2015 Actually Rocks

Blend comes with several enhancements but, by far, the one that was needed the most is the overhaul of the UI as shown below. You will quickly find that Blend includes most of the functionality that we have grown to love in Visual Studio.

Blend for Visual Studio 2015

Some of the notible features are :

  • Basic Debugging Support
  • Peek in XAML
  • Custom Windows Layouts as shown in feature #1
  • Source Control
  • NuGet
  • and finally…

XAML IntelliSense!

Blend for Visual Studio 2015

Just after a few minutes of playing with the new Blend, I can tell Microsoft is committed to making the Blend experience similar to the Visual Studio one.

More Awesomeness Coming from Visual Studio and Telerik

So far, we’ve only seen the first preview of Visual Studio 2015. With the new feedback options, I can only assume that it will get better. Since the release, we’ve been playing with the new bits, as described here. If you are looking for ways to enhance your web, desktop or mobile applications, then take a look at our DevCraft Suite. I’d also encourage you to take a look at the Telerik Platform for cross-platform mobile applications using HTML5, CSS3 and JavaScript.

Also, if I missed a featured then sound off in the comments below. I’d love to hear your feedback as you were pretty vocal in the Windows 10 post. If you need to get up to speed with everything that has happened with .NET over the past couple of weeks then I’d suggest you read Sam Basu‘s post on the “Future of .NET“. Until next time, Michael signing off.