Skip to content

Commit af8399f

Browse files
Merge pull request #10255 from MicrosoftDocs/main638520842492838657sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 1c1d110 + faec9c2 commit af8399f

28 files changed

+670
-41
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: VisualStudio.Extensibility Diagnostics Explorer extension overview
3+
description: VisualStudio.Extensibilityo Diagnostics Explorer extension
4+
author: RyanToth3
5+
ms.author: rytoth
6+
monikerRange: ">=vs-2022"
7+
ms.subservice: extensibility-integration
8+
ms.topic: overview
9+
ms.date: 05/09/2024
10+
---
11+
12+
# Overview
13+
14+
The VisualStudio.Extensibility Diagnostics Explorer extension is designed to help debug VisualStudio.Extensibility extensions while developing them. The target audience for this extension is extension authors, not extension consumers. This extension provides an interface for inspecting the extensibility points that extensions are interacting with, and what configuration objects extensions are providing to the IDE, and the metadata of those configuration objects.
15+
16+
## Get Started
17+
18+
Follow these instructions to install, launch, and configure the Diagsnotics Explorer.
19+
20+
### Install the Extension
21+
22+
You can get the Diagnostics Explorer either directly through the Extension Manager in Visual Studio, or from the Visual Studio Marketplace [here](https://aka.ms/VisualStudio.Extensibility/DiagnosticsExplorer).
23+
24+
> [!NOTE]
25+
> The VisualStudio.Extensibility Diagnostics Explorer extension is compatable with Visual Studio 2022 17.10 and higher.
26+
27+
### Open the Diagnostics Explorer in Visual Studio
28+
29+
To launch the Diagnostics Explorer in Visual Studio, select **VisualStudio.Extensibility Diagnostics Explorer** in the **Extensions** menu.
30+
31+
![Screenshot of the command that opens the extension's tool window.](./media/image-1.png)
32+
33+
### Enable collection of diagnostics
34+
35+
The Diagnostics Explorer is configured to collect relevant diagnostic data from your extensions by default. If you want to disable or re-enable this data collection, you can toggle the **Enable collecting diagnostics** checkbox at the lower-left corner of the tool window. A restart of Visual Studio is required for any changes to this setting to take effect.
36+
37+
![Screenshot of the "Enable collecting diagnostics" setting.](./media/image-11.png)
38+
39+
## Diagnostics Pages
40+
41+
The left-hand panel of the Diagnostics Explorer tool window contains a list different *feature pages*. These pages correspond to the extensible features for which you can find diagnostic information about the components and configurations that Visual Studio discovered from your extensions. For example, you can select **Commands** to view diagnostics related to your commands, command sets, menus and toolbars, placements, and more.
42+
43+
Also in the list are two special pages that aren't directly related to any components in your extension: [**Events**](#events-page), a live viewer for extensibility-related events, and [**Activation Constraints**](#activation-constraints-page), which shows relevant IDE state to help you craft your activation constraints.
44+
45+
![Screenshot of the left hand panel of the tool window.](./media/image-2.png)
46+
47+
### Extensible Feature Pages
48+
49+
Extensible feature pages have a ComboBox in the top-left for the different **Extensibility Points** in that feature area, each of which can be mapped directly to configuration objects in your extension. For example, in the **Commands** page there's an **Extensibility Point** for **Menus and Toolbars**, which shows you each of the menus and toolbars that Visual Studio discovered in your VisualStudio.Extensibility extensions.
50+
51+
The data updates in real time as properties are updated in extensions. For example, if an extension changes the display name of one of its commands at runtime, the new display name of that command is shown in the cell in the **Display Name** column for that command immediately.
52+
53+
![Screenshot of the Commands page.](./media/image-3.png)
54+
55+
The **Extensibility Point** ComboBox also has an item called **Log**, which shows you a live view of those updates. The **Clear All** button beside the ComboBox can be used to clear all lines currently being displayed in the view.
56+
57+
![Screenshot of the Command's Log page.](./media/image-4.png)
58+
59+
You can filter the items in the view by using the **Extensions** ComboBox. When **All** is selected in this ComboBox, data for every installed VisualStudio.Extensibility extension is shown. If you change this ComboBox to the ID of a specific extension, only items related to that specific extension are shown. The value of this ComboBox is persisted even when you navigate between extensible feature pages.
60+
61+
![Screenshot of the Command's page filtered to a specific extension.](./media/image-5.png)
62+
63+
Some cells in the DataGrid display **[Click to Expand]**. This message means that the metadata related to that property is too verbose to be neatly displayed in a cell of the DataGrid. Clicking on the cell opens a modal dialog displaying the actual value of that cell.
64+
65+
![Screenshot of the "Click to Expand" modal dialog."](./media/image-6.png)
66+
67+
### Events Page
68+
69+
The events page shows you when "something happens" in the IDE. Each event appears as a new row in the DataGrid, along with any properties related to that event. For example, when a command is executed, a **Commands - Executing** event appears in the view showing the ID of the extension that the command belongs to and the ID of the command that was executed.
70+
71+
You can use the **Event** ComboBox to filter the view to only contain events with a specific name. When **All** is selected, then all events are shown. If a specific event is selected, all of the properties of the event are shown in the view. Some properties need to be expanded by clicking on **[Click to Expand]** if they're too verbose to be shown in a single cell.
72+
73+
The **Contract** ComboBox filters the view to only show events related to a specific extensible feature. It also filters the `Event` ComboBox to only contain the names of events related to the specific extensible feature.
74+
75+
Clicking the **Clear All** button deletes all the events currently shown in the view.
76+
77+
![Screenshot of the Events page.](./media/image-7.png)
78+
79+
#### Column Descriptions
80+
81+
##### Extension ID
82+
83+
The **Extension Id** column shows the ID of the extension that the instance of the event is related to. It's possible for this cell to be empty for some events if they don't belong to a specific extension but instead apply to the IDE as a whole.
84+
85+
##### Item ID
86+
87+
The **Item Id** column shows the ID of the extension item that the instance of the event is related to. For example, the **Item Id** for the **Commands - Executing** event would be the ID of the command that was executed.
88+
89+
##### Properties
90+
91+
The **Properties** column shows the set of properties related to that instance of the event that could be displayed in a single cell in a DataGrid. More verbose properties would only be visible from the **More Info** dialog, or by changing the **Event** ComboBox to the name of the specific event that you're interested in.
92+
93+
##### More Info
94+
95+
The **More Info** column displays more verbose metadata related to an event. Clicking a cell in this column opens a modal dialog containing all of the metadata related to the event represented by that row.
96+
97+
![Screenshot of the More Info dialog.](./media/image-8.png)
98+
99+
### Activation Constraints Page
100+
101+
The activation constraints page shows the state of various properties related to the IDE itself. The **Context** ComboBox changes the data in the view to either show all of the activation constraints related to the currently selected item in the **Acitvation Constraints** ComboBox, or a log of all the times these properties changed since the tool window was opened. When the **Events** context is selected, the **Clear All** button can be used to delete all the events currently being displayed in the view.
102+
103+
![Screenshot of the Activation Constraint's Current State page.](./media/image-9.png)
104+
105+
![Screenshot of the Activation Constraint's Events page.](./media/image-10.png)

docs/extensibility/visualstudio.extensibility/get-started/debug-extensions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ There is some internal code in the ServiceHub host process that handles the RPC
4343
> [!TIP]
4444
> It can be convenient to have multiple monitors, so you can see both the debugger and the experimental instance at the same time on two different monitors. You might want to change the theme in the Experimental Instance to make it more obvious which IDE you're working with at any given time. See [Change fonts, colors, and themes in Visual Studio](../../../ide/how-to-change-fonts-and-colors-in-visual-studio.md).
4545
46+
## Debug the extension using the Diagnostics Explorer
47+
48+
Please see [VisualStudio.Extensibility Diagnostics Explorer](../diagnostics/visualstudio-extensibility-diagnostics-extension.md) for more information.
49+
4650
## Related content
4751

4852
- [Learn more about debugging](/visualstudio/debugger/)

docs/extensibility/visualstudio.extensibility/inside-the-sdk/activation-constraints.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.subservice: extensibility-integration
1212

1313
# Rule-based activation constraints
1414

15-
One of the common concepts in VisualStudio.Extensibility is use of context-based activation rules. These are rules that govern the conditions under which an extension or a command is surfaced to the user. An example of a context-based activation rule is the [`VisibleWhen`](/dotnet/api/microsoft.visualstudio.extensibility.commands.commandconfiguration.visiblewhen) property in a command's configuration that declares when the command is made visible.
15+
One of the common concepts in VisualStudio.Extensibility is the use of context-based activation rules. These rules govern the conditions under which an extension or a command is surfaced to the user. An example of a context-based activation rule is the [`VisibleWhen`](/dotnet/api/microsoft.visualstudio.extensibility.commands.commandconfiguration.visiblewhen) property in a command's configuration that declares when the command is made visible.
1616

1717
## Constraint types
1818

@@ -22,7 +22,7 @@ Multiple activation constraints can be combined together using the [`And`](/dotn
2222

2323
## Example definition
2424

25-
In the following example, the command configuration property [`EnabledWhen`](/dotnet/api/microsoft.visualstudio.extensibility.commands.commandconfiguration.enabledwhen) defines when the command is in the enabled state. The [`ClientContext`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.clientcontext) method is one of the activation constraint factory methods. It generates the activation constraint, given the two arguments, a string and regular expression pattern to match against that string. Therefore, the following code indicates that a command is enabled when the user has selected a file with one of those extensions.
25+
In the following example, the command configuration property [`EnabledWhen`](/dotnet/api/microsoft.visualstudio.extensibility.commands.commandconfiguration.enabledwhen) defines when the command is in the enabled state. The [`ClientContext`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.clientcontext) method is one of the activation constraint factory methods. It generates the activation constraint, given the two arguments, a string and regular expression pattern to match against that string. Therefore, the following code indicates that a command is enabled when the user selects a file with one of those extensions.
2626

2727
```csharp
2828
public override CommandConfiguration CommandConfiguration => new("%My command.DisplayName%")
@@ -64,6 +64,7 @@ This section shows the list of currently supported activation constraints. Each
6464
| [`ProjectAddedItem`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.projectaddeditem)(\<pattern>=\<regex>) | The term is true when a file matching the "pattern" is added to a project in the solution that is opened. |
6565
| [`SolutionHasProjectCapability`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.solutionhasprojectcapability)(\<expression>=[`ProjectCapability`](/dotnet/api/microsoft.visualstudio.extensibility.projectcapability)) | True whenever solution has a project with capabilities matching the provided subexpression. An expression can be something like `VB | CSharp`. For more about project capabilities, see [Project query API overview](../project/project.md). |
6666
| [`SolutionState`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.solutionstate)(\<state>=[`SolutionState`](/dotnet/api/microsoft.visualstudio.extensibility.solutionstate)) | True when solution state matches the provided value, see [solution states](#solution-states) for list of values. |
67+
| [`EditorContentType`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.editorcontenttype)(\<contentType>) | True when active editor content type is or inherits from specific content type.
6768

6869
For compatibility reasons, the following legacy activation constraints are also supported:
6970

@@ -73,6 +74,7 @@ For compatibility reasons, the following legacy activation constraints are also
7374
| [`ActiveProjectFlavor`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.activeprojectflavor)(\<guid>) | True whenever the selected project has a flavor matching the given project type GUID. |
7475
| [`SolutionHasProjectBuildProperty`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.solutionhasprojectbuildproperty)(\<property>=\<regex>) | The term is true when solution has a loaded project with the specified build property and property value matches to regex filter provided. |
7576
| [`SolutionHasProjectFlavor`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.solutionhasprojectflavor)(\<guid>) | True whenever a solution has project that is flavored (aggregated) and has a flavor matching the given project type GUID. |
77+
| [`UIContext`](/dotnet/api/microsoft.visualstudio.extensibility.activationconstraint.uicontext)(\<guid>) | True when specified [UI Context](/dotnet/api/microsoft.visualstudio.vsconstants.uicontext) is active in Visual Studio instance. |
7678

7779
## Solution states
7880

docs/extensibility/visualstudio.extensibility/inside-the-sdk/advanced-remote-ui.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You'll learn about:
2323
- How reference types are handled in the Remote UI data context and its proxy.
2424
- How to use an *async command* as an event handler.
2525
- How to disable a single button when its *async command*'s callback is executing if multiple buttons are bound to the same command.
26+
- How to use XAML resource dictionaries from a Remote UI control.
2627
- How to use WPF types, like complex brushes, in the Remote UI data context.
2728
- How Remote UI handles threading.
2829

@@ -261,6 +262,74 @@ In this case, we use `vs:EventHandler` to attach to each button its own separate
261262

262263
![Diagram of async Command with targeted RunningCommandsCount.](./media/targeted-counter.gif)
263264

265+
## User XAML resource dictionaries
266+
267+
Starting with Visual Studio 17.10, Remote UI supports [XAML resource dictionaries](/windows/apps/design/style/xaml-resource-dictionary). This allows multiple Remote UI controls to share styles, templates, and other resources. It also allows you to define different resources (E.g., strings) for different languages.
268+
269+
Similarly to a Remote UI control XAML, resource files must be configured as embedded resources:
270+
271+
```xml
272+
<ItemGroup>
273+
<EmbeddedResource Include="MyResources.xaml" />
274+
<Page Remove="MyResources.xaml" />
275+
</ItemGroup>
276+
```
277+
278+
Remote UI references resource dictionaries in a different way than WPF: they are not added to the control's merged dictionaries (merged dictionaries are not supported at all by Remote UI) but referenced by name in the control's .cs file:
279+
280+
```cs
281+
internal class MyToolWindowContent : RemoteUserControl
282+
{
283+
public MyToolWindowContent()
284+
: base(dataContext: new MyToolWindowData())
285+
{
286+
this.ResourceDictionaries.AddEmbeddedResource(
287+
"MyToolWindowExtension.MyResources.xaml");
288+
}
289+
...
290+
```
291+
292+
`AddEmbeddedResource` takes the full name of the embedded resource which, by default, is composed of the root namespace for the project, any subfolder path it may be under, and the file name. It is possible to override such name by setting a `LogicalName` for the `EmbeddedResource` in the project file.
293+
294+
The resource file itself is a normal WPF resource dictionary:
295+
296+
```xml
297+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
298+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
299+
xmlns:system="clr-namespace:System;assembly=mscorlib">
300+
<system:String x:Key="removeButtonText">Remove</system:String>
301+
<system:String x:Key="addButtonText">Add color</system:String>
302+
</ResourceDictionary>
303+
```
304+
305+
You can reference a resource from the resource dictionary in the Remote UI control using `DynamicResource`:
306+
307+
```xml
308+
<Button Content="{DynamicResource removeButtonText}" ...
309+
```
310+
311+
## Localizing XAML resource dictionaries
312+
313+
Remote UI resource dictionaries can be localized in the same way as you would localize embedded resources: you create other XAML files with the same name and a language suffix, for example `MyResources.it.xaml` for Italian resources:
314+
315+
```xml
316+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
317+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
318+
xmlns:system="clr-namespace:System;assembly=mscorlib">
319+
<system:String x:Key="removeButtonText">Rimuovi</system:String>
320+
<system:String x:Key="addButtonText">Aggiungi colore</system:String>
321+
</ResourceDictionary>
322+
```
323+
324+
You can use wildcards in the project file to include all localized XAML dictionaries as embedded resources:
325+
326+
```xml
327+
<ItemGroup>
328+
<EmbeddedResource Include="MyResources.*xaml" />
329+
<Page Remove="MyResources.*xaml" />
330+
</ItemGroup>
331+
```
332+
264333
## Use WPF types in the data context
265334

266335
Until now, the data context of our *remote user control* has been composed of primitives (numbers, strings, etc.), observable collections and our own classes marked with `DataContract`. it's sometimes useful to include simple WPF types in the data context like complex brushes.

0 commit comments

Comments
 (0)