{"id":18105,"date":"2018-01-10T12:39:49","date_gmt":"2018-01-10T20:39:49","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=18105"},"modified":"2019-02-18T17:48:06","modified_gmt":"2019-02-18T17:48:06","slug":"c-static-analysis-improvements-for-visual-studio-2017-15-6-preview-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/c-static-analysis-improvements-for-visual-studio-2017-15-6-preview-2\/","title":{"rendered":"C++ Static Analysis Improvements for Visual Studio 2017 15.6 Preview 2"},"content":{"rendered":"<p><a href=\"https:\/\/blogs.msdn.microsoft.com\/c\/2018\/01\/12\/c-static-analysis-improvements-for-visual-studio-2017-15-6-preview-2\/\">\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248<\/a> <\/p>\n<p>We&#8217;ve made a few changes to the C++ static analysis feature that should make it faster and easier to use. The behavior has changed slightly, and the menus have been moved around a bit, but we think that the new experience is faster and more consistent. Let&#8217;s take a quick look at the changes.<\/p>\n<h2>Single File Analysis<\/h2>\n<p>Developers tend to focus on a few files at a time when working on code. To make it easier to get analysis results for the files you&#8217;re editing, you can now run code analysis on a single file. This lets you get code analysis warnings without having to rebuild the entire project. We think this will be especially useful when fixing analysis warnings because it makes it convenient to check and recheck a file. After analysis runs, all analysis warnings for the file will appear in the error list.<\/p>\n<p><figure id=\"attachment_18116\" aria-labelledby=\"figcaption_attachment_18116\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/single-file-analysis.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/single-file-analysis.png\" alt=\"Screenshot of single file analysis.\" width=\"466\" height=\"404\" class=\"size-full wp-image-18116\" \/><\/a><figcaption id=\"figcaption_attachment_18116\" class=\"wp-caption-text\">New build menu item to run C++ code analysis on a single file.<\/figcaption><\/figure><\/p>\n<p>&nbsp;<\/p>\n<p><figure id=\"attachment_18125\" aria-labelledby=\"figcaption_attachment_18125\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/single-file-analysis-results.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/single-file-analysis-results.png\" alt=\"Screenshot showing single file analysis results.\" width=\"623\" height=\"446\" class=\"size-full wp-image-18125\" \/><\/a><figcaption id=\"figcaption_attachment_18125\" class=\"wp-caption-text\">Code Analysis results for a single file.<\/figcaption><\/figure><\/p>\n<p>If you have a few files you want to check, you can also select multiple files in the Solution Explorer and run code analysis on only those files.<\/p>\n<p><figure id=\"attachment_18135\" aria-labelledby=\"figcaption_attachment_18135\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/multi-file-analysis.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/multi-file-analysis.png\" alt=\"Screenshot showing the code analysis menu for multiple selected files.\" width=\"480\" height=\"196\" class=\"size-full wp-image-18135\" \/><\/a><figcaption id=\"figcaption_attachment_18135\" class=\"wp-caption-text\">Multiple files selected in the Solution Explorer can be analyzed at once.<\/figcaption><\/figure><\/p>\n<h2>More Consistent Menus<\/h2>\n<p>To make the code analysis menus easier to find, we&#8217;ve made them more consistent with their \u201cBuild\u201d counterparts. In previous versions, you would find the menu to run code analysis on a project under the &#8220;Project Only&#8221; menu. Now the menus to start analysis on a solution, project, or file are located near their &#8220;Build X&#8221; counterpart on the &#8220;Build&#8221; menu. On the Solution Explorer context menus, look for the &#8220;Analyze&#8221; menu on the solution, project, and file nodes of the tree.<\/p>\n<h3>Build Menu<\/h3>\n<p><figure id=\"attachment_18137\" aria-labelledby=\"figcaption_attachment_18137\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/analysis-build-menu.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/analysis-build-menu.png\" alt=\"Screenshot showing the location of new analysis menus on the top Build menu.\" width=\"380\" height=\"374\" class=\"size-full wp-image-18137\" \/><\/a><figcaption id=\"figcaption_attachment_18137\" class=\"wp-caption-text\">New build menu locations for starting solution, project, and per-file code analysis.<\/figcaption><\/figure><\/p>\n<h3>Context Menus<\/h3>\n<p><figure id=\"attachment_18185\" aria-labelledby=\"figcaption_attachment_18185\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/analysis-context-menu1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/analysis-context-menu1.png\" alt=\"Screenshot showing new Solution Explorer context menus for starting analysis.\" width=\"641\" height=\"425\" class=\"size-full wp-image-18185\" \/><\/a><figcaption id=\"figcaption_attachment_18185\" class=\"wp-caption-text\">New Solution Explorer context menus for running solution, project or per-file code analysis.<\/figcaption><\/figure><\/p>\n<h2>Analyze Only<\/h2>\n<p>We&#8217;ve heard from developers that running code analysis takes too long. In previous versions, running code analysis required a full build and link before analysis would run. Now when you run code analysis, we no longer generate code or link. This dramatically reduces analysis run time.<\/p>\n<p>One side effect is that you will no longer see some build warnings during analysis runs. You will get build warnings during builds, and code analysis warnings during analysis runs. If you prefer to see build and analysis warnings at the same time, check the &#8220;Enable Code Analysis on Build&#8221; box in the project properties and rebuild your project.<\/p>\n<p><figure id=\"attachment_18165\" aria-labelledby=\"figcaption_attachment_18165\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/enable-code-analysis-on-build.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/enable-code-analysis-on-build.png\" alt=\"Screenshot showing how to enable Code Analysis on Build.\" width=\"480\" height=\"259\" class=\"size-full wp-image-18165\" \/><\/a><figcaption id=\"figcaption_attachment_18165\" class=\"wp-caption-text\">Enable Code Analysis on Build to get build and analysis results at the same time.<\/figcaption><\/figure><\/p>\n<h2>C++ Core Guidelines Checker<\/h2>\n<p>C++ Core Check is currently not enabled by default, so if you want to try out the new single-file analysis experience with C++ Core Check, the extension must first be enabled on the project.<\/p>\n<p><figure id=\"attachment_18175\" aria-labelledby=\"figcaption_attachment_18175\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/enable-cppcorecheck-extension.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/enable-cppcorecheck-extension.png\" alt=\"Screenshot showing C++ Core Check extension enabled for a project.\" width=\"480\" height=\"266\" class=\"size-full wp-image-18175\" \/><\/a><figcaption id=\"figcaption_attachment_18175\" class=\"wp-caption-text\">The C++ Core Check extension has to be enabled per-project if you want the C++ Core Check results when you run code analysis.<\/figcaption><\/figure><\/p>\n<h2>Wrap Up<\/h2>\n<p>These are just a few simple tweaks to improve the C++ code analysis experience. Download the latest <a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">Visual Studio preview<\/a> and give them a try. We hope you will find it easier to use on your projects and that the tools help you write safer, more modern C++.<\/p>\n<p>As always, we welcome your feedback. Feel free to send any comments through e-mail at <a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>, through <a href=\"https:\/\/twitter.com\/visualc\">Twitter @visualc<\/a>, or Facebook at <a href=\"https:\/\/www.facebook.com\/Microsoft-Visual-Cpp-222043184527264\/\">Microsoft Visual Cpp<\/a>.<\/p>\n<p>If you encounter other problems with MSVC in VS 2017 please let us know via the <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio-2017\">Report a Problem<\/a> option, either from the installer or the Visual Studio IDE itself. For suggestions, let us know through <a href=\"https:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio-2015\/category\/30937-languages-c\">UserVoice<\/a>. Thank you!<\/p>\n<p>Happy coding.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248 We&#8217;ve made a few changes to the C++ static analysis feature that should make it faster and easier to use. The behavior has changed slightly, and the menus have been moved around a bit, but we think that the new experience is faster and more consistent. Let&#8217;s take a quick look at the changes. [&hellip;]<\/p>\n","protected":false},"author":2869,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270],"tags":[245,163],"class_list":["post-18105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","tag-cppcorecheck","tag-static-analysis"],"acf":[],"blog_post_summary":"<p>\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248 We&#8217;ve made a few changes to the C++ static analysis feature that should make it faster and easier to use. The behavior has changed slightly, and the menus have been moved around a bit, but we think that the new experience is faster and more consistent. Let&#8217;s take a quick look at the changes. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/18105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/2869"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=18105"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/18105\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=18105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=18105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=18105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}