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.NETLanguage: C++Language: HTMLLanguage: ASP.NETLanguage: RazorLanguage: JavaScriptLanguage: TypeScriptLanguage: CSSLanguage: XMLLanguage: XAMLLanguage: ResxLanguage: Build ScriptsLanguage: ProtobufLanguage: JSON
リファクタリングFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is not available
シグネチャーの変更Feature is availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
抽象クラスをインターフェースに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
匿名を名前付き型に変換するFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
エクステンションメソッドを静的に変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
インデクサーをメソッドに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
インターフェースを抽象クラスに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メソッドをインデクサに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メソッドをプロパティーに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
プロパティを自動プロパティに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
プロパティをメソッドに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
静的メソッドを拡張メソッドに変換するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
型のコピーFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
フィールドのカプセル化Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
クラスの抽出Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
インターフェースの抽出Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メソッドの抽出Feature is availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
「スーパークラスの抽出」リファクタリングFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
CSSスタイルを抽出するFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
XAMLリソースを抽出するFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
XAMLスタイルを抽出するFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
クラスのインライン化Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
フィールドのインライン化Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メソッドのインライン化Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
パラメーターのインライン化Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
インラインリソースFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not available
インラインXAMLリソースFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
変数のインライン化Feature is availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
フィールドの導入Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
ネームスペースエイリアスを導入するFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
パラメーターの導入Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
タイプエイリアスを導入するFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
インライン型エイリアスFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
変数を導入するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
部分文字列の変数を導入するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
真偽の逆転Feature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メソッドを非静的にするFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メソッド/プロパティを静的にするFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
部分的にするFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
インスタンス・メソッドの移動Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
リソースの移動Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not available
リソースに移動Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
タイプを別のファイルに移動するFeature is availableFeature is availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
フォルダへ移動Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
別のタイプに移動するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
型を別の名前空間/モジュールに移動するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
タイプを外部スコープに移動するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メンバーのプル・アップFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
メンバーのプッシュ・ダウンFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
名前変更Feature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is availableFeature is not available
コンストラクターをファクトリー・メソッドで置換Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
安全な削除Feature is availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is availableFeature is availableFeature is not availableFeature is not available
変換パラメータFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
可能な場合はベースタイプを使用するFeature is availableFeature is availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is not availableFeature is availableFeature is not availableFeature is not availableFeature is not availableFeature is not available
最終変更日: 2018年9月12日

関連事項