Skip to content

Latest commit

 

History

History
43 lines (28 loc) · 1.89 KB

File metadata and controls

43 lines (28 loc) · 1.89 KB

Step 4: Using comments to generate code with Copilot

Nicely done utilizing the Copilot tab! 🥳

You now have leveraged the Copilot quick tab auto-suggest as well as the Copilot hub to accept AI generated suggestions.

Now lets see how you can leverage comments to generate Copilot suggestions!

⌨️ Activity: Generate Copilot suggested code from comments.

  1. From inside the codespace in the Solution Explorer, right click on the project, create a new file.

Note: If you closed the Codespace from above please open it back up or create a new Codespace.

  1. Select Class and name the file Comments.cs

  2. Type the following comment into the file inside of the Comments class:

    // create a method that generates a comment for a given skill
    
  3. Press enter to go to a new line.

  4. Copilot will suggest a code block.

  5. Hover over the red squiggly and select the ...

    Note If you don't see the copilot code block suggestion or the red squiggly and the three dots ..., you can type control + enter to bring up the GitHub Copilot completions panel.

  6. Click Open Completions Panel. Copilot will synthesise around 10 different code suggestions. You should see something like this: VS Code showing suggestions to a comment

  7. Find a solution you like and click Accept Solution.

  8. Your Comments.cs file will be updated with your solution.

⌨️ Activity: Push code to your repository from the codespace

Let's use GitHub Copilot to summarize our changes and then commit the code.

  1. Open the Source Control tab
  2. Tap on the ✨ button in the Message entry for Copilot to generate your message.

Commit tab open to generate message with Copilot

  1. Click the Commit button.

Head to Exercise 4 - Using GitHub Copilot with C#