{"id":8563,"date":"2015-02-12T05:50:07","date_gmt":"2015-02-12T05:50:07","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2015\/02\/12\/new-ways-to-quickly-create-a-code-map\/"},"modified":"2019-02-14T17:47:23","modified_gmt":"2019-02-15T01:47:23","slug":"new-ways-to-quickly-create-a-code-map","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/new-ways-to-quickly-create-a-code-map\/","title":{"rendered":"New ways to quickly create a Code Map"},"content":{"rendered":"<p><b>Code Maps<\/b>, previously known as Directed Graph Documents, are a great way to visualize the relationships and interdependencies between the components of your applications. They make it much easier to understand the architecture of your (or, even more useful, somebody else\u2019s) application, and where you should start when you need to update the application. Code Maps are a core part of the features of Visual Studio that help you to visualize and get insights about code.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/4338.clip_image002_09633A82.jpg\"><img decoding=\"async\" title=\"clip_image002\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/8816.clip_image002_thumb_1AD62C0B.jpg\" width=\"606\" height=\"458\" \/><\/a><\/p>\n<h3>OK, but I need more than one Code Map&#8230; <\/h3>\n<p>In Visual Studio 2013, you can create a Code Map by selecting <b>Directed Graph Document<\/b> in the <b>New File <\/b>dialog, from the <b>Architecture<\/b> menu, or by choosing <b>Show on Code Map <\/b>in Architecture Explorer, Solution Explorer, and the Debugger tool bar. However, it\u2019s difficult to start a new and less cluttered Code Map to focus on specific components in an existing Code Map because <b>Show on Code Map <\/b>always adds code elements to the most recent Code Map. Meanwhile, the <b>New File <\/b>dialog and the <b>Architecture<\/b> menu just create a new blank Code Map without any styles. <\/p>\n<p>In Visual Studio 2013 Update 3, we added the capability to drag arbitrary binaries from Windows File Explorer into a Code Map in order to understand their dependencies, and to try to componentize them. Of course, creating a new Directed Graph Document is a pre-requisite for this\u2014which is also quite difficult to do. Many users found it hard to discover the options for creating a new Directed Graph Document, or became confused when prompted to create a new Modeling Project.<\/p>\n<p>In Visual Studio 2015, both of these problems go away. We\u2019re providing some new ways to create a Code Map that makes the feature easier to use, and\u2014by removing unnecessary clutter\u2014even more useful.<\/p>\n<h3>A day in the life of a developer \u2026<\/h3>\n<p>Imagine that this is my first day with the team that produces Entity Framework (EF), and I\u2019ve been given the simple task of adding a new command line option to the Migration tool. I&#8217;ve opened the EntityFramework solution, and generated a Dependency Graph using the option in the <b>Architecture<\/b> menu. This helps me to orient myself within the code, and I\u2019m pleased to see that <b>migrate.exe<\/b> depends only on <b>EntityFramework.dll<\/b>. Immediately I know that I don&#8217;t have to examine the other projects. <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/5710.clip_image004_4544EDD9.jpg\"><img decoding=\"async\" title=\"clip_image004\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image004\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/6232.clip_image004_thumb_29A2F294.jpg\" width=\"707\" height=\"126\" \/><\/a><\/p>\n<p>Looking at the files in Solution Explorer I notice that the Migrate project contains a file named Program.cs. This will be my starting point, and so I select <b>Show on Code Map<\/b> to add it to the existing map.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/6685.clip_image006_790F74DB.jpg\"><img decoding=\"async\" title=\"clip_image006\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image006\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/3581.clip_image006_thumb_7D1C535E.jpg\" width=\"704\" height=\"309\" \/><\/a><\/p>\n<p>I can see that Program has dependencies on Entity Framework.dll and on Externals, but the diagram is becoming more complicated and I still need to know more. So I expand <b>Program<\/b> to examine its contents, and the diagram now gets really cluttered. It contains many things that I&#8217;m not really interested in.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/5025.clip_image008_1A250227.jpg\"><img decoding=\"async\" title=\"clip_image008\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image008\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/5415.clip_image008_thumb_67578C63.jpg\" width=\"700\" height=\"569\" \/><\/a><\/p>\n<p>And every time I expand an item, the graph gets bigger and interaction with it becomes slower and more difficult. That&#8217;s not what I want. I want to keep the overview map (this helps me to stay oriented with the overall solution structure), but I also need to create a new Code Map. In Visual Studio 2013, I can try to find out how to do this using the Quick Launch box, but this doesn\u2019t show anything useful.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/1122.clip_image009_1AB5E071.png\"><img decoding=\"async\" title=\"clip_image009\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image009\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/5282.clip_image009_thumb_5CBC4FB2.png\" width=\"591\" height=\"140\" \/><\/a><\/p>\n<p>Next, I try \u201cDGML\u201d because I noticed that this is the extension for the map files, but that shows nothing either. So I use the <b>Add New Item<\/b> option on the <b>Projects<\/b> menu, but entering \u201cCode Maps\u201d or \u201cDGML\u201d in the search box again finds nothing.<\/p>\n<p>In the end I ask my colleague, who tells me that I need to create a new \u201cDirected Graph Document\u201d in the <b>Add New Item<\/b> dialog, or use the <b>New Diagram<\/b> option on the <b>Architecture<\/b> menu\u2014and that forces me to create a Modeling Project that I don\u2019t really want. It also gives me a new blank Code Map where I have to add the items I\u2019m interested in. <\/p>\n<h3>The answer: new graph from selection!<\/h3>\n<p>In Visual Studio 2015, I can reduce the clutter without losing my existing high-level diagram of the solution structure or starting with a blank map by creating a new Code Map that contains only the selected items in the current Code Map. I simply select the components I\u2019m interested in and choose <b>New Graph from Selection<\/b> in the short-cut menu.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/6712.clip_image011_4CB011AC.jpg\"><img decoding=\"async\" title=\"clip_image011\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image011\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/3122.clip_image011_thumb_69B8C074.jpg\" width=\"700\" height=\"403\" \/><\/a><\/p>\n<p>Now I have a useful and uncluttered diagram focused on just the items I want to explore. I expand the <b>migrate.exe<\/b> item to see that it contains a <b>Program<\/b> item that depends on EntityFramework.dll. <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/2061.clip_image012_298537AB.png\"><img decoding=\"async\" title=\"clip_image012\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image012\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/4478.clip_image012_thumb_1D834777.png\" width=\"310\" height=\"231\" \/><\/a><\/p>\n<p>I dive deeper by expanding the <b>Program<\/b> item to see its contents. It\u2019s now clear that the object I need to work on is the <b>CommandLine<\/b> class.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/1385.clip_image013_788586FD.png\"><img decoding=\"async\" title=\"clip_image013\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image013\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/4382.clip_image013_thumb_4CD74DB2.png\" width=\"550\" height=\"801\" \/><\/a><\/p>\n<p>Using Visual Studio Code Maps made it easy to get an initial overview of the solution and narrow down my exploration to locate the objects I need to work on, while feeling comfortable that I won&#8217;t miss anything. If I\u2019d been doing this purely by examining the code itself, it would have been much harder to understand all the dependencies. With very little effort and intuition I\u2019ve focused down on the <b>CommandLine<\/b> class, but I can continue generating more maps to help me both drill down and step back through the solution architecture.<\/p>\n<h3>And if I want a blank code map?<\/h3>\n<p>In addition, any time I do want a new blank Code Map, perhaps to examine a related object or assembly, I just choose the <b>New Code Map <\/b>option on the <b>Architecture<\/b> menu\u2014without being forced to create a Modeling Project.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/00\/45\/92\/metablogapi\/7127.clip_image014_09FB0938.png\"><img decoding=\"async\" title=\"clip_image014\" style=\"border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px\" border=\"0\" alt=\"clip_image014\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2015\/02\/0525.clip_image014_thumb_64FD48BE.png\" width=\"423\" height=\"185\" \/><\/a><\/p>\n<h3>Got feedback?<\/h3>\n<p>Please try the improved Code Maps and send your feedback, ideas, and requests to vsarchfeedback@microsoft.com<\/p>\n<p>Thank you,    <br \/>The Code Insights team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code Maps, previously known as Directed Graph Documents, are a great way to visualize the relationships and interdependencies between the components of your applications. They make it much easier to understand the architecture of your (or, even more useful, somebody else\u2019s) application, and where you should start when you need to update the application. Code [&hellip;]<\/p>\n","protected":false},"author":112,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,251],"tags":[],"class_list":["post-8563","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-security"],"acf":[],"blog_post_summary":"<p>Code Maps, previously known as Directed Graph Documents, are a great way to visualize the relationships and interdependencies between the components of your applications. They make it much easier to understand the architecture of your (or, even more useful, somebody else\u2019s) application, and where you should start when you need to update the application. Code [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/8563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/112"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=8563"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/8563\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=8563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=8563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=8563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}