Matt Godbolt has announced today that the Visual C++ compiler is finally available on Compiler Explorer (https://godbolt.org/). Compiler Explorer is a website where you can write C/C++/Rust/Go/D code, compile it with various compilers and settings and see the resulted assembly code.

The version available is 1910, i.e. VC++ 2017 RTM (the exact version number is 19.10.25017.0). The following targets are available:

  • x86: x86 CL 19 2017 RTW
  • x64: x86-64 CL 19 2017 RTW
  • ARM: ARM CL 19 2017 RTW

To give it a try, I compiled the following program:

The result may look at little bit surprizing, as it totals over 5000 lines of assembly code, as oposed to gcc 7 or clang 4 that only produce 42.

, , , Hits for this post: 2718 .

Visual Studio 2017 Enterprise provides a feature called Live Unit Testing that enables developers to see live how changing C# and VB.NET code affects its corresponding unit tests. Among its features, it includes showing coverage information in the editor as you type, integration with the Test Explorer, including/excluding targeted test methods or projects for large solutions, quick navigation to failed tests. It works with MSTest, xUnit.net and NUnit, but only for .NET Framework, as support for .NET Standard has not been added yet.

Detailed information about this productivity tool is available in this blog post: Live Unit Testing in Visual Studio 2017 Enterprise. In this article, I will show how this feature help you when you do test driven development. For this purpose, I will create a class called Point3D that is supposed to model a point in 3-dimentional space, as part of a .NET Framework class library called ALibraryHasNoName. A separate unit testing project called ALibraryHasNoName.Test contains an unit testing class Point3DTest. Initially, these are empty.

To start the live unit testing you need to run go to Test > Live Unit Testing and press Start.

I will start by writing a test for the constructor of Point3D. The constructor is supposed to take three arguments, representing the values for the coordinates in the three dimensions, X, Y and Z.

Since the Point3D class is empty, this line of code produces a compiling error. I can use the refactoring tools and create an implementation for the constructor.

After the code is added, when I navigate to the source code document I can see green check marks on the left of the code indicating lines of code covered by successful unit tests.

I don’t like the default names v1, v2, v3 and the fact that these values are represented by fields. I want to use properties called X, Y and Z. Therefore I am refactorying the generated code as shown below:

Back to the unit test, I am adding a few tests for these properties, making sure I get back the values I passed to the constructor.

The result when switching back to the Point3D class is that these properties are now covered by 1 test.

Next thing I want to do is add a static property/field to represent the origin of the 3D space, i.e. the point at (0,0,0). For this I am writing a new test method with the content shown below. Visual Studio suggests several ways to generate the missing symbol: as a property, field or read-only field, which I find the closest to what I want so I am going with this.

The code is generated and I get a visual indication that it is already covered by 1 test.

I want to add tests to make sure the three properties are all 0 as expected.

Back to the source code I can see now that each property is covered by two succesful tests at this point.

If you click the passing indicator, it shows the tests that cover it, whether they passed or failed, and the duration of their execution.

The last thing I want to do for this demo is adding a method to do a translation of the point in the 3d space. I want to call this method Offset. Therefore, I start with a new test method, called TestOffset where I create a point and invoke the new method. Visual Studio suggest to generate the missing method and I will go with the suggested code.

At this point the test is failing. Instead of a green check mark on the left, I see red crosses, indicating a failure.

These marks can be used to get more information about the failure. It turns out that the method is throwing an exception, that is not caught, so the test is failing.

Next, I will change the implementation of the Offset method to reflect what it is expected from it, and the red crosses turn instantly into green check marks.

To check the effect of the function, I am adding tests for each of the three properties of the class.

Going back to the class source code I can see that each of the three properties now has three successful tests that cover them.

Although this post only covers some of the capabilities of live unit testing I hope it shows how helpful it can be in writing unit tests in general and with TDD in particular. For details about the features check the official documentation.

, , , Hits for this post: 2227 .

Visual Studio 2017 has been officially launched today. The release notes contain a summary of all the changes available in the new version. This post is focused on the changes for C++ development.

The Visual C++ team has released a series of blog posts to document some of the new features. Here is a list of them:

Of all the changes and new features in VC++ 2017 (that are described in details in the articles mentioned above) there are several that I want to mention:

  • The C++ compiler is C++14 complete, but still lacks several C++98 and C++11 features. It also contains some features added to C++17.
  • The standard library implementation contains C++17 features including: any, optional, variant, string_view, make_from_tuple(). The complete list of improvements is available here.
  • Visual C++ 2017 runtime is compatible to the Visual C++ 2015 runtime. That means you can link to libraries build with VC++ 2015.
  • The C++ compiler version is 19.1, a minor release of the Visual C++ 2015 compiler (version 19.0). That means _MSC_VER is 1910. On the other hand, MFC and ATL are still on version 14.0 as in Visual C++ 2015. That means _MFC_VER and _ATL_VER ar both 0x0E00.
  • It is possible to open code from any folder with the Open Folder feature and get IntelliSense, navigation, building, and debugging capabilities without creating a solution and project first.
  • You can build your projects with CMake that is now supported in Visual Studio.
  • There is a built-in support for using another C++ compiler, such as Clang or GCC (mainly intended for building projects that target Android, Linux or Mac).
  • The C++ Core Checkers for enforcing the C++ Core Guidelines are now distributed with Visual Studio.
  • Installation of Visual Studio has been redesigned. Components are delivered in “workloads”, but individual components can be added or removed. For C++ there are five workloads: Universal Windows Platform development, Desktop Development with C++, Game development with C++, Mobile development with C++, and Linux development with C++.
  • Installation folder is not c:\Program Files (x86)\Microsoft Visual Studio 15.0 as with previous version, but c:\Program Files (x86)\Microsoft Visual Studio\2017\.

Here are a couple of screenshots from installing Visual Studio:

, , , Hits for this post: 3589 .

I recently encountered a problem creating new logins with SQL Server. Something that has worked for years suddenly stopped with the following error:

Password validation failed. The password does not meet Windows policy requirements because it is too short.

Since SQL Server was using Windows local security policy I went and checked that at Security Settings > Account Policies > Password Policy in Local Security Policy (available under Administrative Tools in Control Panel or by opening secpol.msc). As expected, these contained setting that I was not expecting, which were probably changed from the network by a system administrator.

However, I wanted to be able to enter shorter passwords, like 8 characters instead of 10, but this was disabled. Even if I was running as administrator, the option of changing this was disabled.

It is however still possible to modify these settings even if you cannot do it from the management console. You can do it from a command prompt as administrator.

  1. Open a command prompt running as administrator
  2. Run the following command to export the settings to a file. In my example, the target path is c:\temp\local.cfg, but it can be anything.

  3. Edit the file with notepad or another editor. The file is an INI file with sections and key-value pairs. The password settings are available under the [System Access] section. For changing the minimum length of the passwords modify the MinimumPasswordLength key.
  4. Save the file and run the following command to import the settings from the modified file.

  5. Close and open the Local Security Policy console again and check the settings.
, , , , Hits for this post: 4174 .

Visual Studio 2015 comes with many new features and improvements in the IDE, the debugger or language compilers. Obviously, there are more than three things I like in the new IDE, but three things have caught my attention from the very beginning.

The Error Window

vs2015error1
One of the things that bothered me the most about the error window was the mixture of errors/warnings/messages from both MSBuild and IntelliSense. But I don’t usually care about the later and their presence in the error window is usually annoying me. This is now fixed and you can select to see messages from Build, IntelliSense or both.
vs2015error2
In addition to this you can apply even more filtering:

  • You can select the source of the messages: Entire Solution, Current Project, Open Documents or Current Document.
    vs2015error3
  • You can search the error list, and the search includes the text in all the output list columns (Code, Description, Project, File or Line).
    vs2015error4
  • You can individually show or hide Errors, Warnings and Message (but this feature has been available for many years).

The Find in Files Append

I’m working with large source bases and I often need to do find in files, usually going from search to search until I find what I need. The problem was there were only two output windows for the search results and when you need to do a 3rd you had to discard one of the previous searches while you might still needed the results. I have requested for many years that Visual Studio should support more than two find results windows. I actually created a User Voice request a few years ago.

In Visual Studio 2015 they have implemented an append feature, were you could append your search results to one of the existing two windows.

vs2015find1

As a result the old search results are not discarded, but aggregated in a the form of a tree list in the search results window.

vs2015find2
vs2015find3

Though this is not what exactly I was expecting it provides the feature I was looking for with probably minimal changes to the Visual Studio IDE.

The Inline Create Definition (for C++)

I’m not sure how this feature is actually called, but what it does is creating a definition for a function in the source file from the declaration in the header and displays it in a boxed document inside the header document. Here is an example:

You declare a function/method in a header file. Visual Studio figures out the definition is missing.
vs2015inline1
Use the Quick Actions (CTRL + .) to create a definition of the symbol in the source file.
vs2015inline2
The definition is added to the source file that is opened as a document in a box just below the function declaration.
vs2015inline3
I find this very useful to get going with a new function. Of course for writing larger functions you’ll probably switch to the actual document tab where the source file is opened.

With these new features only Visual Studio has become much more productive for me. And there are plenty more.

, , Hits for this post: 14354 .

I have tried to assemble together information about the Visual C++ releases, the compiler and the frameworks (MFC and ATL). You can find these on many places, but it is often incomplete or focused on something particular (Visual Studio, C++ compiler, framework, etc.).

The table below is the result of this effort. It is incomplete because it’s not easy to find information about products released more than two decades ago, but if you can help filling in the gaps please drop a comment with the information you have and I will update the table.

UPDATE: Added information about Visal C++ 2017.

Product Codename Release date C++ version _MSC_VER MFC version _MFC_VER ATL version _ATL_VER
C 1.0 100
C 2.0 200
C 3.0 300
C 4.0 400
C 5.0 500
C 6.0 1990 600
C/C++ 7.0 1992 700 1.0 0x0100
Visual C++ 1.0 Caviar 1993 1.0 800 2.0 0x0200
Visual C++ 1.1 Barracuda 1993 1.1
Visual C++ 1.5 Dolphin 1993 1.5 850 2.5 0x0250
Visual C++ 1.51 1.5
Visual C++ 1.52 1.52
Visual C++ 1.52b 1.52b
Visual C++ 1.52c 1.52c
Visual C++ 2.0 2.0 900 3.0 0x0300
Visual C++ 2.1 2.1
Visual C++ 2.2 2.2
Visual C++ 4.0 Olympus 1995-12-11 4.0 1000 4.0 0x0400
Visual C++ 4.2 4.2 1020 4.2 0x0420
1.0 0x0100
1.1 0x0110
2.0 0x0200
Visual Studio 97 Boston 1997-04-28 5.0 1100 4.21 0x0421 2.1 0x0210
Visual Studio 6.0 Aspen 1998 6.0 1200 6.0 0x0600 3.0 0x0300
Visual Studio .NET 2002 Rainier 2002 7.0 1300 7.0 0x0700 7.0 0x0700
Visual Studio .NET 2003 Everett 2003 7.1 1310 7.1 0x0710 7.1 0x0710
Visual Studio 2005 Whidbey 2005 8.0 1400 8.0 0x0800 8.0 0x0800
Visual Studio 2008 Orcas 2008 9.0 1500 9.0 0x0900 9.0 0x0900
Visual Studio 2010 Dev10 2010 10.0 1600 10.0 0x0A00 10.0 0x0A00
Visual Studio 2012 Dev11 2012-08-15 11.0 1700 11.0 0x0B00 11.0 0x0B00
Visual Studio 2013 Dev12 2013-10-17 12.0 1800 12.0 0x0C00 12.0 0x0C00
Visual Studio 2015 Dev14 2015-07-20 14.0 1900 14.0 0x0E00 14.0 0x0E00
Visual Studio 2017 Dev15 2017-03-07 14.1 1910 14.0 0x0E00 14.0 0x0E00

Several notes on the history of VC++:

  • Visual Studio 97 was the first product that bundled together several products (Visual C++, Visual Basic, Visual J++)
  • Visual Studio 6.0 is the only version of Visual Studio that was not named after the release year, but the version number
  • MFC was first release in 1992 with C/C++ 7.0
  • MFC 6.0 released with Visual Studio 6 did not change the name of the MFC DLLs, that were still named mfc42.dll
  • ATL was first released in between Visual C++ 4.2 and Visual Studio 97. The first release of the framework to be included in a product was ATL 2.1 released with Visual Studio 97
  • Visual C++ version 3.0 was skipped to 4.0 to align the product version with the MFC version, whose next version was 4.0
  • Visual Studio 2015, the compiler and framework version are 14.0 and not 13.0, a number which was skipped (for the good old superstitions)
  • Visual Studio 2017, the compiler version is 14.1, a minor version of 14.0 from Visual Studio 2015, and the runtime is backwards compatible to VC++ 2015. MFC and ATL version remain 14.0 as in Visual Studio 2015.
  • _MFC_VER and _ATL_VER macros were initially incorrectly documented in MSDN as 0x1000 instead of 0x0A00

References

, , , Hits for this post: 20744 .

If you work on a Apache Cordova project in Visual Studio 2013 using Visual Studio Tools for Apache Cordova CTP 3 or 3.1 you should know there are important breaking changes in migrating the project from Visual Studio 2013 to Visual Studio 2015. The project can be migrated, but you have to do everything manually, as Visual Studio is not able to apply the changes automatically.

First of all, Visual Studio Tools for Apache Cordova CTP3.x are not longer supported in Visual Studio 2013 in the first place. If you try to install Update 5 it will prompt you to remove it before continuing.
vs2013u5
This is explained in the release notes for Update 5.

Also note: All prior releases of the Tools for Apache Cordova are incompatible with Update 5. If you have previously installed a Tools for Apache Cordova CTP extension, you must uninstall that extension before installing Visual Studio 2013 Update 5. If you require Apache Cordova support, we encourage you to try Visual Studio 2015.

The options for those developing with the VS tools for Apache Cordova in VS2013 are either to switch to Visual Studio 2015 or not install the last update and continue to work with CTP 3.x in VS2013.

In this article I will show you how to migrate a Cordova application from VS2013 to VS2015 and I will exemplify with a test application.

I have this app called TestApp. It’s built with Ionic and AngularJS. It is a JavaScript app, not a TypeScript app, but this works just the same regardless what language you use. It has the following project structure, with the Javascript source code in a folder called app, the libraries in libs and the templates in views. There are other folders apart from the ones VS has created, mainly css and images.

vs2013proj1 vs2013proj2

The application is just a test, it doesn’t do anything but it works for both Android and iOS.

ripple1 ripple2

When you open this project in Visual Studio 2015 it is not loaded. Visual Studio complains that “This project is incompatible with the current edition of Visual Studio.”
vs2015proj1
You have to covert it manually in order to make it available for Visual Studio 2015. Fortunately, the steps to do this are documented, but not in MSDN as one might expect, but on GitHub. There is a document called Known Issues – Visual Studio 2015 that explains what has to be done.

  • Create a new empty Apache Cordova app. The only purpose of this app is to copy from files to your actually project.
    vs2015proj2
  • Copy the .jsproj and taco.json files into the project folder of the application you migrate. Make sure you overwrite the existing .jsproj with this new project file.
  • Delete the existing bin and bld folders
  • Create a folder called www
  • Move everything except for config.xml and folders merges, res and plugins to the www folder.

If you open the project again in Visual Studio 2015 it will work and you can build and run it. For my test application the new project looks like this.
vs2015proj3

You can see that the all the folders and files under the www folder appear automatically in the solution explorer. They are not added with a Content or Folder element in the .jsproj file. You can make a comparison of the old and new .jsproj and see how simplified the new file is.
jsprojcompare1

Another thing to notice here is that the NodeJS module used for building the project is no longer called vs-mda (i.e. Visual Studio Multi-Device Application) but vs-tac (i.e. Visual Studio Tools for Apache Cordova).
jsprojcompare2

However, when I tried to build I got the following error:

MSBUILD : cordova-build error BLD401: Error : BLD00401 : Could not find module ‘delayed-stream’] code: ‘MODULE_NOT_FOUND’. Please Go to Tools –> Options –> Tools for Apache Cordova –> Cordova Tools –> Clear Cordova Cache and try building again.

This might have been related to the version of Apache Cordova I had globally installed, i.e. 5.1.1. If you get the same install it via npm.

However, you may still get problems when you try to build for Android.

MSBUILD : cordova-build error BLD10205: Please install Android target “”
You may not have the required environment or OS to build this project
MDAVSCLI : error : cmd: Command failed with exit code 2

The Android target name is empty, but if you do a Rebuild you get more information and actual required target name:

[Error: Please install Android target: “android-21”.

Hint: Open the SDK manager by running: C:\Program\ Files\ (x86)\Android\android-sdk\tools\android.BAT
You will require:
1. “SDK Platform” for android-21
2. “Android SDK Platform-tools (latest)
3. “Android SDK Build-tools” (latest)]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\ApacheCordovaTools\vs-mda-targets\Microsoft.MDA.FileMirroring.targets(352,5): error MSB3073: The command “platforms\android\cordova\clean.bat” exited with code 2.

These can be installed using the Android SDK Manager. Make sure you select all the mentioned components.
android1
With these changes you can build successfully for Android.

One more thing here is the version of Apache Cordova used by vs-tac to build. vs-tac uses Cordova 4.3.1, but I already had Cordova 5.1.1 installed on my machine and used by vs-mda. If you have a newer Cordova version than 4.3.1 what you have to do instruct vs-tac to use this one in the taco.json file.

Replace the version 4.3.1 of the cordova command line interface with desired version (in my case 5.1.1). When you rebuilt it will install it and build with it.

Your environment has been set up for using Node.js 0.12.7 (x64) and npm.
—— Ensuring correct global installation of package from source package directory: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\packages\vs-tac
—— Name from source package.json: vs-tac
—— Version from source package.json: 1.0.0
—— Package already installed globally at correct version.
—— Installing Cordova tools cordova@5.1.1 for project from npm. This could take a few minutes…

You can find the various Cordova versions installed under %APPDATA%\npm\node_modules\vs-tac\node_modules\cordova.
vstac3

For more information see:

, , , , Hits for this post: 20977 .

guidgen.exe is a small utility that comes with Visual Studio and generates GUIDs in a variety of formats. The problem with the tool is that it does not format GUIDs in plain text, which I happen to need many times (in source code, database tables, etc.) and I suppose is a feature needed by many developers. There are a couple of variants of the tool on Codeproject (GUIDGen Developer Studio AddIn and GUIDGen AddIn for Visual Studio.NET) but they lack some of the new formats supported by guidgen.

GUIDGEN.exe from Visual Studio

GUIDGEN.exe from Visual Studio does not have plain text formatting or case options.

Modified GUIDGEN has plain text formatting and case option but does not support all formats from Visual Studio’s GUIDGEN (i.e. C# and VB.NET Guid attribute format)

I have decided to create another modified version of GUIDGEN in order to support additional formats, including plain text, and also case options.

guidgen used to be available as an MFC sample, but that doesn’t seem to be the case any more. However, the sample from Visual Studio 2005 is still available on MSDN and I used that as a starting point. The result is a tool very similar to guidgen.exe from Visual Studio (2013 or 2015) but with additional features:

  • two more formats: __declspec(uuid("xxxxxxxx-xxxx...xxxx")) and plain text
  • case option: upper case (default) or lower case
guidgen2 guidgen3

The existing guidgen executable is available in the Common7\Tools folder of Visual Studio (i.e. c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ for Visual Studio 2013). You can replace that version with this build or put it somewhere else and keep it side by side by adding a new command from Tools > External tools. This might be more practical if you have several versions of Visual Studio installed.

guidgen-externaltools

Here are the downloads:
Guidgen-src (814) – Source code as Visual Studio 2013 solution
Guidgen-binaries (750) – Executables built with MFC as a shared library
Guidgen-mfcstaticlib-binary (808) – Executables built with MFC an a static library

, , , , , Hits for this post: 19858 .

Visual Studio Tools for Apache Cordova (VSCordovaTools for short) is a great Visual Studio toolset to develop hybrid applications for multiple platforms, including Android, iOS and Windows. One of the nice things about the tool is that it installs everything you need to develop with Cordova. You don’t have to care about installing multiple components, runtimes, setting system environment variables, etc. However, one of the drawbacks is that it is not currently supporting updating those components to newer versions.

The latest release available for VS 2013 is CTP 3.1 and this build comes with Cordova 3.5.0. Should you need to use a newer version you have to do it manually. In this blog post I will list all the steps you need to do to update to the latest version Cordova (currently 5.1.1) both on Windows and on Mac (where you build the iOS version of the hybrid apps). However, in these steps I will also include how to update Node.js and npm.

Update Cordova on Windows

Note: Make sure you close all instances of Visual Studio before starting this process.

  1. Download and install the latest version of Node.js from nodejs.org.
  2. Update npm. To check your current npm version run the following command in a console:

    To update to the last version of npm run the following command in a console (elevated As Administrator):
  3. Update Cordova. To check your Cordova version run the following command in a console:

    To update to the last version of cordova run the following command in a console (elevated As Administrator):
  4. Update the vs-mda version of Cordova with the latest you just installed in the previous step. Cordova is (globally) installed at %APPDATA%\npm\node_modules\cordova. vs-mda copy of Cordova is available at %APPDATA%\npm\node_modules\vs-mda\node_modules\cordova. Replace the entire content of this folder with the one of the global Cordova installation.
  5. Install missing modules (this might depend on the latest version you install). For 5.1.1 I had to install concat-map and balanced-match. If anything else is necessary it should show up in the output log when you build your Cordova project.

Update Cordova on Mac

Note: Make sure you stop the vs-mda-remote agent before performing this upgrade.

  1. Open a Terminal session and run the following command:
  2. Update the vs-mda-remote version of Cordova with the the latest you just installed in the previous step. Cordova is (globally) installed at /usr/local/lib/node_modules/cordova. vs-mda-remove copy of Cordova is available at /usr/local/lib/node_modules/vs-mda-remote/node_modules/cordova. Replace the entire content of this folder with the one of the global Cordova installation.
  3. Restart the vs-mda-remote agent.

With all these installed you should be all set to start building with the latest version of Cordova.

, , , , , , Hits for this post: 19780 .

Several CTPs for Visual Studio 2014 have been released so far. The 3rd and 4th CTPs can be actually used with a Windows Azure Virtual Machine. If you have a Windows Azure account you can go ahead and create a VM. If you are an MSDN Subscriber or you have a trial account, you have a number of free hours that you can use, so you won’t have to pay anything to run VS2014 CTP in the clound.

NOTE: Details about the limits and cost in Windows Azure are available here (also see this article).

Below is a step-by-step walk through of how to create and start a VM for Visual Studio 14 CTP 4.

Step 1: Log to Windows Azure.

Step 2: Create a new virtual machine.

In the Azure portal press the New button.
azure_vs2014ctp_1

Select Compute > Virtual Machine > From Gallery
azure_vs2014ctp_2

Choose the Visual Studio 2014 CTP 4 Image
azure_vs2014ctp_3

Select the virtual machine configuration
azure_vs2014ctp_4

azure_vs2014ctp_5

azure_vs2014ctp_6

Step 3: Wait until the virtual machine starts up.

This may take a few minutes.
azure_vs2014ctp_7

azure_vs2014ctp_8

Step 4: Connect remotely to the virtual machine.

See How to Log on to a Virtual Machine Running Windows Server.

Note: You have to authenticate with the username (make sure you use the format machinename\username) and the password you have created, not the account you are initially prompted in the RDP window.

azure_vs2014ctp_9

Step 5: Launch and use Visual Studio 2014 CTP.

azure_vs2014ctp_10

, , , , Hits for this post: 20377 .