It's been a while since we last posted, and we've been hard at work on new features for Python in Visual Studio 2017. Today, the first preview of the next update has been released, which you can install from visualstudio.com or by updating your existing Preview install.
In this post, we'll briefly discuss the new features in this preview, including the secret tricks and exclusive downloads you will need to enable some of them.
Ctrl+Click Go To Definition
Over the new update you should see this feature coming to most languages in Visual Studio, but we are excited that Python is one of the first to get it.
You are probably familiar with the Go To Definition feature, either through the editor context menu or the F12 shortcut key, but we have added a new way to use it. While holding the Control key down, the identifier you have the mouse over will turn into a hyperlink if it has definitions you can go to. Clicking on the item will then take you directly to the definition.
(Unfortunately, it seems that peek does not work for Python code in this first preview. We're fixing it for preview 2!)
Debugging in the Windows Subsystem for Linux
The Windows Subsystem for Linux (WSL) is an exciting new technology that lets you use a full Linux distribution on your Windows machine. This is not a virtual machine, but a subsystem similar to the way that 32-bit processes are supported on 64-bit Windows. Follow the link for instructions on how to set it up.
For this preview, we are releasing a separate extension that enables debugging in WSL. After installing this extension, you can select a new debug launcher in Python project properties. Now, when you press F5, your project will launch under WSL using the most compatible version of Python available (for example, a project using Python 3.6 will try to launch with python3.6 and then python3 before returning an error).
Once running, the debugger will automatically attach, providing the great experience you are used to getting with local or remote debugging.
One known issue is that you may see an error dialog appear as well as the Bash shell, but your project does not start. In most cases, attempting to launch again should succeed, so please try that before reporting a problem. Also note that native code debugging is not supported with WSL, even though the checkbox for it appears.
You can download the extension from here: Microsoft.PythonTools.Wsl.VS2017.vsix (64 kB)
Warnings: This is a highly experimental extension, and we're releasing it separately because we may change it dramatically when fully integrated into Visual Studio, or we may decide not to integrate it at all. You may need to manually uninstall the extension before installing future Visual Studio updates. While this extension is completely unsupported, we would love to hear your feedback on GitHub. This download will only be available for a limited time and is only compatible with Visual Studio 15.4 Preview 1.
Debug C++ project with Python
If you develop native Python extensions, you are likely familiar with our support for mixed C/Python debugging. Currently, you can only enable this on a Python project, which meant that if you were developing a C++ project that embeds Python, you could not use it.
Today we are releasing a standalone extension that adds a new debugging option to C++ projects: Python native debugging.
Selecting this debugger for your C++ project will launch with support for viewing Python types and stack frames, giving you the best experience for debugging your application.
You can download the extension from here: Microsoft.PythonTools.Debugger.VCLauncher.VS2017.vsix (331 kB)
Warnings: This is a highly experimental extension, and we're releasing it separately because we may change it dramatically when fully integrated into Visual Studio, or we may decide not to integrate it at all. You may need to manually uninstall the extension before installing future Visual Studio updates, and you may require administrative privileges to install and remove it. While this extension is completely unsupported, we would love to hear your feedback on GitHub. This download will only be available for a limited time and is only compatible with Visual Studio 15.4 Preview 1.
Disable the completion database
Remember when you installed Anaconda and we made you wait hours before giving you IntelliSense? Yeah, we aren't proud of that. Our IntelliSense is based on some really intense static analysis that infers types for every possible variable, and it takes time to get those results. But in many cases, very simple syntax analysis can provide results that will keep you productive, especially when combined with your own expertise.
So we've been working on a brand new approach that does not rely on generating a completion DB. This means that when you install a new environment or a new package, we will give you great IntelliSense immediately, without having to run the background process at all.
This new approach is very experimental right now, and we are actively working on improving the experience. It is included in the current Visual Studio 2017 Preview but disabled by default. You can tell when it is enabled because the IntelliSense dropdown will be missing from the Python Environments window.
To enable this feature, use registry editor to create a key HKEY_CURRENT_USER\Software\Microsoft\PythonTools\Experimental and add a DWORD value named NoDatabaseFactory and set its value to 1. Then restart Visual Studio.
Warnings: This is a highly experimental feature, and we do not recommend enabling it in production environments. While Visual Studio Preview is not supported, we would love to hear your feedback on GitHub. This registry key is only compatible with Visual Studio 15.4 Preview 1, and newer versions may have alternate.
As usual, feedback is welcome at our GitHub page, and while we don't recommend using previews in production it is easy to install both the current preview and the current release of Visual Studio 2017 on the same machine.
We hope you enjoy these early previews of our current work. We're excited about a future with better C++ integration and no IntelliSense database, and we hope you are too. Thanks for being a Visual Studio user!