Microsoft has released new guidance to help developers improve the behavior and design of Visual Studio extension commands, with a focus on proper use of the CanonicalName property. This update encourages clearer, more consistent command structures to enhance usability and maintainability in custom tools.
Here’s how:
Why add CanonicalName? It makes commands more predictable, improves user experience with consistent behavior, and simplifies integration without locale-specific handling.
Step 1: Find your .vsct file Locate the
.vsct
(Visual Studio Command Table) file—typically in the root of your extension project.Step 2: Add CanonicalName: Within
<Button>
,<Combo>
, or<Menu>
elements, insertCanonicalName
as a child of the<Strings>
element.Step 3: Ensure uniqueness: Assign a unique and meaningful
CanonicalName
to each command to avoid conflicts and clearly reflect its purpose.Best practices: Use PascalCase, avoid localization, start with a period, and begin with your extension name for clarity and structure.