Skip to content

Part 03: Referencing Code Files in Chat

In this section, you’ll learn how to reference existing code files in your chat conversations.

  1. Open the Products.razor again from the Store project.

  2. Ensure that GitHub Copilot Chat is open by clicking on the Github Copilot Chat in the top-right corner of Visual Studio and select Open Chat Window or press Ctrl+\+C if Copilot chat isn’t open.

    Open chat window dialog

  3. Start a new chat by clicking the + icon in the top right corner of the chat window.

    New chat

  4. Change the mode to Ask

    Change to chat

  1. Type: #ProductService.cs to reference the ProductService file.
  2. Ask: How would I implement getting and visualizing the products in a table using the code in #ProductService and the css required.
  3. Review the code suggestion but don’t implement it yet.
  4. Notice how Copilot can reference existing code to provide contextual suggestions.

Key Takeaway: Referencing files in your chat provides Copilot with the context it needs to give more accurate, project-specific suggestions.


Back: Part 02 - Enhancing UI with Inline Chat | Next: Part 04 - Using Custom Instructions

Reset all workshop progress?

This clears completed lessons and checked task items stored in this browser. This action cannot be undone.