This week at Build 2016, we released Visual Studio 2015 Update 2 and Visual Studio “15” Preview. Both releases include many new language features that you can try today. It’s safe to install both versions of Visual Studio on the same machine so that you can check out all of the new features for yourself.
New C# and VB features in Visual Studio 2015 Update 2
In Visual Studio 2015 Update 2, you’ll notice that we’ve added some enhancements to previous features as well as added some new refactorings. The team focused on improving developer productivity by cutting down time, mouse-clicks, and keystrokes to make the actions you perform every day more efficient.
Interactive Improvements
The C# Interactive window and command-line REPL, csi, were introduced in Visual Studio Update 1. In Update 2, we’ve paired the interactive experience with the editor by allowing developers to send code snippets from the editor to be executed in the Interactive window. We’ve also enabled developers to initialize the Interactive window with a project’s context.
To play with these features:
- Highlight a code snippet in the editor, right-click, and press Execute in Interactive (or Ctrl+E, Ctrl+E), as shown in the image below.
- Right-click on a project in the Solution Explorer and press Initialize Interactive with project.
Add Using/Imports Improvements
We’ve improved the Adding Using/Imports command to support “fuzzy” matching on misspelled types and to search your entire solution and metadata for the correct type—adding both a using/imports and any project/metadata references, if necessary.
You can see an example of this feature with a misspelled “WebCleint” type. The type name needs to be fixed (two letters are transposed) and the System.Net using needs to be added.
Refactorings
A couple refactorings we sprinkled in were:
- Make method synchronous
- Use null-conditional for delegate invocation
Roslyn Features
We’ve added two new compiler flags to the Roslyn compiler:
- deterministic: This switch will ensure builds with the same inputs produce the same the outputs, byte for byte. Previously, PE entries–like MVID, PDB ID and Timestamp–would change on every build but now can be calculated deterministically based on the inputs.
- publicSign: Supports a new method of signing that is similar to delay signing except it doesn’t need to add skip verification entries to your machine. Binaries can be public signed with only the public key and load into contexts necessary for development and testing. This is also known as OSS signing.
Sneak Peek: What’s in Visual Studio “15” Preview
We released a first look of Visual Studio “15” this week at Build. It is point in time view of what we’ve been working on. Some features will still change and others are still coming. It’s a good opportunity to provide feedback on the next big release of Visual Studio.
Play with C# 7 Prototypes
The guiding theme for C# 7 language design is “working with data”. While the final feature set for C# 7 is still being determined by the Language Design Committee, you can play with some of our language feature prototypes today in Visual Studio “15” Preview.
To access the language prototypes, right-click on your project in Solution Explorer > Properties > Build and type “__DEMO__” in the “Conditional compilation symbols” text box. This will enable you to play with a preview of local functions, digit separators, binary literals, ref returns, and pattern matching.
There is a known bug related to ref return IntelliSense, which can be worked around by:
- right-click on your project in Solution Explorer > Unload Project
- right-click on your project after it’s been unloaded > Edit csproj
- in the first Property Group under
add: refLocalsAndReturns - Ignore any XML schema warnings you may see
Custom Code Style Enforcement
The feature you all have been asking for is almost here! In Visual Studio “15” Preview, you can play around and give us feedback on our initial prototype for customizable code style enforcement. To see the style options we support today, go to Tools > Options > C# > Code Style. Under the General options, you can tweak “this.”, predefined type, and “var’ preferences. Today, with “var’ preferences, you can control the severity of enforcement—e.g., I can prefer “var” over explicit types for built-in types and make any violation of this squiggle as an error in the editor.
You can also add Naming rules, for instance, to require methods to be PascalCase.
Please Keep up the Feedback
Thanks for all the feedback we’ve received over the last year. It’s had a big impact on the features that I’ve described here and on others we’ve been working on. Please keep it coming. The language feedback on the open source Roslyn project has been extensive. It’s great to see a broader language community developing around the Roslyn open source project on Github.
To give feedback, try one of the following places:
- The Roslyn project, for language feedback
- Send Feedback Option Visual Studio, for Visual Studio feedback
- UserVoice , for Visual Studio suggestions
Thanks for using the product. I hope you enjoy using it to build your next app.
Over ‘n’ out
Kasey Uhlenhuth, Program Manager, Managed Languages Team