Microsoft enhances Visual Studio extension command practices with CanonicalName focus

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, insert CanonicalName 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.