{"id":543,"date":"2014-06-12T14:59:00","date_gmt":"2014-06-12T14:59:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2014\/06\/12\/project-support-for-natvis\/"},"modified":"2021-10-11T14:30:32","modified_gmt":"2021-10-11T14:30:32","slug":"project-support-for-natvis","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/project-support-for-natvis\/","title":{"rendered":"Project Support for Natvis"},"content":{"rendered":"<p><span style=\"font-size: 12px\">The past two releases of Visual Studio have evolved the Natvis format to allow developers to easily visualize their debug data inside the VC++ expression evaluator. &nbsp;The first Visual Studio &ldquo;14&rdquo; CTP provides a new way for native developers to consume and manage their Natvis debug visualizers.&nbsp; In response to <\/span><a style=\"font-size: 12px\" href=\"http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio\/suggestions\/4353231-allow-per-solution-or-per-project-natvis-files\">requests<\/a><span style=\"font-size: 12px\"> from Visual Studio developers, these files can now be added to a VC++ project which enables easier tracking and integration with source control.&nbsp; Special thanks to C++ MVP Marius Bancila for sharing the Natvis project integration <\/span><a style=\"font-size: 12px\" href=\"http:\/\/mariusbancila.ro\/blog\/2014\/06\/04\/per-project-natvis-files-in-visual-studio-14\/\">on his blog<\/a><span style=\"font-size: 12px\">!&nbsp;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: medium\"><strong>Adding a Visualizer to a Project<\/strong><\/span><\/p>\n<p>Existing .natvis files can be easily added to a project using the &ldquo;Add Existing Item&hellip;&rdquo; option and navigating to their location.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/3857.1_-add-natvis.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/3857.1_-add-natvis.png\" alt=\"Image 3857 1 add natvis\" width=\"554\" height=\"148\" class=\"aligncenter size-full wp-image-29552\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/3857.1_-add-natvis.png 554w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/3857.1_-add-natvis-300x80.png 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/0363.1_add-natvis-2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/0363.1_add-natvis-2.png\" alt=\"Image 0363 1 add natvis 2\" width=\"922\" height=\"193\" class=\"aligncenter size-full wp-image-29550\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/0363.1_add-natvis-2.png 922w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/0363.1_add-natvis-2-300x63.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/0363.1_add-natvis-2-768x161.png 768w\" sizes=\"(max-width: 922px) 100vw, 922px\" \/><\/a><\/p>\n<p>In the image below, <em>Volcanoes.natvis<\/em> has been added to the project and is shown in the Solution Explorer.<span style=\"font-size: 12px\">&nbsp;<\/span>\n<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/6457.2_natvis-in-soln-exp.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/6457.2_natvis-in-soln-exp.png\" alt=\"Image 6457 2 natvis in soln exp\" width=\"867\" height=\"286\" class=\"aligncenter size-full wp-image-29553\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/6457.2_natvis-in-soln-exp.png 867w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/6457.2_natvis-in-soln-exp-300x99.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/6457.2_natvis-in-soln-exp-768x253.png 768w\" sizes=\"(max-width: 867px) 100vw, 867px\" \/><\/a>\n<\/p>\n<p>Natvis files from the project will be evaluated by the debugger after all <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/jj620914.aspx\">other directories<\/a>, allowing an existing visualizer to be overridden by a custom .natvis file inside the project.<\/p>\n<p>Note: The CTP does not have a new item template for a blank .natvis file, however this will be available in the next release of Visual Studio along with a file icon for Natvis.<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: medium\"><strong>Live Editing While Debugging<\/strong><\/span><\/p>\n<p>Another improvement that we made for the first CTP is that the debugger no longer needs to be stopped to pick up the changes.&nbsp; The animation below demonstrates the live editing of <em>Volcanoes.natvis<\/em> while debugging the program. Visualization code is pasted into the .natvis file and then saved during the debugging session. Notice how the value for <em>volcanoesOfWashington<\/em> turns <span style=\"color: #ff0000\">red<\/span> to indicate that the saved changes in the visualizer have been picked up by the debugger:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/1680.3_natvis-gif.gif\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/1680.3_natvis-gif.gif\" alt=\"Image 1680 3 natvis gif\" width=\"822\" height=\"444\" class=\"aligncenter size-full wp-image-29551\" \/><\/a><\/p>\n<p>For more details on writing .natvis debug visualizers, consult these blog posts:<\/p>\n<ul>\n<li><span style=\"text-decoration: underline\"><a href=\"http:\/\/blogs.msdn.com\/b\/mgoldin\/archive\/2012\/06\/06\/visual-studio-2012-and-debugger-natvis-files-what-can-i-do-with-them.aspx\">http:\/\/blogs.msdn.com\/b\/mgoldin\/archive\/2012\/06\/06\/visual-studio-2012-and-debugger-natvis-files-what-can-i-do-with-them.aspx<\/a><\/span><\/li>\n<li><a style=\"font-size: 12px\" href=\"http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2013\/06\/28\/using-visual-studio-2013-to-write-maintainable-native-visualizations-natvis.aspxb\">http:\/\/blogs.msdn.com\/b\/vcblog\/archive\/2013\/06\/28\/using-visual-studio-2013-to-write-maintainable-native-visualizations-natvis.aspx<\/a><\/li>\n<\/ul>\n<p>In conclusion, please let us know what you think about these improvements by submitting feedback either online (blog comments, UserVoice, Connect) or through the Feedback button in the upper right corner of Visual Studio (<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/3022.7_feedback-icon.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2014\/06\/3022.7_feedback-icon.png\" alt=\"Image 3022 7 feedback icon\" width=\"16\" height=\"15\" class=\"aligncenter size-full wp-image-29556\" \/><\/a>).&nbsp; Thanks!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The past two releases of Visual Studio have evolved the Natvis format to allow developers to easily visualize their debug data inside the VC++ expression evaluator. &nbsp;The first Visual Studio &ldquo;14&rdquo; CTP provides a new way for native developers to consume and manage their Natvis debug visualizers.&nbsp; In response to requests from Visual Studio developers, [&hellip;]<\/p>\n","protected":false},"author":295,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[140,55,194],"class_list":["post-543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-c","tag-debugging","tag-diagnostics"],"acf":[],"blog_post_summary":"<p>The past two releases of Visual Studio have evolved the Natvis format to allow developers to easily visualize their debug data inside the VC++ expression evaluator. &nbsp;The first Visual Studio &ldquo;14&rdquo; CTP provides a new way for native developers to consume and manage their Natvis debug visualizers.&nbsp; In response to requests from Visual Studio developers, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/543","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\/295"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/543\/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=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}