ReSharper 2019.2ヘルプ

リファクタリング

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

サポートされている言語およびプロジェクト項目のほとんどでリファクタリングが利用可能です。特定のリファクタリングについてさらに学習するには、以下のセクションを調べましょう。

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

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

  2. 以下のいずれか 1 つを実行します:

    • メインメニューでReSharper | リファクタリングを選択してから、必要なリファクタリングを選択します。このメニューで利用可能なリファクタリングのリストは現在の状況に依存します。ReSharperがコンテキストのリファクタリングを提案できない場合は、メニュー全体が無効になります。

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

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

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

  3. 選択したリファクタリングにユーザー入力が必要な場合は、リファクタリングウィザードが開きます。ウィザードのダイアログはモーダルではないため、ウィザードが開いている間にコードを編集できます。

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

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

エディターでコードを変更した直後に利用できるリファクタリングもあります。詳しくは、インプレース・リファクタリングを参照してください。

ReSharperのほとんどのリファクタリングはC#とVisual Basic .NETで利用可能です、いくつかはいくつかの言語で利用可能です、他は言語特有です。以下の表は、それらがサポートされているすべてのリファクタリングと言語/テクノロジの一覧です。

このセクションのトピックで説明されている手順と例は、C#でのリファクタリングの使用を扱います。特定の言語で使用可能なリファクタリングの詳細については、言語によるReSharperセクションの対応するトピックを参照してください。

リファクタリング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年11月13日

関連ページ:

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

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

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

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

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

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に対して以下のリファクタリングを提供します。型をコピー、フィールドの導入、型エイリアスの紹介、インライン型エイリアス、変数を導入...