---
# System prepended metadata

title: Visual Studio 拡張機能 2022-01-18
tags: [VSIX, Visual Studio 拡張機能, Visual Studio 2022, VSSDK]

---

---
lang: ja-jp
breaks: true
---
# Visual Studio 拡張機能 2022-01-18

> Getting started writing Visual Studio extensions
> https://devblogs.microsoft.com/visualstudio/getting-started-writing-visual-studio-extensions/

> Visual Studio Extensibility Checklist
> https://gist.github.com/madskristensen/7310c0d61694e323f4deeb5a70f35fec

> Visual Studio 機能拡張
> https://docs.microsoft.com/ja-jp/visualstudio/extensibility/


## `Microsoft.VisualStudio.SDK.Analyzers` 拡張機能

```xml=
  <ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.SDK.Analyzers">
      <Version>16.10.10</Version>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

```

## サンプルリポジトリ

> microsoft/VSSDK-Extensibility-Samples
> https://github.com/Microsoft/VSSDK-Extensibility-Samples

## IWpfTextView

> How to get IWpfTextView from command Visual Studio Extension 2017
> https://stackoverflow.com/questions/45751908/how-to-get-iwpftextview-from-command-visual-studio-extension-2017

## IEditorOperationsFactoryService


## KeyBinding

https://stackoverflow.com/questions/31337319/vs-2013-sdk-how-to-keybind-hotkey-only-for-code-window-editor

```xml=
<KeyBindings>
    <KeyBinding
          guid="guidVSIXProject8PackageCmdSet"
          id="cmdidEditorCursorMoveDown"
          editor="guidCShapeCodeTextEditor"
          key1="VK_DOWN"
          mod1="Control Alt"
          />
    <KeyBinding
          guid="guidVSIXProject8PackageCmdSet"
          id="cmdidEditorCursorMoveUp"
          editor="guidCShapeCodeTextEditor"
          key1="VK_UP"
          mod1="Control Alt"
          />
</KeyBindings>

<Symbols>
    <GuidSymbol name ="guidCShapeCodeTextEditor" value="{A6C744A8-0E4A-4FC6-886A-064283054674}" />
</Symbols>
```

:::info
mod1、mod2：`Key modifier may be a combination of 'Control', 'Alt' and 'Shift' delimited by space`
:::

:::info
`editor` とその `GuidSymbol` について

スコープを`テキストエディタ`にする場合は、`GUID_TextEditorFactory`を指定する。
> https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb131539(v=vs.110)
> https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb163249(v=vs.110)
:::

:::warning
スコープに`C#エディタ` `{A6C744A8-0E4A-4FC6-886A-064283054674}` を指定してみたが、正常に動作しなかった。

> psxvoid/editor-guids-vs2019-community.xml
> https://gist.github.com/psxvoid/22699b898b2c0cc5b7d5135ccee53298
:::

###### tags: `VSIX` `Visual Studio 拡張機能` `VSSDK` `Visual Studio 2022`
