{"id":249167,"date":"2024-05-28T11:10:05","date_gmt":"2024-05-28T18:10:05","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=249167"},"modified":"2024-05-30T07:28:36","modified_gmt":"2024-05-30T14:28:36","slug":"visualstudio-extensibility-17-10","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/visualstudio-extensibility-17-10\/","title":{"rendered":"VisualStudio.Extensibility 17.10: Debug your extensions with the Diagnostics Explorer"},"content":{"rendered":"<p>Imagine creating extensions that run faster and smoother than ever before! If you haven&#8217;t been following along lately, we&#8217;ve been working on improving the VisualStudio.Extensibility SDK. VisualStudio.Extensibility helps you build extensions that run outside the main IDE process for improved performance and reliability. With it comes a sleek and intuitive .NET 8-based API and comprehensive, well-maintained documentation to help you develop awesome extensions.<\/p>\n<p>This 17.10 release builds on our <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/Blog\/17.9\">previous<\/a> releases, and it brings with it a brand-new debugging experience to make it easier for you to get your extensions running just the way you&#8217;d expect. We\u2019ve also enhanced our remote UI features, added a new way to prompt users, and continued to add features to our project query API.<\/p>\n<p><div  class=\"d-flex justify-content-center\"><a class=\"cta_button_link btn-primary mb-24\" href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\" target=\"_blank\">Get Started with VisualStudio.Extensibility<\/a><\/div><\/p>\n<p>Please visit <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\">https:\/\/aka.ms\/VisualStudio.Extensibility<\/a> for the latest up-to-date docs and installation instructions. We encourage you to report bugs and suggest features via the <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/Issues\">issue tracker<\/a> on our <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/Repo\">GitHub repo<\/a>, where you can also find extension <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/Samples\">samples<\/a> to help you get started.<\/p>\n<p>&nbsp;<\/p>\n<h3>What\u2019s new for VisualStudio.Extensibility?<\/h3>\n<p>Do you want to develop and debug your extensions more quickly and more easily than before? Our 17.10 release adds the following features to help you do just that:<\/p>\n<ul>\n<li><a href=\"#post-249167-_Debug_your_extension\">Debug your extension using our new Diagnostics Explorer<\/a><\/li>\n<li><a href=\"#post-249167-_Leverage_XAML_Resources\">Leverage XAML Resources in your UI<\/a><\/li>\n<li><a href=\"#post-249167-_Let_your_extension\">Let your extension users pick files or directories<\/a><\/li>\n<li><a href=\"#post-249167-_Track_project_changes\">Track project changes with an improved query API<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4><a id=\"post-249167-_Debug_your_extension\"><\/a>Debug your extension using our new Diagnostics Explorer<\/h4>\n<p>We\u2019ve created a powerful new tool for debugging your extensions called the VisualStudio.Extensibility Diagnostics Explorer, available <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/DiagnosticsExplorer\">here<\/a> in the Visual Studio Marketplace. With it, you\u2019ll be able to see extensions the way that Visual Studio sees them to help ensure that you\u2019ve configured yours correctly.<\/p>\n<p>This tool, which itself was written as an <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/VSSDKCompatability\">in-process VisualStudio.Extensibility extension<\/a>, can help you answer questions like \u201cwhy isn\u2019t my command showing up where I expect it to be in the IDE?\u201d or \u201cwhy isn\u2019t my extension being activated when I expect it to be?\u201d<\/p>\n<h5>Inspect configuration<\/h5>\n<p>VisualStudio.Extensibility has already made it easier for you to configure your extensions by eliminating the need for you to manually maintain separate metadata files. Now, we\u2019re building on that with the Diagnostics Explorer, which lets you see exactly which extensions and components were discovered by Visual Studio, along with the configuration of each discovered item.<\/p>\n<p>For example, if you weren\u2019t seeing your command in the IDE, you could use the Command tab Diagnostics Explorer to view any commands that have been contributed to Visual Studio. If it\u2019s not present in the list, that\u2019s a hint to double check your configuration to make sure it gets discovered. If it\u2019s present, but not enabled or visible, you may want to check your <a href=\"#post-249167-_Create_better_activation\">activation constraints<\/a>. And if it\u2019s marked as enabled and visible, you could use the dropdown menu to view <em>command placements<\/em> to make sure you\u2019ve placed it correctly.<\/p>\n<p><img decoding=\"async\" width=\"2222\" height=\"445\" class=\"wp-image-249169\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-white-text-description-automa.png\" alt=\"A screenshot of the Commands tab of the VisualStudio.Extensibility Diagnostics Explorer. It shows one command associated with the ToolWindowSampleExtension, along with the metadata for that command.\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-white-text-description-automa.png 2222w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-white-text-description-automa-300x60.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-white-text-description-automa-1024x205.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-white-text-description-automa-768x154.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-white-text-description-automa-1536x308.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-white-text-description-automa-2048x410.png 2048w\" sizes=\"(max-width: 2222px) 100vw, 2222px\" \/><\/p>\n<p>Using the Commands tab, you can inspect <em>commands<\/em>, <em>command sets<\/em>, <em>groups<\/em>, <em>menus and toolbars<\/em>, <em>command placements<\/em>, and <em>dynamic command anchors<\/em>. Other tabs let you inspect components for other feature areas including tool windows, document types, text views, and more. As we add features in future releases, you\u2019ll be able to inspect any new components alongside these in the Diagnostics Explorer.<\/p>\n<h5>View live event log<\/h5>\n<p>We know that extension developers like you sometimes develop extensions that may need to handle events throughout the IDE, such as a command being executed, a tool window being opened, or a TextView being created, so we\u2019ve added a live event viewer to enable you to observe these events and their properties in real time:<\/p>\n<p><img decoding=\"async\" width=\"2222\" height=\"444\" class=\"wp-image-249170\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-many-small-colored-lines-desc.png\" alt=\"A screenshot of the Events tab of the VisualStudio.Extensibility Diagnostics Explorer, which shows several events related to executing a command and hiding\/showing tool windows.\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-many-small-colored-lines-desc.png 2222w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-many-small-colored-lines-desc-300x60.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-many-small-colored-lines-desc-1024x205.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-many-small-colored-lines-desc-768x153.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-many-small-colored-lines-desc-1536x307.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-black-screen-with-many-small-colored-lines-desc-2048x409.png 2048w\" sizes=\"(max-width: 2222px) 100vw, 2222px\" \/><\/p>\n<h5><a id=\"post-249167-_Create_better_activation\"><\/a>Create better activation constraints<\/h5>\n<p>The Activation Constraints tab in the Diagnostics Explorer gives you the current state for each of the values available to you when creating an <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/ActivationConstraints\">activation constraint<\/a>. Using this tab, you can get the IDE into the state that you want to use for your activation (such as building a project or opening a markdown file), and then you can inspect the values for each of the available expressions to help you create your constraint.<\/p>\n<p><img decoding=\"async\" width=\"2388\" height=\"562\" class=\"wp-image-249171\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-screenshot-of-a-computer-description-automatica.png\" alt=\"A screenshot of the Activation Constraints tab of the VisualStudio.Extensibility Diagnostics Explorer, which shows current information about the state of the IDE.\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-screenshot-of-a-computer-description-automatica.png 2388w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-screenshot-of-a-computer-description-automatica-300x71.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-screenshot-of-a-computer-description-automatica-1024x241.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-screenshot-of-a-computer-description-automatica-768x181.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-screenshot-of-a-computer-description-automatica-1536x361.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2024\/05\/a-screenshot-of-a-computer-description-automatica-2048x482.png 2048w\" sizes=\"(max-width: 2388px) 100vw, 2388px\" \/><\/p>\n<p>For example, suppose you wanted a command to be visible only if there\u2019s a C# file open in the editor. With the Diagnostics Explorer, you could open a C# file and use the Activation Constraints tab to help you to determine which of the expressions you\u2019ll need to craft your constraint:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\" style=\"padding-bottom: 0px; margin-bottom: 0px;\"><span style=\"font-size: 8.5pt;\"><code class=\"language-cs language-csharp\">EnabledWhen = ActivationConstraint.ClientContext(ClientContextKey.Shell.ActiveEditorContentType, \"CSharp\").\r\n<\/code><\/span><\/pre>\n<p>&nbsp;<\/p>\n<h4><a id=\"post-249167-_Leverage_XAML_Resources\"><\/a>Leverage XAML Resources in your UI<\/h4>\n<p>XAML resources accelerate your UI development by letting you define objects like colors, brushes, or styles that you can leverage throughout your project. With this release of VisualStudio.Extensibility, we\u2019re adding support for XAML resources to help you develop great UIs for your extensions!<\/p>\n<p>Consistent with our other remote UI features such as UI controls, you\u2019ll define any XAML files with ResourceDictionaries as embedded resources in your .csproj file:<\/p>\n<pre class=\"prettyprint language-xml\" style=\"padding-bottom: 0px; margin-bottom: 0px;\"><span style=\"font-size: 8.5pt;\"><code class=\"language-xml\">&lt;ItemGroup&gt;\r\n    &lt;EmbeddedResource Include=\"\\XamlResources.*xaml\" \/&gt;\r\n    &lt;Page Remove=\"XamlResources.*xaml\" \/&gt;\r\n&lt;\/ItemGroup&gt;\r\n<\/code><\/span><\/pre>\n<p>Once defined, it\u2019s easy to include your resources in other components so that they can be referenced in your XAML throughout your project:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\" style=\"padding-bottom: 0px; margin-bottom: 0px;\"><span style=\"font-size: 8.5pt;\"><code class=\"language-cs language-csharp\">ResourceDictionaries.AddEmbeddedResource(\"XamlResources.xaml\")\r\n<\/code><\/span><\/pre>\n<p>You can even localize your resources: see the <a href=\"https:\/\/github.com\/microsoft\/VSExtensibility\/tree\/main\/New_Extensibility_Model\/Samples\/FeatureGallery\/ModalDialog\">Modal Dialog sample<\/a> for more information and let us know what you think!<\/p>\n<p>&nbsp;<\/p>\n<h4><a id=\"post-249167-_Let_your_extension\"><\/a>Let your extension users pick files or directories<\/h4>\n<p>Building on our previous support for <a href=\"https:\/\/learn.microsoft.com\/visualstudio\/extensibility\/visualstudio.extensibility\/user-prompt\/user-prompts\">user prompts<\/a> and <a href=\"https:\/\/learn.microsoft.com\/visualstudio\/extensibility\/visualstudio.extensibility\/dialog\/dialog\">custom dialogs<\/a>, we\u2019ve added the ability to display file and directory picker prompts from your extensions. For example, you can use the <code>ShowOpenFileDialogAsync()<\/code> method to prompt users to select a single file to open:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\" style=\"padding-bottom: 0px; margin-bottom: 0px;\"><span style=\"font-size: 8.5pt;\"><code class=\"language-cs language-csharp\">VisualStudioExtensibility.Shell().ShowOpenFileDialogAsync(options, cancellationToken);\r\n<\/code><\/span><\/pre>\n<p>Using the new APIs, you can prompt users to:<\/p>\n<ul>\n<li>Select a single file to open<\/li>\n<li>Select one or more files to open<\/li>\n<li>Select a single file to Save As<\/li>\n<li>Select a directory to open<\/li>\n<\/ul>\n<p>As always, if there are other types of user prompts that are important for your extensions, please let us know through our <a href=\"https:\/\/github.com\/microsoft\/VSExtensibility\/issues\">Issues Tracker<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h4><a id=\"post-249167-_Track_project_changes\"><\/a>Track project changes with an improved query API<\/h4>\n<p>Our 17.10 release adds three new features to the project query API.<\/p>\n<h5>Track changes to query results<\/h5>\n<p>The TrackUpdatesAsync() method can be used in your project system queries to create an <a href=\"https:\/\/learn.microsoft.com\/dotnet\/api\/system.iobserver-1\">IObserver<\/a> object to track changes to the state of the projects or solutions in your query. For example, if you want to track when updates made to the files in a project, you could use:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\" style=\"padding-bottom: 0px; margin-bottom: 0px;\"><span style=\"font-size: 8.5pt;\"><code class=\"language-cs language-csharp\">var query = await myProject\r\n    .Files\r\n    .With(f =&gt; f.FileName)\r\n    .TrackUpdatesAsync(new TrackerObserver(), CancellationToken.None);\r\n<\/code><\/span><\/pre>\n<p>In this example, the TrackerObserver implements <code>IObserver&lt;IQueryTrackUpdates&lt;IFileSnapshot&gt;&gt;<\/code>, so you can use your own custom logic to handle the update events.<\/p>\n<h5>Query project rules<\/h5>\n<p>Each project in the project query API now contains a RulesResults attribute, which includes a rule name and a list of items. You can access these rules by calling <code>RuleResultsByName()<\/code> for a given configuration.<\/p>\n<pre class=\"prettyprint language-cs language-csharp\" style=\"padding-bottom: 0px; margin-bottom: 0px;\"><span style=\"font-size: 8.5pt;\"><code class=\"language-cs language-csharp\">var results = await querySpace\r\n    .Projects\r\n    .With(p =&gt; p.Path)\r\n    .With(p =&gt; p.ActiveConfigurations\r\n        .With(c =&gt; c.RuleResultsByRuleName(\"CompilerCommandLineArgs\")\r\n            .With(r =&gt; r.RuleName)\r\n            .With(r =&gt; r.Items\r\n                .With(i =&gt; i.Name))))\r\n        .ExecuteQueryAsync();\r\n<\/code><\/span><\/pre>\n<h5>Skip results in a query<\/h5>\n<p>We\u2019ve added the <code>Skip()<\/code> method to enable you to skip results in your query.<\/p>\n<pre class=\"prettyprint language-cs language-csharp\" style=\"padding-bottom: 0px; margin-bottom: 0px;\"><span style=\"font-size: 8.5pt;\"><code class=\"language-cs language-csharp\">var projects = await queryableSpace.Projects\r\n    .With(proj =&gt; proj.Name)\r\n    .Skip(1)\r\n    .ExecuteQueryAsync();\r\n<\/code><\/span><\/pre>\n<p>Here, the first project is skipped, and the remaining projects are returned.<\/p>\n<p>&nbsp;<\/p>\n<h3>We can\u2019t do this without you!<\/h3>\n<p>We need your help as we continue to develop VisualStudio.Extensibility! Please try out this preview release and let us know what you think. Check out the <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\">docs<\/a>, browse the <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/Samples\">code samples<\/a>, and build your <a href=\"https:\/\/aka.ms\/VisualStudio.Extensibility\/FirstExtension\">first extension<\/a>. You can send feedback, report issues, or request features through our <a href=\"https:\/\/github.com\/microsoft\/VSExtensibility\/issues\">issue tracker<\/a>.<\/p>\n<p>You can also find information about <a href=\"https:\/\/github.com\/microsoft\/VSExtensibility\/blob\/main\/docs\/breaking_changes.md\">breaking changes<\/a> and <a href=\"https:\/\/github.com\/microsoft\/VSExtensibility\/blob\/main\/docs\/known_issues.md\">known issues<\/a> at our VisualStudio.Extensibility <a href=\"https:\/\/github.com\/microsoft\/VSExtensibility\">GitHub repo<\/a>.<\/p>\n<p>We\u2019re prioritizing the features that our extenders ask for, so please give VisualStudio.Extensibility a try and share your thoughts with us!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine creating extensions that run faster and smoother than ever before! If you haven&#8217;t been following along lately, we&#8217;ve been working on improving the VisualStudio.Extensibility SDK. VisualStudio.Extensibility helps you build extensions that run outside the main IDE process for improved performance and reliability. With it comes a sleek and intuitive .NET 8-based API and comprehensive, [&hellip;]<\/p>\n","protected":false},"author":108688,"featured_media":249202,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1388],"tags":[294,12,6815],"class_list":["post-249167","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-extensibility","tag-extensions","tag-visual-studio","tag-visual-studio-2022"],"acf":[],"blog_post_summary":"<p>Imagine creating extensions that run faster and smoother than ever before! If you haven&#8217;t been following along lately, we&#8217;ve been working on improving the VisualStudio.Extensibility SDK. VisualStudio.Extensibility helps you build extensions that run outside the main IDE process for improved performance and reliability. With it comes a sleek and intuitive .NET 8-based API and comprehensive, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/249167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/108688"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=249167"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/249167\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/249202"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=249167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=249167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=249167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}