Code Optimizations extensions for Visual Studio (preview)
With the Code Optimizations extension for Visual Studio, you can generate a code fix proposal for performance issues identified by Code Optimizations in your running .NET apps.
This article guides you through using the extension with GitHub Copilot in Visual Studio.
Prerequisites
- Install version 17.12 or higher of Visual Studio.
- Sign up for and log into a GitHub account with a valid GitHub Copilot subscription.
- Enable the following services for your .NET application:
Verify Code Optimizations for your application
To get started, make sure Code Optimizations are identified for your application.
In the Azure portal, navigate to your Application Insights resource.
Select Investigate > Performance.
In the Performance blade, select the Code Optimizations button in the top menu.
Make note of:
- The Application Insights resource name.
- The Application Insights Application ID, found on the API Access blade.
- The account with which you're signed into the Azure portal.
Install the Code Optimizations extension (preview)
Install the Code Optimizations extension for Visual Studio.
Fix issues in your code using the extension
Once installed, the Code Optimizations extension (preview) introduces an agent called @code_optimizations
with a few commands or "skills" that you can use in GitHub Copilot to interface with Code Optimizations issues.
In Visual Studio, open the repo holding your .NET application with Code Optimizations enabled.
Open the GitHub Copilot chat.
Invoke the extension by executing the following command, replacing the placeholder with your own Application Insights resource name or with the Application Insights Application ID.
@code_optimizations /connect <YOUR_APPLICATION_INSIGHTS_RESOURCE_NAME_OR_APPLICATION_ID>
The command pulls the top issues from Code Optimizations, maps them to source code in your local repo, and suggests fixes/recommendations. It automatically generates the top recommendation.
Note
By default, only issues from the past 24 hours are returned.
Generate fixes for other issues by following the prompts in the Copilot response.