Next-Gen Code Coverage in Visual Studio: Enhanced C++ Support and Security


We’re excited to share the latest changes in Visual Studio’s code coverage components. If you haven’t already, be sure to check out our previous blog posts: What’s New in Our Code Coverage Tooling? and Code coverage features in Visual Studio Enterprise.

C++ Code Coverage

Tired of instable native code coverage that doesn’t support ARM64? Now, you can collect native code coverage for all your methods, including those on ARM64. We have completely overhauled the C++ code coverage support to improve reliability, performance, and security. The new implementation, powered by MSVC compiler tooling, now supports x86, x64, and ARM64 architectures. To enable the new experience, you need to enable the /PROFILE linker option for all C++ projects, including both testing and production.

Image showing Configuration Properties, Linker, Advanced and set Profile to Yes (/Profile)

For detailed examples, visit:

This feature is available only for the MSVC compiler.

Introducing Microsoft.CodeCoverage.Console

You can use the new Microsoft.CodeCoverage.Console tool to collect code coverage for console applications, merge coverage reports, and instrument binaries. It can also capture code coverage for each test separately, making it an ideal choice for use in CI pipelines.

Available in Visual Studio Enterprise through Developer PowerShell, this command-line tool extends the capabilities of the well-known dotnet-coverage tool, adding support for C++ code coverage and enhanced security features.

For an example of how to use the Microsoft.CodeCoverage.Console tool, visit Scenario 09: C++ Code Coverage for Console Apps in Developer PowerShell for Visual Studio Enterprise. Visit What’s New in Our Code Coverage Tooling? to find even more examples.

To learn more, check out the Microsoft.CodeCoverage.Console documentation.

Enhanced Security Features

You can collect code coverage for web applications running in IIS for both .NET and C++ using Microsoft.CodeCoverage.Console, which allows for the instrumentation of both C++ and .NET binaries. Additionally, Visual Studio code coverage components now include enhanced security features, such as controlling access to data passed through named pipes and shared memory. This security improvement also supports running web applications in IIS under different user accounts, allowing you to specify which users can access the coverage data.

For a full example, visit Scenario 08: Static Code Coverage for ASP.NET Core Web Apps (Razor Pages) in IIS.

Summary

In this update, we’ve enhanced the code coverage experience in Visual Studio with a complete rewrite of C++ code coverage support, introduced the new Microsoft.CodeCoverage.Console tool, and added new security measures for managing access to shared data. These changes provide a faster, more reliable, and secure way to measure code coverage in your applications, especially when working with C++ projects.

We appreciate the time you’ve spent reporting issues/suggestions and hope you continue to give us feedback when using Visual Studio on what you like and what we can improve. Your feedback is critical to help us make Visual Studio the best tool it can be! You can share feedback with us via Developer Community: report any bugs or issues via report a problem and share your suggestions for new features or improvements to existing ones.

Stay connected with the Visual Studio team by following us on YouTube, Twitter, LinkedIn, Twitch and on Microsoft Learn.



Leave a Reply

Your email address will not be published. Required fields are marked *