@@ -117,62 +117,61 @@ In the above exercises we achieved the following:
117117- Observe autonomous coding and PR generation
118118- Assign issues to the Copilot coding agent
119119
120- In this section w
120+ GitHub Copilot Agent Mode is an autonomous 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 .
121121
122+ 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 . This is also the capability to choose your model as well . Also note , the open tab 'program .cs ' is being referenced for context .
122123
124+ 2. Give Agent mode a detailed prompt . For this example we are going to ask Copilot to make several improvements to our project .
123125
124-
125- Looking at your Program .cs file for the backend service , there are several potential improvements you could make . Here are some suggestions for changes you could start with :
126-
127- Add an endpoint for the Customer class that you have in your project
128- Configure CORS to allow your frontend to communicate with the backend
129- Add dependency injection for any services you might need
130- Add error handling middleware
131- Add authentication /authorization if needed
132- Improve the organization by creating controller classes instead of inline route handlers
133- As a first change , I 'd recommend adding a basic endpoint for the Customer class since you already have that model in your project . This would be a good starting point before making more complex changes .
134-
135- Would you like me to show you how to implement a simple endpoint for retrieving and creating customers ? Or would you prefer to start with one of the other changes I suggested ?
136-
137-
138-
139-
140- 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 .
141-
142- 
143-
144- At this point , GitHub Copilot will suggest a new class . You need to first press [Create ] to create the new file .
145-
146- 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 `.
147-
148- ***Important :** We are not going to use the test file in this project . You must delete the generated test file to continue .*
149-
150- Finally , let 's use the `/doc ` to generate automatic documentation to the code . Select lines 39-42, press `CTRL + I ` to open the inline chat , and type `/doc ` (or select the command ) to generate the documentation for this record .
151-
152- 
153-
154- Inline chat , the Chat Panel , and slash commands are part of the amazing tools that support our development experience with GitHub Copilot . Now we are ready to add new features to this App .
155-
156-
157- ### 🗒️ Step 3: Generate a new Record that includes the city name
158-
159- Go to the `Program .cs ` file in the BackEnd project . The file is in the following path `SampleApp \BackEnd \Program .cs `.
160-
161- 
162-
163- Navigate to the end of the file and ask Copilot to generate a new record that includes the name of the city .
164-
165- ```csharp
166- // create a new internal record named WeatherForecastByCity that request the following parameters: City, Date, TemperatureC, Summary
167126```
127+ 1. Add an endpoint for the Customer class in the project .
128+ 2. Configure CORS to allow the frontend to communicate with the backend
129+ 3. Add dependency injection for any services needed
130+ 4. Improve the organization by creating controller classes instead of inline route handlers
131+ 5. Write documentation for every change
132+ 6. Write tests using xUnit , verify error handling works correctly .
133+ ```
134+ Agent mode performed the following summary of changes
135+
136+ **Customer Endpoint Implementation **
137+ - Created a RESTful API for Customer with proper CRUD operations
138+ - Added appropriate status codes and validation
139+
140+ **CORS Configuration **
141+ - Properly configured CORS to allow the frontend to communicate with the backend
142+ - Set up to allow any origin , method , and header for development purposes
143+
144+ **Dependency Injection **
145+ - Added service interfaces and implementations for the Customer operations
146+ - Configured DI in Program .cs to make the application more testable and maintainable
147+
148+ **Code Organization **
149+ - Created a proper structure with Models , Controllers , and Services folders
150+ - Moved inline route handlers to dedicated controller classes
151+ - Applied consistent naming conventions
152+
153+ **Unit Tests **
154+ - Added comprehensive tests for controllers and services
155+ - Implemented tests for both success and error scenarios
156+ - Verified validation logic works properly
157+
158+ **Documentation **
159+ - Created detailed documentation for all APIs , models , and services
160+ - Included response types and error handling details
161+
162+ 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 .
163+
164+ Agent Mode was able to perform C # specific tasks :
165+ - Moving from inline route handlers to controller -based architecture
166+ - Adding proper model validation
167+ - Implementing comprehensive error handling
168+ - Setting up dependency injection for better testability
169+ - Creating an organized project structure
170+
171+
172+ ### 🗒️ Section 3: MCP and etc
168173
169- The generated code should be similar to this one :
170174
171- ```csharp
172- // create a new internal record named WeatherForecastByCity that request the following parameters: City, Date, TemperatureC, Summary
173- internal record WeatherForecastByCity (string City , DateOnly Date , int TemperatureC , string ? Summary )
174- {
175- public int TemperatureF = > 32 + (int )(TemperatureC / 0.5556);
176175}
177176```
178177
0 commit comments