New Improvements to C# and Visual Basic in Visual Studio 2015

C# and Visual Basic Improvement

We are pleased to discuss some new features announced at #vsconnect. Microsoft released the next version of Visual Studio, Visual Studio 2015 Preview, on November 12-13, 2014.

The more exciting things is that this is the first public release of a version of Visual Studio that is Open Source, so the first CTP (Common Technology Preview) is available publicly, we can download it from Microsoft website. Remember, Roslyn is the next generation of .NET Compiler Platform for C# and Visual Basic.

In the conference of Visual Studio Connect(), there was a great announcement. There were new changes in C#, Visual Basic and F# as well. The core team of Microsoft has made a great change to re-implement the full language stack for C# and Visual Basic. As we know that an improved stack with cleaner architecture allows the developer to work faster and lets others build "Code Smart" tools for applications. From now we can create a richer and smarter IDE experience in Visual Studio.

In this article, as for the #vsconnect conference announcement, emphasis was on new language features, a smarter and better IDE experience, improved debugging and code aware diagnostic analyzer. The following are new features of Visual Studio 2015.

  • Microsoft improved IDE
  • New features in C#
  • New Features in Visual Basic
  • Debugging gets improved
  • Diagnostic Analyser and Code Fixes

Microsoft improved IDE

In Visual Studio 2015, the C# and Visual Basic code-focused IDE experience is significantly improved. The new key features are:

  • Refresh Core IDE
  • Code Fixes and Refactorings
  • Inline Rename

Refresh Core IDE

The #vsconnect conference has announced C# and Visual Basic IDEs. These IDEs are made of dozens of new features that developers use every day, such as syntax highlighting, IntelliSense and refactoring support.

Let's have a look at the new IDE using an example.

Colorized ToolTips

Visual Studio has supported collapsible outlining in the editor for more than a decade: Visual Studio automatically creates collapsible regions for various language constructs, such as class and method bodies. When collapsed, you've always been able to hover over them to see the hidden code presented in a plain text tooltip but in Visual Studio 2015, the tooltip now displays the code in full color and even shows the full declaration to provide more context.

1

Code Fixes and Refactorings

Another new feature is code refactoring code analysis in the new IDE, where live static code analysis and automated code refactoring is done. Let's try to understand using an example.

2

When we hover over an error or warning in the editor then it will often show a lightbulb with a tooltip explaining the problem. The lightbulb tells us there are possible fixes for the problem.

3

If you  want to see the error using the keyboard, you can press the CTRL+<dot> (in other words, CTRL and the period key) to display the light bulb.

4

In Visual Studio 2015 there are two new refactorings introduced. That is Explaining Variable and Inline Temporary Variable. This augments an existing set offered  for C#, like Rename, Extract Method and Encapsulate Field. To apply a refactoring, move the editor caret and select a relevant piece of code and press CTRL+<dot>. This should display a lightbulb with the relevant refactoring actions available to you. Alternatively, you can right-click in the editor and choose “Quick Actions” from the context menu.

8

Inline Renaming

This is a new feature for C# and Visual Basic, Inline Rename. As we have used in previous versions of Visual Studio, where we  performed a Rename operation that was generally present in a dialog where you could provide a new name. Once you supplied a name and accepted the dialog, the Rename refactoring would then go off to find all of the references to rename and do tons of work, taking minutes on a large solution. From now in Visual Studio 2015, Microsoft has removed the dialog and made rename work inline in the editor.

5

Rename : Error while conflict of the variable name.  

7 

New features in C#

  • C# 6

    The C# 6 language is introduced in Visual Studio 2015, that is the latest installment of the language. C# 6 mainly focuses on making our code cleaner without adding new fetures, also helps to remove boilerplate code and making our code cleaner. C# 6 includes some features, like the null conditional dot (?.) to make null checking fade into the background, string interpolation for easy formatting and a refactoring-safe nameof operator to get the names of program elements as text.
  • New Features in Visual Basic

    In Visual Basic, we have new features as in C#. Additionally we've rounded out many existing language features, mainly in response to user requests. ReadOnly auto-properties are a big favorite, along with multi-line string literals, comments within multiline LINQ queries, year-first date literals, partial interfaces and many more.

  • Debugging gets improved

    Debugging now has more extensive support for modern language features like LINQ queries, Lambda Expressions and Extension Methods, that can now be used in the Watch window, Immediate window, conditional breakpoints and other debugger contexts.

    As we know in the previous version of C# and Visual Basic we were not able to debug the code of LINQ, Lambda Expressions and Extention Method as well but with the new version we can do debugging on these things as well.

  • Diagnostic Analyser and Code Fixes

    Diagnostic analyzer is one of the best and helpful key new features of Visual Studio 2015 that lets a NuGet package enable custom warnings and errors in the editor live as you type the code, with automatic code fixes that can clean up those issues for us. Packages can even be bundled together as a “code-aware library” that pulls in both an API and the domain-specific analyzers to make sure that you stay on course when using it. We'll have a targeted guidance from the moment we download the NuGet package. And because these analyzers are part of our project, everyone on your team gets to see the same warnings.

Summary

In this article we saw some new features of Visual Studio 2015 and also explore the features.

Next Recommended Readings