Skip to content

Commit 0cb9275

Browse files
Update lab feedback
1 parent ffecb84 commit 0cb9275

13 files changed

Lines changed: 158 additions & 93 deletions

lab/images/1-agent.png

-4.67 KB
Loading

lab/images/3-chat.png

-4.12 KB
Loading

lab/images/5-select-sonnet.png

26.2 KB
Loading

lab/part0-exploring-codebase.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
GitHub Copilot Chat allows you to ask questions about your code and get intelligent responses.
44

5-
1. [] Open the solution in Visual Studio 2022.
6-
2. Click 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.
7-
5+
1. [] Open the solution in Visual Studio 2022 if it is not already open.
6+
1. Click 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.
87
![Open chat window dialog](./images/1-open-copilot-chat.png)
9-
10-
3. [] Try asking questions about the project structure:
8+
1. [] Try asking questions about the project structure:
119
- `What projects are in this solution and how do things work together?`
1210
- `What is the TinyShop application architecture?`
1311
- `How does the Products API work?`
14-
4. [] Notice how Copilot analyzes your codebase to provide contextual answers.
12+
1. [] Notice how Copilot analyzes your codebase to provide contextual answers.
1513

1614
**Key Takeaway**: GitHub Copilot Chat helps you understand unfamiliar codebases by answering questions about the project structure, architecture, and implementation details.

lab/part1-code-completion.md

Lines changed: 78 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@ In this section, you'll use GitHub Copilot's code completion to implement API en
44

55
> IMPORTANT: For this exercise, **DO NOT** copy and paste the code snippet provided, but rather type it manually. This will allow you to experience code completion as you would if you were coding back at your desk. You'll likely see you only have to type a few characters before GitHub Copilot begins suggesting the rest.
66
7-
1. [] Open **ProductEndpoints.cs** in the **Products** project under **Endpoints** - it should be empty or contain minimal code.
7+
1. [] Stop debugging the appliaction if it is currently running.
8+
9+
1. [] In the Solution Explorer, in the **Products** project, open **Endpoints/ProductEndpoints.cs** - it will have a single endpoint implemented.
810

911
> Note: GitHub Copilot will not give code suggestions when debugging.
1012
11-
2. [] Begin typing a comment to describe what you want to implement:
13+
1. [] Let's implement a new **MapGet** to get product details for a specific **id**. Move our cursor and click on line 20 under the existing **/** endpoint. Text suggestion may apprear or type:
1214
```csharp
13-
group.MapGet(
15+
g
1416
```
15-
3. [] Wait for the ghost text suggestions to appear (gray text).
16-
17+
1. [] Wait for the ghost text suggestions to appear (gray text).
18+
;
1719
![Code suggestions](./images/1-ghost-text.png)
1820

19-
4. [] Press Tab to accept the suggestion or continue typing to get more specific suggestions.
21+
1. [] Press Tab to accept the suggestion or continue typing to get more specific suggestions.
2022

21-
5. [] From there Next Edit Suggetions (NES) or addtional Ghost Text suggestions will appear.
23+
1. [] From there Next Edit Suggetions (NES) or addtional Ghost Text suggestions will appear.
2224

2325
![NES showing up](./images/1-nes.png)
2426

25-
6. [] We now can implement the following endpoints using GitHub Copilot:
27+
1. [] We now can implement the following endpoints using GitHub Copilot:
2628
- GET product by ID
2729
- POST to create a new product
2830
- PUT to update a product
@@ -32,9 +34,9 @@ In this section, you'll use GitHub Copilot's code completion to implement API en
3234
- Open 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.
3335
- Switch to **Agent** mode.
3436
- ![Switch to agent mode](./images/1-agent.png)]
35-
- Ask the agent: `Can you implement the rest of the endpoints for the Product API and also implement the ProductService integration on the Store project?`
37+
- Ask the agent: `Can you implement the rest of the endpoints for the Product API and also implement the ProductService to call these new endpoints in the Store project?`
3638

37-
The end code sould look similar to:
39+
The end code in **ProductEndpoints.cs** sould look similar to:
3840

3941
```csharp
4042
group.MapGet("/", async (ProductDataContext db) =>
@@ -96,22 +98,84 @@ In this section, you'll use GitHub Copilot's code completion to implement API en
9698
.Produces(StatusCodes.Status404NotFound);
9799
```
98100

101+
In the **Store** project in the solution explorer open **Services/ProductService.cs**, the code sould look similar to:
102+
103+
```cs
104+
using DataEntities;
105+
using System.Text.Json;
106+
107+
namespace Store.Services;
108+
109+
public class ProductService
110+
{
111+
HttpClient httpClient;
112+
public ProductService(HttpClient httpClient)
113+
{
114+
this.httpClient = httpClient;
115+
}
116+
public async Task<List<Product>> GetProducts()
117+
{
118+
List<Product>? products = null;
119+
var response = await httpClient.GetAsync("/api/Product");
120+
if (response.IsSuccessStatusCode)
121+
{
122+
var options = new JsonSerializerOptions
123+
{
124+
PropertyNameCaseInsensitive = true
125+
};
126+
127+
products = await response.Content.ReadFromJsonAsync(ProductSerializerContext.Default.ListProduct);
128+
}
129+
130+
return products ?? new List<Product>();
131+
}
132+
133+
public async Task<Product?> GetProductById(int id)
134+
{
135+
var response = await httpClient.GetAsync($"/api/Product/{id}");
136+
if (response.IsSuccessStatusCode)
137+
{
138+
return await response.Content.ReadFromJsonAsync<Product>(ProductSerializerContext.Default.Product);
139+
}
140+
return null;
141+
}
142+
143+
public async Task<bool> CreateProduct(Product product)
144+
{
145+
var response = await httpClient.PostAsJsonAsync("/api/Product", product, ProductSerializerContext.Default.Product);
146+
return response.IsSuccessStatusCode;
147+
}
148+
149+
public async Task<bool> UpdateProduct(int id, Product product)
150+
{
151+
var response = await httpClient.PutAsJsonAsync($"/api/Product/{id}", product, ProductSerializerContext.Default.Product);
152+
return response.IsSuccessStatusCode;
153+
}
154+
155+
public async Task<bool> DeleteProduct(int id)
156+
{
157+
var response = await httpClient.DeleteAsync($"/api/Product/{id}");
158+
return response.IsSuccessStatusCode;
159+
}
160+
}
161+
```
162+
99163
> [!IMPORTANT]
100164
>Because LLMs are probabilistic, not deterministic, the exact code generated can vary. The above is a representative example. If your code is different, that's just fine as long as it works!
101165
102-
7. [] Try changing the variable name of **id** to `productId` in the new **MapGet** method and see Next Edit Suggestions help out.
166+
1. [] Go back to **ProductEndpoints.cs**, and try changing the variable name of **id** to `productId` in the new **MapGet** method and see Next Edit Suggestions help out.
103167

104168
![NES suggestions more](./images/1-nes-2.png)
105169

106-
8. [] Try using documentation generation:
170+
1. [] Try using documentation generation:
107171
- Type `///` above a method to generate XML documentation on the **MapProductEndpoints** this can also be brought up with `Alt+/` for inline and then entering **/** which will bring up a list of commands.
108172

109173
![documentation generation by Copilot](./images/1-docs.png)
110174

111-
9. [] Test your implementation:
175+
1. [] Test your implementation:
112176
- Run the AppHost project.
113177
- Test your new endpoints by going to **https://localhost:7130/api/Product/1**
114178

115-
10. [] Stop debugging and close the application
179+
1. [] Stop debugging and close the application
116180

117181
**Key Takeaway**: GitHub Copilot can generate complete API implementations based on your comments or partial code, significantly speeding up development.

lab/part2-enhancing-ui.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ Now, you'll improve the loading experience using Copilot's inline chat.
55
> [!NOTE]
66
> This exercise does supply specific prompts to type, but as part of the learning experience we encourage you to discover how to interact with Copilot. Feel free to talk in natural language, describing what you're looking for or need to accomplish.
77
8-
1. [] Open **Products.razor** in the **Store** project under **Components**.
9-
2. [] Find the "Loading..." text in the code.
10-
3. [] Select this text and right-click.
11-
4. [] Choose "Copilot > Start inline chat" or press `Alt+/`.
12-
5. [] In the inline chat, type: "What would this look like with a loading progress spinner"
8+
1. [] In the **Solution explorer** under the **Store** project open **Components/Pages/Products.razor**.
9+
1. [] Find the "Loading..." text in the code.
10+
1. [] Select this text and right-click.
11+
1. [] Choose "Ask Copilot" or press `Alt+/`.
12+
1. [] In the inline chat, type: "Update this to have a loading progress spinner and the text: Loading... under it"
1313

1414
![Screenshot of VS with inline chat](./images/2-inline-code.png)
1515

16-
6. [] Preview the suggestion by clicking the "Preview" button.
17-
7. [] Accept the change by clicking "Accept."
16+
1. [] Select **Tab** to accept the changes, and it should look similar to:
1817

1918
```html
2019
<div class="spinner-border text-primary" role="status">
2120
<span class="visually-hidden">Loading...</span>
2221
</div>
2322
```
24-
8. [] Run the application to see your new loading spinner in action.
2523

26-
9. [] Stop debugging and close the application
24+
1. [] Run the application to see your new loading spinner in action.
25+
26+
1. [] Stop debugging and close the application
2727

2828
**Key Takeaway**: Inline chat allows you to make targeted improvements to your code without leaving your editor context.

lab/part3-referencing-files.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

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

5-
1. [] Open **Products.razor** from the Store project.
6-
1. [] Ensure that GitHub Copilto Chat is open by clickin 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.
5+
1. [] Open the **Products.razor** again from the **Store** project.
6+
1. [] Ensure that GitHub Copilto 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.
77

88
![Open chat window dialog](./images/1-open-copilot-chat.png)
99

10-
1. Change the mode to `Manual(Chat)`
10+
1. Change the mode to `Ask`
1111

1212
![Change to chat](./images/3-chat.png)
1313

lab/part4-custom-instructions.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ Here are some guidelines to consider when creating a Copilot instructions file:
2121

2222
## Create a Copilot instructions file
2323

24-
1. [] Open the **copilot-instructions.md** file in the **.github** folder, you can also get to it from the **Solution Items** folder in Visual Studio.
25-
2. [] Add project-specific information about your application:
24+
1. [] In the **Solution Explorer**, expand the **Solution Items** and open **copilot-instructions.mc**.
25+
> This file is located in the **.github* folder in the root of the repository.
26+
1. [] Add project-specific information about your application:
2627

2728
```markdown
28-
## TinyShop
29-
3029
### Backend
3130
- Products project is the backend API.
3231
- Built with .NET Minimal APIs.
@@ -39,14 +38,14 @@ Here are some guidelines to consider when creating a Copilot instructions file:
3938
- UI should have a modern look and feel.
4039
- CSS should be in .razor.css files.
4140
```
42-
3. Start a new chat by clicking the `+` icon in the top right corner of the chat window.
41+
1. Start a new chat by clicking the `+` icon in the top right corner of the chat window.
4342

4443
![New chat](./images/5-new-edits.png)
4544

46-
4. [] Go back to Copilot Chat and re-run the prompt from Part 3, you can do this by pressing the up key. or
45+
1. [] Go back to Copilot Chat and re-run the prompt from Part 3, you can do this by pressing the up key. or
4746
i. [] Ask: `How would I implement getting and visualizing the products in a table using the code in #ProductService and the css required.`
4847
i. [] Review the code suggestion but don't implement it yet.
4948
i. [] Follow up with: `How would this look in a grid instead of a list?`
50-
5. [] Notice how the responses now incorporate your custom instructions.
49+
1. [] Notice how the responses now incorporate your custom instructions.
5150

5251
**Key Takeaway**: Custom instructions make Copilot's suggestions more aligned with your project standards and architecture preferences.

lab/part5-implementing-features.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ With Copilot Agent, you will add the files which need to be updated to the conte
77
Let's add the ability to see a list of images into the app:
88

99
1. [] Open 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.
10+
1011
1. [] Switch to **Agent** mode.
1112

1213
![Switch to agent mode](./images/1-agent.png)
@@ -15,7 +16,10 @@ Let's add the ability to see a list of images into the app:
1516

1617
![New chat icon in VS copilot](./images/5-new-edits.png)
1718

18-
1. [] If available, select **Claude 3.5 Sonnet** from the list of available models
19+
1. [] At the bottom of the GitHub Copilot Chat pane, select the model (default is GPT-4o") from the dropdown list, and select **Claude 3.5 Sonnet** from the list of available models.
20+
21+
![Select Sonnet in Copilot](./images/5-select-sonnet.png)
22+
1923
1. [] Type: `Implement a product listing page in Products.razor that fetches products from #ProductService and displays them in a list with product name, description, price, and image.`
2024

2125
> [!NOTE]

lab/part6-copilot-vision.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
In this section, you'll use Copilot Vision. You can share screenshots of errors and Copilot will interpret the image and resolve the issue. Or share mockups of new designs, and Vision will help you bring them to life. Let's update our design based on a photo our design gave us.
44

55
1. [] Open a new Copilot Chat thread in Agent mode.
6-
2. [] Click the **+** button in the chat, select **upload image**, and select the store application image that is found in the GitHub repo that is cloned called **eshop.png** inside of the **C:\Users\LabUser\Source\Repos\build-2025-lab300** directory.
6+
1. [] Click the **+** button in the chat, select **upload image**, and select the store application image that is found in the GitHub repo that is cloned called **eshop.png** inside of the **C:\Users\LabUser\Source\Repos\build-2025-lab300** directory.
77

88
![Attach image icon](./images/6-add-image.png)
99

10-
3. [] Ask: `Update the Products.razor to display products in a grid layout similar to this image. Add nice hover effects and make it responsive.`
11-
4. [] Review the suggested code changes and implement them. It should recommend changes to both the **Products.razor** and a new **Products.razor.css**
12-
5. [] Run the application to see the updated product grid layout. You may have to clear the browser cashe with CTRL+SHIFT+R if you don't see the css update.
10+
1. [] Ask: `Update the Products.razor to display products in a grid layout similar to this image. Add nice hover effects and make it responsive.`
11+
1. [] Review the suggested code changes and implement them. It should recommend changes to both the **Products.razor** and a new **Products.razor.css**
12+
1. [] Run the application to see the updated product grid layout. You may have to clear the browser cashe with CTRL+SHIFT+R if you don't see the css update.
1313

1414
> Note: continue to iterate with Copilot Agent if it isn't to your liking.
1515

0 commit comments

Comments
 (0)