Copilot Chat にプロジェクトに関する具体的な質問や、ソフトウェア全般に関する質問をすることができます。 また、Copilot Chat に、コードの記述、エラーの修正、テストの記述、およびドキュメント コードを依頼することもできます。
上記のタブを使用して、Copilot Chat を使用している環境を選択します。
ソフトウェアに関する一般的な質問を行う
Copilot Chat の一般的なソフトウェアに関する質問をすることができます。 次に例を示します。
tell me about nodejs web server frameworks
how to create an express app
how to update an npm package
プロジェクトに関する質問を行う
プロジェクトに関して Copilot Chat に質問できます。 Copilot に正しいコンテキストを提供するには、次の方法をいくつか試してください。
- 関連するコード行をハイライトする。
- 関連するファイルを開く。
#file
を使って、Copilot に特定のファイルを参照するよう指示します。#solution
を使って、Copilot にアクティブなファイルを参照するよう指示します。
次に例を示します。
what sorting algorithm does this function use
#file:gameReducer.js what happens when a new game is requested
コードの記述
variables.product.prodname_copilot_short %} にコードの記述を依頼できます。 次に例を示します。
write a function to sum all numbers in a list
add error handling to this function
Copilot がコード ブロックを返す際、応答には、コードをコピーするか、新しいファイルに挿入するか、またはコードの出力をプレビューするかのオプションが含まれます。
GitHub Advanced Security 機能のアラートに関して質問する
GitHub Advanced Security 機能 (code scanning、secret scanning、および Dependabot alerts) による組織内リポジトリのセキュリティアラートに関して、Copilot に尋ねることができます。 次に例を示します。
How would I fix this alert?
How many alerts do I have on this pull request?
Which line of code is this code scanning alert referencing?
What library is affected by this Dependabot alert?
コードの修正、改善、リファクタリング
アクティブなファイルにエラーが含まれている場合は、/fix
スラッシュ コマンドを使用して、Copilot にエラーを修正するよう依頼します。
コードを改善またはリファクタリングするための一般的な要求を行うこともできます。
how would you improve this code?
translate this code to C#
add error handling to this function
テストを記述する
/tests
スラッシュ コマンドを使用して、Copilot に、アクティブなファイルまたは選択したコードのテストを記述するように依頼します。 次に例を示します。
/tests
/tests using the Jest framework
/tests ensure the function rejects an empty list
スラッシュ コマンドは /tests
、既存のコードのテストを記述します。 コードを書き込む前にテストを記述する (テスト駆動開発) 場合は、/tests
コマンドを省略します。 次に例を示します。
Add tests for a JavaScript function that should sum a list of integers