You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 06-Using-GitHub-Copilot-with-CSharp/README.md
+11-11
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Prepare to tackle a practical, hands-on project! You’ll work on modifying a C#
11
11
</header>
12
12
13
13
14
-
-**Who this is for**: Developers, DevOps Engineers, Software development managers, Testers.
14
+
-**Who this is for**: Developers, DevOps Engineers, Software Development Managers, Testers.
15
15
-**What you'll learn**: How to use GitHub Copilot to create code and add comments to your work.
16
16
-**What you'll build**: C# files that will have code generated by Copilot AI for code and comment suggestions.
17
17
-**Prerequisites**: GitHub Copilot is available to use for free, sign up for [GitHub Copilot](https://gh.io/copilot).
@@ -47,7 +47,7 @@ We will review the steps to update the Weather BackEnd App by adding a new endpo
47
47
48
48
### 🗒️ Step 1: Get familiarized with the "GitHub Codespaces ♥️ .NET 8" repository
49
49
50
-
Once you open the repository in Codespaces, you will find a new browser window with a fully functional Codespace. Everything in this repository is contained within this one Codespace. In example, in the explorer panel, we can see the main code for the BackEnd and the FrontEnd project.
50
+
Once you open the repository in Codespaces, you will find a new browser window with a fully functional Codespace. Everything in this repository is contained within this one Codespace. For example, in the explorer panel, we can see the main code for the BackEnd and the FrontEnd projects.
51
51
52
52

53
53
@@ -74,7 +74,7 @@ Add a breakpoint in line 24 (press F9) and refresh the browser with the Url to t
74
74
75
75

76
76
77
-
Pressing F10 we can debug step-by-step until line 32, where we can see the generated values. The application should have been generated samples Weather values for the next 5 days. The variable `forecast` has an array containing these values.
77
+
Pressing F10 we can debug step-by-step until line 32, where we can see the generated values. The application should have generated samples Weather values for the next 5 days. The variable `forecast` has an array containing these values.
78
78
79
79

80
80
@@ -105,13 +105,13 @@ The selected C# code is part of an ASP.NET Core application using the minimal AP
105
105
-`/fix` to propose a fix for the problems in the selected code
106
106
-`/generate` to generate code to answer your question
107
107
108
-
Let's use the `/tests` command to generate tests to the code. Select lines 39-42, press `CTRL + I` to open the inline chat, and type `/tests` (or select the /tests slash command) to generate a new set of tests for this record.
108
+
Let's use the `/tests` command to generate tests for the code. Select lines 39-42, press `CTRL + I` to open the inline chat, and type `/tests` (or select the /tests slash command) to generate a new set of tests for this record.
109
109
110
110

111
111
112
112
At this point, GitHub Copilot will suggest a new class. You need to first press [Create] to create the new file.
113
113
114
-
A new class `ProgramTests.cs` was created and added to the project. This tests are using XUnit, however, you can ask to generate tests using another Unit Test library with a command like this one `/tests use MSTests for unit testing`.
114
+
A new class `ProgramTests.cs` was created and added to the project. These tests are using XUnit, however, you can ask to generate tests using another Unit Test library with a command like this one `/tests use MSTests for unit testing`.
115
115
116
116
***Important:** We are not going to use the test file in this project. You must delete the generated test file to continue.*
117
117
@@ -134,7 +134,7 @@ Navigate to the end of the file and ask Copilot to generate a new record that in
134
134
// create a new internal record named WeatherForecastByCity that request the following parameters: City, Date, TemperatureC, Summary
135
135
```
136
136
137
-
The generated code sould be similar to this one:
137
+
The generated code should be similar to this one:
138
138
139
139
```csharp
140
140
// create a new internal record named WeatherForecastByCity that request the following parameters: City, Date, TemperatureC, Summary
@@ -152,18 +152,18 @@ You can take a look at the prompt working in the next animation:
152
152
153
153
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`**.
154
154
155
-
***Important:** You must place the code after the '.WithOpenApi();' line, this starts in line 36. Also remember to press TAB in each new suggested line until the whole endpoint is defined.*
155
+
***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.*
156
156
157
157
Next, generate a new endpoint with GitHub Copilot by adding the comment:
158
158
159
159
```csharp
160
160
// 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
161
161
```
162
-
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 pressing [TAB].
162
+
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].
163
163
164
164

165
165
166
-
***Important**: This prompt generates several lines of C# code. It's strongly adviced to check and review the generated code to verify that it works in the desired way.*
166
+
***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.*
167
167
168
168
The generated code should look similar to this one:
169
169
@@ -199,7 +199,7 @@ Now press Run and the project should build and run. Once the project is running,
199
199
https://< your code space url >.app.github.dev/WeatherForecast
200
200
```
201
201
202
-
And the new endpoint will be also ready to test. Here are some samples urls with different cities:
202
+
And the new endpoint will also be ready to test. Here are some samples urls with different cities:
203
203
```bash
204
204
https://< your code space url >.app.github.dev/WeatherForecastByCity/Toronto
205
205
@@ -213,7 +213,7 @@ Both tests running should be like these ones:
213
213

214
214
215
215
216
-
🚀 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 write documentation, test your applications and more.
216
+
🚀 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.
0 commit comments