{"id":34627,"date":"2024-09-11T10:00:41","date_gmt":"2024-09-11T10:00:41","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=34627"},"modified":"2024-09-10T20:59:31","modified_gmt":"2024-09-10T20:59:31","slug":"fix-c-warnings-and-errors-with-copilot-introducing-ai-assisted-code-fixes-in-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/fix-c-warnings-and-errors-with-copilot-introducing-ai-assisted-code-fixes-in-visual-studio\/","title":{"rendered":"Fix C++ warnings and errors with Copilot: Introducing AI-Assisted Code Fixes in Visual Studio"},"content":{"rendered":"<p>Stuck on an unfamiliar build error? Want to resolve your code errors quickly? Copilot is now integrated into Visual Studio error workflows to assist you with understanding and resolving C++ errors and warnings.<\/p>\n<p>To access this new feature, you will need an <a href=\"https:\/\/github.com\/features\/copilot?utm_source=vscom&amp;utm_medium=hero&amp;utm_campaign=cta-get#pricing\">active Copilot subscription<\/a> and the <a href=\"https:\/\/visualstudio.microsoft.com\/\">latest 17.11 GA version of Visual Studio<\/a>.<\/p>\n<h3>How does it work?<\/h3>\n<p>There are two different entry points to accommodate where you are at in your error workflow:<\/p>\n<ul>\n<li>The <strong>Quick Action lightbulb proposes a fix<\/strong> of a given error inline in your code window.<\/li>\n<li>The <strong>Error List Integration<\/strong> invokes Copilot in the chat window to <strong>explain the error code and showcase a proposed fix<\/strong>.<\/li>\n<\/ul>\n<p>Semantically relevant code snippets from your active file and related files are automatically included as context to increase the relevant of the proposed fix.<\/p>\n<h3>Fix with Copilot in the Quick Action Lightbulb<\/h3>\n<p>Copilot is integrated into the Quick Action lightbulb in your code editor, so that you can invoke Copilot and view proposed fixes inline with a few simple clicks. Just <strong>hover over the diagnostic squiggle<\/strong> or <strong>double-click on a diagnostic message in your Error List <\/strong>to access Fix with Copilot via Quick Action Lightbulb.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/fix-with-copilot-lightbulb.png\"><img decoding=\"async\" class=\"size-full wp-image-34628 aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/fix-with-copilot-lightbulb.png\" alt=\"Option to fix with Copilot over an error in the light bulb.\" width=\"1006\" height=\"366\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/fix-with-copilot-lightbulb.png 1006w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/fix-with-copilot-lightbulb-300x109.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/fix-with-copilot-lightbulb-768x279.png 768w\" sizes=\"(max-width: 1006px) 100vw, 1006px\" \/><\/a>From here, Copilot will invoke the \/fix command with semantically relevant C++ code snippets to propose a fix for your code.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/diff-viewer-fix.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-34629\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/diff-viewer-fix.png\" alt=\"VS diff viewer showing the implementation of a proposed fix.\" width=\"1795\" height=\"553\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/diff-viewer-fix.png 1795w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/diff-viewer-fix-300x92.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/diff-viewer-fix-1024x315.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/diff-viewer-fix-768x237.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/diff-viewer-fix-1536x473.png 1536w\" sizes=\"(max-width: 1795px) 100vw, 1795px\" \/><\/a><\/p>\n<p>You can edit the proposed code, accept any changes inline, or ask any follow-up questions in the inline Copilot Chat pane, without having to navigate away from the code editor.<\/p>\n<h3>Explain and Fix with Copilot in the Error List<\/h3>\n<p>If you want to learn more about the error itself, Copilot is integrated in the Error List to invoke by\u00a0<strong>selecting the Copilot icon to the left of a code warning or error<\/strong> to provide an explanation alongside a proposed fix through the Chat pane. This can be beneficial for more complex fixes, as it can provide multiple code snippets across several files and a deeper understanding of the error itself.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-error-list.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-34630\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-error-list.png\" alt=\"Copilot icon in the error list to ask copilot for an explanation and a fix,\" width=\"1858\" height=\"355\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-error-list.png 1858w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-error-list-300x57.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-error-list-1024x196.png 1024w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-error-list-768x147.png 768w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-error-list-1536x293.png 1536w\" sizes=\"(max-width: 1858px) 100vw, 1858px\" \/><\/a><\/p>\n<p>Given the same relevant C++ context, it will help you more deeply understand the error code and propose a fix for the code. You also can ask follow-up questions or add any additional details via the Chat pane to probe further.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-chat-error.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-34631\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-chat-error.png\" alt=\"Copilot Chat pane proposing an explanation and how to fix an error.\" width=\"813\" height=\"1165\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-chat-error.png 813w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-chat-error-209x300.png 209w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-chat-error-715x1024.png 715w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2024\/09\/copilot-chat-error-768x1101.png 768w\" sizes=\"(max-width: 813px) 100vw, 813px\" \/><\/a><\/p>\n<h3>What do you think?<\/h3>\n<p>Please let us know anything you\u2019d like to see added to this feature or your experiences with this fixing experience. We have a survey available for any feedback here: <a href=\"https:\/\/www.surveymonkey.com\/r\/RKG68YN\">https:\/\/www.surveymonkey.com\/r\/RKG68YN<\/a>. You\u2019ll need an active\u00a0<a href=\"https:\/\/github.com\/features\/copilot?utm_source=vscom&amp;utm_medium=hero&amp;utm_campaign=cta-get#pricing\">GitHub Copilot<\/a>\u00a0subscription. Download the\u00a0<a href=\"http:\/\/aka.ms\/vs\">latest version of Visual Studio<\/a>\u00a0and give it a try.<\/p>\n<p>In addition, our team is working hard on improving C++ integrations with Copilot Chat, so please let us know any other enhancements you\u2019d like to see to your C++ workflows and content you\u2019d like to see.<\/p>\n<p>We welcome all types of feedback on your experience with the product. Comment below, or you can find us via email at\u00a0<a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>\u00a0or via X at\u00a0<a href=\"https:\/\/x.com\/visualc\">@VisualC<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Stuck on an unfamiliar build error? Want to resolve your code errors quickly? Copilot is now integrated into Visual Studio error workflows to assist you with understanding and resolving C++ errors and warnings. To access this new feature, you will need an active Copilot subscription and the latest 17.11 GA version of Visual Studio. How [&hellip;]<\/p>\n","protected":false},"author":85413,"featured_media":34628,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,3940],"tags":[],"class_list":["post-34627","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","category-copilot"],"acf":[],"blog_post_summary":"<p>Stuck on an unfamiliar build error? Want to resolve your code errors quickly? Copilot is now integrated into Visual Studio error workflows to assist you with understanding and resolving C++ errors and warnings. To access this new feature, you will need an active Copilot subscription and the latest 17.11 GA version of Visual Studio. How [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/34627","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\/85413"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=34627"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/34627\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/34628"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=34627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=34627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=34627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}