ReSharper 2025.1 ヘルプ

リファクタリング

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

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

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

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

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

    • メインメニューから ReSharper | リファクタリングを選択し、目的のリファクタリングを選択します。このメニューで使用できるリファクタリングのリストは、現在のコンテキストによって異なります。ReSharper がコンテキストのリファクタリングを提案できない場合、メニュー全体が無効になります。

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

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

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

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

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

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

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

ReSharper のリファクタリングのほとんどは C# と Visual Basic で利用できます。一部は複数の言語で利用でき、他は言語固有です。以下の表は、サポートされているすべてのリファクタリングと言語 / テクノロジを示しています。

このセクション内のトピックに示されている手順と例では、C# でのリファクタリングの使用について説明します。特定の言語で使用できるリファクタリングの詳細については、言語およびフレームワークセクションの対応するトピックを参照してください。

リファクタリング

Language: C#

Language: VB.NET

Language: C++

Language: ASP.NET

Language: Razor

Language: XAML

Language: Resx

Language: Build Scripts

リファクタリング

Feature is available in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is available in ASP.NET

Feature is available in Razor

Feature is available in XAML

Feature is available in Resource files

Feature is available in build script files

シグネチャーの変更

Feature is available in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

匿名から名前付き型に変換

Feature is available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

拡張メソッドをプレーンスタティックに変換

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

スコープ付き列挙型に変換

Feature is not available in C#

Feature is not available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

型をコピー

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

フィールドのカプセル化

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

クラスの抽出

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

インターフェースの抽出

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

メソッドの抽出

Feature is available in C#

Feature is available in Visual Basic

Extract method in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

を使用してグローバルに変換するリファクタリング

Feature is available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

CSS スタイルの抽出

Feature is not available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is available in ASP.NET

Feature is available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

XAML リソースの抽出

Feature is not available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

XAML スタイルを抽出

Feature is not available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

クラスのインライン化

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

メソッドのインライン化

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

非グローバルに変換する方法リファクタリング

Feature is available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

インラインリソース

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is available in Resource files

Feature is not available in build script files

インライン XAML リソース

Feature is not available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

変数のインライン化

Feature is available in C#

Feature is not available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

フィールドの導入

Feature is available in C#

Feature is available in Visual Basic

Introduce field in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

ネームスペースエイリアスの紹介

Feature is not available in C#

Feature is not available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

パラメーターの導入

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

型エイリアスの導入

Feature is not available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

typedef の導入

Feature is not available in C#

Feature is not available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

列挙型を使用して紹介する

Feature is not available in C#

Feature is not available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

型エイリアスのインライン化

Feature is not available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

Typedef のインライン化

Feature is not available in C#

Feature is not available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

変数の導入

Feature is available in C#

Feature is available in Visual Basic

Introduce variable in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

ブール値の反転

Feature is available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

メソッドを非静的にする

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

部分的にする

Feature is available in C#

Feature is not available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

リソースの移動

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is available in Resource files

Feature is not available in build script files

リソースに移動

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is available in ASP.NET

Feature is available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

型を別のファイルに移動

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

フォルダーに移動

Feature is available in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

別の型に移動

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

型を別のネームスペース / モジュールに移動する

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

型を外部スコープに移動

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

メンバーのプルアップ

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

名前変更

Feature is available in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is available in ASP.NET

Feature is available in Razor

Feature is available in XAML

Feature is available in Resource files

Feature is available in build script files

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

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

安全な削除

Feature is available in C#

Feature is available in Visual Basic

Feature is available in C++

Feature is available in ASP.NET

Feature is available in Razor

Feature is available in XAML

Feature is available in Resource files

Feature is available in build script files

パラメーター修飾子の追加 / 削除

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

変換パラメーター

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

可能な限り基本型を使用する

Feature is available in C#

Feature is available in Visual Basic

Feature is not available in C++

Feature is available in ASP.NET

Feature is not available in Razor

Feature is available in XAML

Feature is not available in Resource files

Feature is not available in build script files

関連ページ:

コンテキストアクション

コンテキストアクションは、エディターで直接利用できるコード変換ヘルパーです。クイックフィックスとは対照的に、コンテキストアクションは問題の解決やコードの改善を目的としているためはなく、アクセス修飾子の変更、null をチェックするコードの生成、'foreach' の 'for' への変換などの小さな変更をすばやく導入できます。ReSharper は、サポートされているすべての言語で数百のコンテキストアクションを提供します。完全なリストは、ReSharper オプション Alt+R, O のページとコ...

リファクタリングのメインセット

このセクションでは、C# でサポートされているリファクタリングについて学習できます。これらのリファクタリングのほとんどは、Visual Basic やその他の言語でもサポートされています。シグネチャーの変更、抽象クラスをインターフェースに変換、匿名から名前付き型に変換、拡張メソッドをプレーンスタティックに変換、インデクサーをメソッドに変換、インターフェースを抽象クラスに変換、メソッドをインデクサーに変換、メソッドをプロパティに変換する、プロパティを自動プロパティに変換、プロパティをメソッドに変換...

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

ReSharper は、プロジェクトの国際化を大幅に簡素化する一連のリソース関連のリファクタリングを提供します。リソースに移動:プロジェクトの内部化に取り組むときは、ローカライズ可能な文字列をリソースファイルに格納するのが一般的です。ReSharper はローカライズ対象の文字列を検出してハイライトするため、そのような文字列を簡単に見つけてソースコードからリソースファイルに移動できます。ReSharper は対応するリソースエントリを宣言し、コード内の文字列をリソース使用量に置き換えます。ロー...

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

リファクタリングを実行するシンボルにキャレットを置き、リファクタリングするコードフラグメントを選択するか、ツールウィンドウ内の項目を選択します。以下のいずれか 1 つを実行します: メインメニューからを選択し、目的のリファクタリングを選択します。このメニューで使用できるリファクタリングのリストは、現在のコンテキストによって異なります。ReSharper がコンテキストのリファクタリングを提案できない場合、メニュー全体が無効になります。エディター、ファイル構造ウィンドウ、またはその他の ReShar...

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

ASP.NET では、ReSharper は、ASP.NET ファイル内の C# および VB .NET コードで使用できるリファクタリングのメインセットと、リソースの使用に使用できるローカライゼーションリファクタリングをサポートしています。このトピックでは、ASP.NET に固有のリファクタリングを一覧表示します。リファクタリングを実行するシンボルにキャレットを置き、リファクタリングするコードフラグメントを選択するか、ツールウィンドウ内の項目を選択します。以下のいずれか 1 つを実行します: メ...

TypeScript のリファクタリング

リファクタリングを実行するシンボルにキャレットを置き、リファクタリングするコードフラグメントを選択するか、ツールウィンドウ内の項目を選択します。以下のいずれか 1 つを実行します: メインメニューからを選択し、目的のリファクタリングを選択します。このメニューで使用できるリファクタリングのリストは、現在のコンテキストによって異なります。ReSharper がコンテキストのリファクタリングを提案できない場合、メニュー全体が無効になります。エディター、ファイル構造ウィンドウ、またはその他の ReShar...