Skip to content

Commit 78f5f2e

Browse files
committed
Refactor README.md to improve clarity on using GitHub Copilot's Agent Mode, including new API endpoint generation instructions and customization context.
1 parent d066e22 commit 78f5f2e

File tree

1 file changed

+4
-71
lines changed

1 file changed

+4
-71
lines changed

Using-GitHub-Copilot-with-CSharp/README.md

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -168,84 +168,17 @@ Agent Mode was able to perform C# specific tasks:
168168
- Setting up dependency injection for better testability
169169
- Creating an organized project structure
170170

171-
172-
### 🗒️ Section 3: MCP and etc
173-
174-
175-
}
176-
```
177-
178-
You can take a look at the prompt working in the next animation:
179-
180-
![open program.cs in the BackEnd project](./014AddNewRecord.gif)
181-
182-
### 🔎 Step 4: Generate a new endpoint to get the weather forecast for a city
183-
184-
Now let's generate a new API endpoint similar to `/weatherforecast` that also includes the city name. The new API endpoint name will be **`/weatherforecastbycity`**.
185-
186-
***Important:** You must place the code after the '.WithOpenApi();' line, this starts on line 36. Also remember to press TAB in each new suggested line until the whole endpoint is defined.*
187-
188-
Next, generate a new endpoint with GitHub Copilot by adding the comment:
189-
190-
```csharp
191-
// Create a new endpoint named /WeatherForecastByCity/{city}, that accepts a city name in the urls as a paremeter and generates a random forecast for that city
192-
```
193-
In the following example, we added some extra blank lines after the previous endpoint and then GitHub Copilot generated the new endpoint. Once the Endpoint core code was generated, GitHub Copilot also suggested code for the name of the endpoint (line 49) and the OpenAPI specification (line 50). Remember to accept each one of these suggestions by pressing [TAB].
194-
195-
![Copilot ghost suggestion for the new endpoint](./020GeneratedCode.gif)
196-
197-
***Important**: This prompt generates several lines of C# code. It's strongly advised to check and review the generated code to verify that it works in the desired way.*
198-
199-
The generated code should look similar to this one:
200-
201-
```csharp
202-
// Create a new endpoint named /WeatherForecastByCity/{city}, that accepts a city name in the urls as a paremeter and generates a random forecast for that city
203-
app.MapGet("/WeatherForecastByCity/{city}", (string city) =>
204-
{
205-
var forecast = new WeatherForecastByCity
206-
(
207-
city,
208-
DateOnly.FromDateTime(DateTime.Now),
209-
Random.Shared.Next(-20, 55),
210-
summaries[Random.Shared.Next(summaries.Length)]
211-
);
212-
return forecast;
213-
})
214-
.WithName("GetWeatherForecastByCity")
215-
.WithOpenApi();
216-
```
217-
218-
219-
220-
### 🐍 Step 5: Test the new endpoint.
221-
222-
Finally, verify the new endpoint is working by starting the project from the Run and Debug panel.
223-
Select Run and Debug, and then select the BackEnd project.
224-
225-
![Open Run and Debug panel and select BackEnd project](./030RunAndDebugTheBackEndProject.png)
226-
227-
Now press Run and the project should build and run. Once the project is running, we can test the original Url using your Codespace url and the original endpoint:
171+
Finally, verify that the changes and new endpoint is working by starting the BackEnd project from the 'Run and Debug' panel. Once the project is running, test the original URL using your Codespace URL and original endpoint:
228172

229173
```bash
230174
https://< your code space url >.app.github.dev/WeatherForecast
231175
```
232176

233-
And the new endpoint will also be ready to test. Here are some samples urls with different cities:
234-
```bash
235-
https://< your code space url >.app.github.dev/WeatherForecastByCity/Toronto
236-
237-
https://< your code space url >.app.github.dev/WeatherForecastByCity/Madrid
238-
239-
https://< your code space url >.app.github.dev/WeatherForecastByCity/<AnyCityName>
240-
```
241-
242-
Both tests running should be like these ones:
243-
244-
![Open Run and Debug panel and select BackEnd project](./032TestAndDebugUsingUrls.png)
245-
177+
🚀Congratulations! Now you understand the power behind Agent Mode and the many tasks that it can help with. Scroll down to the next section that will show you how to add context and customization to Copilot.
246178

247-
🚀 Congratulations, through the exercise, you haven't only used GitHub Copilot to generate code but also done it in an interactive and fun way! You can use GitHub Copilot to not only generate code, but also write documentation, test your applications and more.
179+
### 🗒️ Section 3: Customization and Context.
248180

181+
TODO
249182

250183
## Legal Notices
251184

0 commit comments

Comments
 (0)