Skip to content

Commit cbd8a42

Browse files
authored
Merge pull request #198 from microsoft/pythonmodules
Python Module Rewrite to include agentic use
2 parents 4800ea1 + 3325fc0 commit cbd8a42

14 files changed

+311
-53
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ By the end of this module, you'll acquire the skills to be able to:
3030

3131
1. Enable your [GitHub Copilot service](https://github.com/github-copilot/signup)
3232

33-
1. Get familiar with [this repository with Codespaces](https://github.com/github/dotnet-codespaces)
33+
1. Open [this repository with Codespaces](https://github.com/github/dotnet-codespaces)
3434

3535
## 💪🏽 Exercise
3636

@@ -88,6 +88,14 @@ In the above exercises we achieved the following:
8888

8989
### 🗒️ Section 2: Code Completion
9090

91+
**🎯 Learning Goals**
92+
93+
- Use inline code completion to write code from comments.
94+
- Trigger and refine Copilot completions.
95+
- Use inline chat and slash commands.
96+
97+
In the previous section you learned how to use both natural language or slash commands to quickly understand the codebase without digging through folders. In the next set of exercises we're going to use Copilot to make some changes to the API using code completion.
98+
9199
1. Ask GitHub Copilot in the chat pane to "run and debug" the backend project (you can also do this from the 'run and debug' panel in the editor). Start Debugging the selected project.
92100

93101
<div align="left">
@@ -112,7 +120,7 @@ https://< your url>.app.github.dev/weatherforecast
112120
<img src="./images/005ports.jpg" alt="port view in the editor">
113121
</div>
114122

115-
1. In this next step we want to refactor some code and generate a new record for our Weather API. The goal is to add a new record that includes the name of the city. We are going to achieve this by asking Copilot directly from the file using code comments. From the file pane, navigate to the following path `SampleApp\BackEnd\Program.cs` and open `Program.cs`. Navigate to the end of the file and type in (or copy):
123+
3. In this next step we want to refactor some code and generate a new record for our Weather API. The goal is to add a new record that includes the name of the city. We are going to achieve this by asking Copilot directly from the file using code comments. From the file pane, navigate to the following path `SampleApp\BackEnd\Program.cs` and open `Program.cs`. Navigate to the end of the file and type in (or copy):
116124

117125
```csharp
118126
// create a new internal record named WeatherForecastByCity that requests the following parameters: City, Date, TemperatureC, Summary
@@ -124,19 +132,19 @@ The output should be similar to this:
124132
<img src="./images/006internalrecord.jpg" alt="changes to existing record">
125133
</div>
126134

127-
4. Now we want to use the inline feature of Copilot. Using the inline feature we can focus on the code in front of us and make progressive changes as needed in our code base. Next, we will create a new C# class by creating a new file under the `Backend` folder: `SampleApp\BackEnd\Customer.cs`.
135+
1. Now we want to use the inline feature of Copilot. When using the inline feature we can focus on the code in front of us and make progressive changes as needed in our code base. Next, we will create a new C# class by creating a new file under the `Backend` folder: `SampleApp\BackEnd\Customer.cs`.
128136

129137
<div align="left">
130138
<img src="./images/007customerfile.png" alt="New file customer.cs">
131139
</div>
132140

133-
From the top of the editor, press `CTRL + I` to open the inline chat and type (or copy) in:
141+
From the top of the editor, press `CTRL + I` to open inline chat and type (or copy) in:
134142

135143
```csharp
136144
// Create a class for a Customer with Id, Name, and Email, and a method to validate email format
137145
```
138146

139-
5. Accept the suggestion and and with the output, using the inline prompt window ask:
147+
5. Accept the suggestion and with the output, using the inline prompt window ask:
140148

141149
```csharp
142150
/improve IsValidEmail method using Regex
@@ -171,7 +179,7 @@ In the above exercises we achieved the following:
171179

172180
[GitHub Copilot Agent Mode](https://github.blog/ai-and-ml/github-copilot/agent-mode-101-all-about-github-copilots-powerful-mode/) is an autonomous AI coding assistant that acts as a synchronous collaborator in real-time. It can perform coding tasks that require multiple steps all while using your natural language prompts. When working in Agent Mode, Copilot can problem solve alongside you, understanding your intent, and when the built solution needs some tweaking, it can iterate until it gets it right. In this section we're going to use Agent Mode to make a multitude of changes to our backend service to provide several improvement to our code.
173181
174-
1. Open GitHub Copilot Chat. Notice in the text box you can 'add context', which allows you to attach files, folders and other items to the context of Copilot so that it can better understand your codebase. Agent mode should be selected by default. You have the capability to choose your model as well. Also note, the open tab `Program.cs` is being referenced for context.
182+
1. Open GitHub Copilot Chat. Notice in the text box you can 'add context', which allows you to attach files, folders and other items to the context of Copilot so that it can better understand your codebase. Agent mode should be selected by default. You have the capability to choose your model as well. Also note, the open tab `Program.cs` is being referenced to for context.
175183

176184
<div align="left">
177185
<img src="./images/009agentview.jpg" alt="Output of /Explain">
@@ -208,7 +216,7 @@ While Agent Mode is working, we can also view that it has created documentation
208216

209217
For this step in the workshop, agent mode should have taken several minutes to complete your tasks. Review the various changes and confirm that they have achieved all of the given output. With Agent mode, it also outputs what changes were made. The following summary of changes that were made are summarized below:
210218

211-
```
219+
```md
212220
**Customer Endpoint Implementation**
213221
- Created a RESTful API for Customer with proper CRUD operations
214222
- Added appropriate status codes and validation
@@ -238,10 +246,10 @@ For this step in the workshop, agent mode should have taken several minutes to c
238246

239247
Agent Mode confirmed that all tests are passing and that the application follows modern ASP.NET best practices with a focus on separation of concerns and test coverage.
240248

241-
3. 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:
249+
3. Finally, verify that the changes and new endpoint are 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:
242250

243251
```bash
244-
https://< your code space url >.app.github.dev/WeatherForecast
252+
https://< your codespace url >.app.github.dev/WeatherForecast
245253
```
246254

247255
🚀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.
@@ -255,6 +263,10 @@ Agent Mode was able to perform C# specific tasks:
255263

256264
### 🗒️ Section 4: Customization and Context
257265

266+
🎯 Learning Goals
267+
- Understand the different ways to customize GitHub Copilot and receive better responses from prompts.
268+
- Understand the role of Model Context Protocol (MCP).
269+
258270
**Part 1: Custom Instructions**
259271

260272
GitHub Copilot instructions files are markdown documents that provide essential context to guide Copilots behavior within a specific codebase. These files help tailor AI-generated suggestions to match your teams coding standards, architectural patterns, naming conventions, testing strategies, and deployment practices. There are two types of instructions files: global instructions, which apply to the entire repository and are stored in `copilot-instructions.md`, and scoped instructions, which apply only to specific files or folders and are placed in `.github/instructions/*instructions.md`.

0 commit comments

Comments
 (0)