Visual Studio ‘15’ Preview 3 for C# and Visual Basic

One of our major focuses in Visual Studio ‘15′ is improving developer productivity inside the editor. As we develop, we all perform series of actions over and over again–like writing methods, renaming variables, changing method signatures, implementing interfaces, etc. Our goal is to help automate or reduce these tasks to a single click so that you can focus on logic rather than syntax, references, style, and formatting. You may have noticed each Visual Studio ‘15’ release enhances existing experiences to save you a little more time and effort and enables you to build faster with additional refactorings and code generation.

Download Visual Studio ’15’ Preview 3 and read the release notes for more information about what is in this release. Please check out the Visual Studio “15” Preview 3 blog post, too.

C# 7

One of the biggest productivity gains coming in Visual Studio ’15’ is from the C# language itself, with C# 7 features now “on” by default:

  • Tuples allow groups of values to be easily passed around. This is especially helpful when you want to return multiple values from a method without using out parameters. C# 7 tuples may be used as keys in a Dictionary, for example, making it really easy to combine multiple values into a single key (note: the C# 7 compiler generates efficient Equals and GetHashCode methods and, being value types, C# 7 tuples are more memory efficient than System.Tuple, resulting in fewer allocations).
  • Pattern-matching lets you declaratively test the shape and contents of a value while extracting data into variables. This makes for more expressive type tests and switch statements.
  • Local functions, ref returns, binary literals and more.

The example below demonstrates multiple C# 7 features: pattern matching, tuples, local functions and binary literals.

Share your feedback on C# 7 with us on our GitHub or tweet @roslyn, we’d love to hear what you think!

Visual Basic 15 (upcoming)

The next version of the Visual Basic language is also getting enhancements in Visual Studio ’15’. We’re hard at work finishing up the last of these at the moment and expect to have them in the one of the next Visual Studio ’15’ pre-release releases.

  • Tuples for Visual Basic are the same as for C#. The straightforwardness is truly in line with VBs design philosophy.
  • Binary literals are another great new feature in the spirit of Visual Basic. Long have programmers had to mentally map decimal and hexadecimal numbers to their binary bit patterns. Soon you will be able to express this fundamental concept of computer programming—binary—natively in VB. To support this, we’re also adding the ability to put underscores as digit group separators in the middle of numeric literals. These characters are purely cosmetic but make reading binary and other large literals much easier.

Join the discussion on Visual Basic 15 language design in this issue or this issue on the Roslyn repo, or tweet @ThatVBGuy.

IntelliSense Improvements

In Preview 3, we’ve enhanced IntelliSense to make you more productive when working in a large solution or an unfamiliar codebase. This release we’ve added an icon tray to IntelliSense that allows you to filter your member list by type (e.g., methods, properties, classes, etc.). Each filter toggle has an associated keyboard shortcut which you can discover by hovering your cursor over the icon.

IntelliSense improvements in VS '15' Preview 3

To enable this feature, go to Tools > Options > Text Editor > [C# | Visual Basic] > IntelliSense and check the options for highlighting and filtering.

More Quick Actions and Refactorings

We added the following refactorings and code actions to assist your code writing process:

  • Add braces (C# only). Allows you to add braces to the body of an if-else statement. This lets you quickly convert a single line if-statement to multiline with a single click.
    Add Braces code action
  • Convert property to method (C# and VB). Sometimes properties start to grow into functions that perform logic. This refactoring will let you transform these logic-heavy properties into methods.
    Convert Property to Method code action
  • Add missing switch/Select case (C# and VB). This action will figure out which cases you are missing in your switch/Select and add them for you.
    Add Missing switch/Select case code action

To trigger a refactoring or code action, place your cursor in the expression and use the keyboard shortcut Ctrl+. or right-click and choose Quick Actions and Refactorings.

Try out C# 7 and other features in Visual Studio ’15’ Preview 3 today! As usual, share your thoughts and feedback with us by filing issues on our Roslyn repo.

Over ‘n’ out,
Kasey Uhlenhuth, Program Manager, .NET Managed Languages