ReSharper 2019.1ヘルプ

リファクタリング

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
最終更新日: 2019年7月16日

関連事項

関連ページ:

コンテキスト・アクション

コンテキストアクションのいくつかの例をReSharperWebサイトでチェックすることができます。コンテキストアクションは、エディターで直接利用できるコード変換ヘルパーです。クイックフィックスとは対照的に、コンテキストアクションは問題の解決やコードの改善を目的としているためはなく、アクセス修飾子の変...

コンテキストアクションリファレンス

ReSharperオプションのコード編集 | コンテキスト・アクションページで特定のコンテキストアクションを無効にすることができます。このセクションでは、特定の言語で利用可能なコンテキストアクションの完全なリストを見つけることができます。言語に依存しないコンテキストアクション、C#のコンテキストアク...

ローカライゼーションリファクタリング

ReSharperは、プロジェクトの国際化を大幅に簡素化する一連のリソース関連のリファクタリングを提供します。リソースに移動:プロジェクトの内部化に取り組むときは、ローカライズ可能な文字列をリソースファイルに格納するのが一般的です。ReSharperはローカライズ対象の文字列を検出して強調表示するた...

C++のリファクタリング

C++のサポートは、ReSharper C++(ReSharperと一緒に、またはReSharper Ultimateと別々にまたは並行してインストールできる)の専用製品で使用できます。リファクタリングに加えて、ReSharperはコンテキスト・アクションで利用可能ないくつかの小さなローカルコード変...

ASP.NET用リファクタリング

ASP.NETでは、ReSharperは、ASP.NETファイル内のC#およびVB .NETコードで利用可能なメインセットリファクタリング、およびリソースの用途で利用可能なローカライズリファクタリングをサポートしています。ASP.NETに固有のいくつかのリファクタリングもあります。リファクタリングに...

TypeScriptのリファクタリング

リファクタリングに加えて、ReSharperはコンテキスト・アクションで利用可能ないくつかの小さなローカルコード変換を提供します。ReSharperは、TypeScriptに対して以下のリファクタリングを提供します。型のコピーフィールドの導入タイプエイリアスを導入するインライン型エイリアス変数を導入...