GitHub Copilot is an AI-powered code completion and generation tool developed by GitHub in collaboration with OpenAI.

It’s designed to assist developers in writing code more efficiently by providing real-time suggestions and auto-completions as they work. GitHub Copilot is built on OpenAI’s GPT-3 technology, which enables it to understand natural language queries and context to generate code snippets, comments, and even entire functions based on the context provided by the developer.

Key features of GitHub Copilot include:

    1. Code Auto Completion: Copilot suggests code completions, making it faster for developers to write common code patterns and functions.
    2. Code Generation: Copilot can generate code snippets or even larger blocks of code based on natural language descriptions provided by the developer. This can help in quickly implementing complex logic or tasks.
    3. Contextual Assistance: Copilot takes into account the context of the code being written, including variable names, function names, and comments, to provide more relevant and accurate suggestions.
    4. Multiple Languages and Frameworks: Copilot supports a wide range of programming languages and frameworks, making it versatile for various development environments.
    5. Refactoring Assistance: It can help with code refactoring, suggesting ways to improve the structure and efficiency of existing code.
    6. Learning from the Developer: As developers use Copilot, they can help train it to provide even more accurate and contextually relevant suggestions.
    7. Integration with IDEs: Copilot integrates seamlessly with popular integrated development environments (IDEs) such as Visual Studio Code, making it accessible directly within the coding environment.
    How to try GitHub CoPilot. You need to have an account in the GitHub to start with. Inside GitHub you have the option to start a free trial. For free trial too you will need to provide card details. Once you have activated the trial you can cancel your subscription anytime. You will still get the full one month to try CoPilot.

At the time of writing this post, there are 3 different extensions/plugins available for Visual Studio and Visual Studio Code.

    1. Copilot- Provides Auto completion and Code generation capabilities in the IDE. 
    2. Copilot Chat – At present this feature is available to all by default. This is currently available on invitation, you can request for the access though. I got the access after 3 weeks of my requesting. Like ChatGPT, Copilot chat is integrated with the IDE.

    In Visual Studio , if you right click you will get option AskCopilot. This will open a textbox like following within the file that is opened.


This is how it looks in Visual Studio IDE.

In Visual Studio Code, you will get option like following in the context menu.

    1. Copilot Labs (available with VS code only and on as-Is basis)

I had tried it for a month and based on my experience , here are my observations on following development Use Case.

    1. Autocomplete feature– It suggests entire lines, code blocks, or functions based on your context, reducing the need to manually write repetitive or boilerplate code. At times I found it generating the entire method just by the time you finish writing the method name.

    2. Code Generation–  You can use the Copilot chat option to ask it to generate a method to perform a particular job. Based on your prompt, it would generate the method for you. It works well for the utility type of method.
    3. Unit Test generation – It Can quickly generate C# Unit Tests for the method you have written. The Unit Tests are not 100% perfect, you will still need to Mock setup or add dependencies in the method if Copilot has not generated it but I have found it very useful nonetheless. Tests generated will reduce your Unit test writing effort by at least 30-60% depending upon the quality of the test it has generated.  The Angular tests generated by Copilot are more complete and require very little manual effort.
    4. Code Refactoring – Code refactoring doesn’t always work well, especially with complex code. When asked to refactor code, it has been observed to sometimes remove lines of code or even disrupt existing functionality. Additionally, it removes any inline code comments and adds its own comments.
    5. Code Optimization/ Performance improvement- It provides suggestions to improve code, like adding async/await etc. However, its refactoring at this point is not very mature and reliable.
    6. Documentation- It can be used for generating code comments and documentation. It can be helpful for generating the API documentation as well.

      

Leave a Reply

Your email address will not be published. Required fields are marked *