The Visual C++ team has been working to refresh our code analysis experience inside Visual Studio. We’re aiming to make these tools both more useful and natural to use and hope that they’ll benefit you no matter your workflow, style, or project type.
Trying out new features
In Visual Studio 2017 version 15.8 Preview 3, available in the Preview channel, we’ve introduced some new, in-progress code analysis features. These features are disabled by default, but you may enable them under Tools > Options > Text Editor > C++ > Experimental > Code Analysis. We encourage you to test them out and provide any feedback or comments you may have regarding your experience.
Background analysis
After enabling the features, code analysis will now run in the background when C++ files are opened or saved! Our goal here is to bring code analysis warnings into the editing experience so that bugs can be fixed earlier, and defects aren’t discovered only during build time. Once background code analysis runs for a file, warnings will be shown in the Error List and in the editor as squiggles.
In-editor warnings
Along with background analysis, code analysis warnings now display in-editor as green squiggles underneath the corresponding source code. In this Preview, if you change the file to fix a warning, the squiggles aren’t automatically refreshed. If the file is saved or analysis is re-run for the current file (Ctrl+Shift+Alt+F7), the squiggles and the Error List will be updated. We’re hoping these visual indicators will prove useful by giving you the ability to see code warnings in the same place you write and edit it.
Error List
Code analysis warnings will continue to be displayed in the Error List, but we’re trying to improve this experience as well. Filtering in the error list should be faster. We encourage using the “Current Document” filter to see only the errors for the files being edited. This pairs nicely with the background analysis feature. Warning details are also displayed in-line in the Error List instead of in a separate pop-up window. We’re believe having the details near the error makes it easier to dig into warnings. The new Error List experience is still a work in progress, so let us know of there are any “must have” features we should consider.
Future work
We’re excited to show off a preview of what’s to come, but for now there are a few known issues you may encounter. First, only the “Recommended Native Rules” ruleset is used when background analysis is run. Second, not all project types are supported with background analysis. You can always try running code analysis through the menus to force squiggles to refresh. Finally, the best way to clear squiggles for a project is to “Clean” build or disable the experimental feature.
Along with improved background analysis runs, highlighting for multi-line warnings, and a change to squiggles to show when warnings are out-of-date, automatic fix-its are also on the way. These IntelliSense-like lightbulb menus will give you the ability to rapidly correct or make changes to your code – and see exactly what will be changed – directly in the editor.
Send us feedback
Thank you to everyone who helps make Visual Studio a better experience for all. Your feedback is critical in ensuring we can deliver the best code analysis experience, so please let us know how Visual Studio 2017 version 15.8 Preview 3 is working for you in the comments below. General issues can be reported from within Visual Studio via Report a Problem, and you can provide any suggestions through UserVoice. You can also find us on Twitter (@VisualC).
The post New, experimental code analysis features in Visual Studio 2017 15.8 Preview 3 appeared first on C++ Team Blog.