2
2
{
3
3
// <shortcut id="Show context actions">Alt+Enter</shortcut>
4
4
//
5
- // Used to apply quick fixes to inspections ("squigglies"), or apply
6
- // context specific actions, depending on location of text caret
5
+ // QuickFix 機能を使ってみましょう。
7
6
//
8
- // Also allows searching and applying all ReSharper commands direct
9
- // from the menu.
7
+ // QuickFix は、Inspections (コード検査機能 = 波線で表示されるところ) や、
8
+ // 現在のキャレット位置に応じて ReSharper や Rider が提供する機能を
9
+ // 簡単に (ダイレクトに) 適用することが出来ます。
10
+ //
11
+ // もちろん、メニューから機能を選ぶことで、ReSharper や Rider が提供する
12
+ // 全ての機能を選択して適用することもできます。
13
+ //
14
+ // QuickFix があることは、エディタの左側余白(行番号付近)に表示されます。
15
+ // 例えば、以下のようなバリエーションがあります。
16
+ // - 黄色の電球: 警告の修正
17
+ // - 赤色の電球: エラーの修正
18
+ // - ハンマー : コンテキストアクションの適用 (選択箇所特有の機能適用)
19
+ // - などなど
20
+ //
21
+ // (補足)
22
+ // 「コンテキスト」という言葉は日本語だと「文脈」と翻訳されますが、
23
+ // 「その時の状況」といったイメージで理解すると良いでしょう。
24
+ // ReSharper や Rider は、選択箇所そのものの問題だけでなく、
25
+ // その時の状況 (前後関係やそこに至る文脈) に応じて
26
+ // 推奨する改善や修正を提示してくれます。
27
+ // ソフトウエア業界では、こういった前後関係の文脈や
28
+ // 時間的連続性を言うときに「コンテキスト」という表現を
29
+ // 使うことが多いです。
30
+ // https://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%B3%E3%83%86%E3%82%AF%E3%82%B9%E3%83%88
10
31
//
11
- // Icon is displayed in gutter margin on left of editor, e.g. yellow
12
- // light bulb to fix warning, red light bulb to fix error, hammer to
13
- // apply a context action, etc.
14
32
15
- // 1. Apply QuickFix for an inspection
16
- // The class doesn't match ReSharper's naming style
17
- // Place text caret on "squiggly". Note the lightbulb in the margin on the left
18
- // Click the light bulb, or hit <shortcut id="Show context actions">Alt+Enter</shortcut>
19
- // Select "Rename to 'BadlyNamedClass'" to fix
33
+ // 1. Inspection (コード検査結果) に QuickFix を適用してみます
34
+ // 設定で定義している命名スタイルと一致しないクラス名があったとします。
35
+ // ReSharper や Rider は 波線で教えてくれます。
36
+ //
37
+ // badlyNamedClass に波線が引かれていると思います (*1)。
38
+ // <shortcut id="Show context actions">Alt+Enter</shortcut> を押すか、
39
+ // エディター左側の余白、行番号付近にある電球アイコンをクリックしましょう。
20
40
//
21
- // (More on inspections in section 3)
41
+ // "Rename to 'BadlyNamedClass'" とコードスタイルに設定されている
42
+ // 命名規則に適合した修正が提案されているはずです。選択して修正してみましょう。
43
+ //
44
+ // (*1)
45
+ // もし、badlyNamedClass に波線が引かれていない場合は、
46
+ // あなたが使っている ReSharper や Rider のコードスタイル設定が、
47
+ // この演習が期待している前提と違っている可能性が高いです。
48
+ // コードスタイルの設定に関しては以下を参照してください。
49
+ // https://www.jetbrains.com/resharper/features/code_formatting.html
50
+ //
51
+ // (Inspections (コード検査) については Section 3 で詳しく説明します)
22
52
public class badlyNamedClass
23
53
{
24
54
}
@@ -27,20 +57,42 @@ public class ContextAction
27
57
{
28
58
public static string FormatString ( string arg )
29
59
{
30
- // 2. Apply context action
31
- // Place text caret on "arg"
32
- // Note the hammer action - a context action is available (no squiggly!)
33
- // Hit <shortcut id="Show context actions">Alt+Enter</shortcut>, select "To String.Format invocation"
60
+ // 2. コンテキストアクションを適用してみます
61
+ // 下の "arg" を選択してキャレットを置いてください。
62
+ // ハンマーのアイコンが表示されましたか?
63
+ // コンテキストアクションを使うことが出来ます(波線は出ませんので注意!)。
64
+ // <shortcut id="Show context actions">Alt+Enter</shortcut> を押して、
65
+ // "To String.Format invocation" を選択してください。
66
+ // String.Format 形式に簡単に修正できます。
67
+ //
68
+ // (注意)
69
+ // C#での文字列操作は気付かずパフォーマンス悪化に陥ることが多いです。
70
+ // 言語仕様を理解していないと、メモリ消費、実行速度の2つの面で課題が出ます。
71
+ // メモリ消費の観点では '+' 演算は使うべきではありません。
72
+ // StringBuilder 、または内部的に StringBuilder を使っている
73
+ // 文字列補完機能 '$' を使うべきです。
74
+ // もし、実行速度にこだわるのであればもう少し実装方式を考える必要が出てくるでしょう。
75
+ //
76
+ // String 型と StringBuilder 型 の違い
77
+ // https://docs.microsoft.com/ja-jp/dotnet/api/system.text.stringbuilder?view=net-5.0#the-string-and-stringbuilder-types
78
+ //
79
+ // Performance Of String Concatenation In C# (C#における文字列結合の性能考察)
80
+ // https://dotnetcoretutorials.com/2020/02/06/performance-of-string-concatenation-in-c/
81
+ //
34
82
return "Hello" + arg + "World" ;
35
83
}
36
84
}
37
85
38
- // 3. Go to action
39
- // Place text caret on class name below
40
- // <shortcut id="Show context actions">Alt+Enter</shortcut>, note magnifying glass
41
- // Click magnifying glass, start typing "rename"
42
- // Or, just start typing "rename" from menu
43
- // Filters ReSharper commands and applies
86
+ // 3. Go to action 機能を使ってみます。
87
+ // 下のクラス名のどこかにキャレットを置き、
88
+ // <shortcut id="Show context actions">Alt+Enter</shortcut> を押します。
89
+ //
90
+ // コンテキストメニューが表示されている状態で 'rename' とタイプし、
91
+ // たくさんの機能からフィルターして表示される 'Rename...' を選択します。
92
+ //
93
+ // このように、 ReSharper や Rider は、
94
+ // 様々な場所で直接タイプすることで機能をフィルターし、
95
+ // 直接呼び出すことが出来ます。
44
96
public class GoToAction
45
97
{
46
98
}
0 commit comments