ReSharper 2018.2ヘルプ

リファクタリング

ReSharperは、シンボルの名前の変更、移動、および安全な削除を可能にする広範な自動化されたソリューション全体のコードリファクタリングを提供します。フィールド、変数、またはパラメータを導入してインライン化し、より多くの変換を無駄なく実行します。

リファクタリングは、サポートされているほとんどの言語およびプロジェクト項目で利用できます。特定のリファクタリングの詳細については、次のセクションを参照してください。

リファクタリングを実行するには

  1. 記号でキャレットを設定し、リファクタリングするコードフラグメントを選択するか、ツールウィンドウで項目を選択します。

  2. 以下のいずれか 1 つを実行します:
    • メインメニューで、ReSharper | リファクタリングを選択し、目的のリファクタリングを選択します。このメニューで使用可能なリファクタリングのリストは、現在のコンテキストによって異なります。 ReSharperがコンテキストのリファクタリングを示唆できない場合、メニュー全体が無効になります。

    • エディタ、ファイル構造ウィンドウ、または他のReSharperウィンドウで、変換するアイテムを右クリックし、コンテキストメニューからリファクタリングを選択し、必要なリファクタリングを選択します。

    • メインメニューで、ReSharper | リファクタリング | リファクタリングを選択するか、または Ctrl+Shift+R を押して適用可能なリファクタリングのリストを表示し、それらのいずれかを選択します。また、選択項目のコンテキストメニューでリファクタリングを選択することもできます。

    • 特定のリファクタリングに割り当てられたデフォルトのキーボードショートカット、または好きなリファクタリングコマンドに カスタムショートカットを割り当てるを使用します。

  3. 選択したリファクタリングにユーザー入力が必要な場合は、リファクタリングウィザードが開きます。ウィザードのダイアログはモーダルではないので、ウィザードが開いている間にコードを編集できます。
    リファクタリングアクションをロールバックするには、ウィザードにオプション元に戻すを有効にするには、編集のための変更を含むすべてのファイルを開きますが表示されます。このオプションを選択すると、ReSharperはすべての変更されたファイルを新しいエディタタブで開き、リファクタリングをロールバックすることができます。この場合、変更内容を自分で保存する必要があります。このオプションを選択しないと、ReSharperは変更したファイルを開かずに自動的に保存します。

  4. リファクタリング操作によってコードの競合(名前の重複、可視性の競合など)が発生した場合、リファクタリングを適用する前に、ウィザードは最後のステップで競合のリストを表示します。いくつかの競合については、ウィザードでクイックフィックスを提案することもできます。詳細は、リファクタリングにおける競合の解決を参照してください。

一部のリファクタリングは、エディタでコードを変更した直後に使用できます。詳細については、インプレースリファクタリングを参照してください。

ReSharperのリファクタリングのほとんどは、C#およびVisual Basic .NETで利用可能であり、いくつかは複数の言語で利用可能であり、その他は言語固有です。以下の表は、サポートされているすべてのリファクタリングと言語/テクノロジを示しています。

ここでは、C#でのリファクタリングの使用について説明します。特定の言語で使用できるリファクタリングの詳細については、言語によるReSharperの該当するトピックを参照してください。

リファクタリング

Language: C#

Language: VB.NET

Language: C++

Language: HTML

Language: ASP.NET

Language: Razor

Language: JavaScript

Language: TypeScript

Language: CSS

Language: XML

Language: XAML

Language: Resx

Language: Build Scripts

Language: Protobuf

Language: JSON

リファクタリング

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is not available

シグネチャーの変更

Feature is available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

抽象クラスをインターフェースに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

匿名を名前付き型に変換する

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

エクステンションメソッドを静的に変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

インデクサーをメソッドに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

インターフェースを抽象クラスに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メソッドをインデクサに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メソッドをプロパティーに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

プロパティを自動プロパティに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

プロパティーをメソッドに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

静的メソッドを拡張メソッドに変換する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

型のコピー

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

フィールドのカプセル化

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

クラスの抽出

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

インターフェースの抽出

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メソッドの抽出

Feature is available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

「スーパークラスの抽出」リファクタリング

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

CSSスタイルを抽出する

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

XAMLリソースを抽出する

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

XAMLスタイルを抽出する

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

クラスのインライン化

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

フィールドのインライン化

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メソッドのインライン化

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

パラメーターのインライン化

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

インラインリソース

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

インラインXAMLリソース

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

変数のインライン化

Feature is available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

フィールドの導入

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

ネームスペースエイリアスを導入する

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

パラメーターの導入

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

タイプエイリアスを導入する

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

インライン型エイリアス

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

変数を導入する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

部分文字列の変数を導入する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

真偽の反転

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メソッドを非静的にする

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メソッド/プロパティを静的にする

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

部分的にする

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

インスタンス・メソッドの移動

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

リソースの移動

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

リソースに移動

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

タイプを別のファイルに移動する

Feature is available

Feature is available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

フォルダへ移動

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

別のタイプに移動する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

型を別の名前空間/モジュールに移動する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

タイプを外部スコープに移動する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メンバーのプル・アップ

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

メンバーのプッシュ・ダウン

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

名前変更

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is available

Feature is not available

コンストラクターをファクトリー・メソッドで置換

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

安全な削除

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is available

Feature is available

Feature is not available

Feature is not available

変換パラメータ

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

可能な場合はベースタイプを使用する

Feature is available

Feature is available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

Feature is available

Feature is not available

Feature is not available

Feature is not available

Feature is not available

最終更新日: 2018年11月5日

関連事項