{"id":91999,"date":"2021-09-20T17:00:00","date_gmt":"2021-09-20T17:00:00","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=91999"},"modified":"2021-10-13T12:50:15","modified_gmt":"2021-10-13T12:50:15","slug":"c-xml-comments-in-visual-studio-code","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/c-xml-comments-in-visual-studio-code\/","title":{"rendered":"C# XML Comments in Visual Studio Code"},"content":{"rendered":"<p><strong>Visual Studio Code<\/strong> appeared years ago as a light option to the full Visual Studio Environment. Being light, there are some features that we don&#8217;t have or at least took some time to appear. <strong>C# XML Comments<\/strong> is one of them.<\/p>\n<p>If a code needs to be full of comments, it&#8217;s possible the code is not good enough to be read. However, this doesn&#8217;t mean we should totally avoid comments. Some explanations on business logic may be useful. If we manage to include these explanations in a standard format that could even be extracted later, even better.<\/p>\n<p>In the past there was an extension for <strong>C# XML Comments<\/strong> but since version 1.23.8 the C# XML comments are naively support on Visual Studio Code, but not enabled by default.<\/p>\n<p>In order to enable them, we need to enable the configuration <strong>Format On Type<\/strong> on File-&gt;<em>Preferences-&gt;Settings-&gt;Text Editor-&gt;Formatting<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-92000\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/xmlcomments01.png\" alt=\"\" width=\"672\" height=\"720\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-92001\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/xmlcomments02.png\" alt=\"\" width=\"974\" height=\"556\" \/><\/p>\n<p>Basically, we are telling the editor to format our code, in this case the XML Comments, immediately after typing.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-92002\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/07\/xmlcomments03.png\" alt=\"\" width=\"760\" height=\"204\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>I confess I don&#8217;t know for sure what other formatting features are included when we enable this option but I would love to discover this. If you find this out, drop a comment on this blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio Code appeared years ago as a light option to the full Visual Studio Environment. Being light, there are some features that we don&#8217;t have or at least took some time to appear. C# XML Comments is one of them. If a code needs to be full of comments, it&#8217;s possible the code is&#8230;&hellip;<\/p>\n","protected":false},"author":50808,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[145417,145438],"coauthors":[6810],"class_list":["post-91999","post","type-post","status-publish","format-standard","hentry","category-blogs","tag-csharp","tag-visual-studio-code"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/91999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/50808"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=91999"}],"version-history":[{"count":1,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/91999\/revisions"}],"predecessor-version":[{"id":92003,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/91999\/revisions\/92003"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=91999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=91999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=91999"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=91999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}