Today I would like to briefly talk about how to use GitHub Copilot in your AL project.
GitHub Copilot · Your AI pair programmer: GitHub Copilot uses the OpenAI Codex to suggest code and entire functions in real-time, right from your editor.
What is GitHub Copilot?
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work. It draws context from comments and code to suggest individual lines and whole functions instantly. GitHub Copilot is powered by OpenAI Codex, a generative pretrained language model created by OpenAI. It is available as an extension for Visual Studio Code, Visual Studio, Neovim, and the JetBrains suite of integrated development environments (IDEs).
First of all this is not a free service. If you want to do some testing, start the free trial.
You must have a Github account, if not, please create an account first.
When you click the Start a free trial, you will jump to the Github Copilot settings page, and you will see the following message.
Your Github Copilot setup is incomplete. Select your perferences below to start using Gihub Copilot.
Setup is very simple. Just select suggestions matching public code
GitHub Copilot can allow or block suggestions matching public code. See the GitHub Copilot documentation to learn more.
Then choose Save.
Setup in Github is complete.
It can take up to 30 minutes for the changes to take effect. Restart your code editor for the changes to take effect immediately.
PS: You can also get Copilot from an organization.
Organizations can provide their members (including you) and their teams access to GitHub Copilot. Organizations owned by enterprise accounts are not currently listed.
Okay, let’s continue the test. As you know, the common development tool for Business Central is VS Code, so we need to install the Github Copilot extension in VS Code.
After successful installation, it is recommended to restart VS Code, and then you can see the prompt that you need to sign in to Github Copilot.
PS: If you do not have a license to use Github Copilot, you will be prompted with the following message.
GitHub Copilot could not connect to server. Extension activation failed: “Your Copilot experience is not fully configured, complete your setup.”
That’s the end of the setup, let’s test it briefly. (Press the Tab key to add the Copilot proposal to the content)
GitHub Copilot commands:
You will find that Copilot will always provide useful suggestions as you write code. You can directly apply its suggestions, or ignore them, and then it will propose new suggestions again in the next line. This is very convenient.
In addition, for example, when adding fields, triggers and other information, corresponding suggestions will also be provided.
Very interesting, this is the way of writing code in the future. Give it a try!!!😁
PS: In Github, you can choose Settings -> Billing and plans 0> Plans and usage to manage your Github Copilot add-on.
MS Learn: Introduction to GitHub Copilot
Hope this will help.
Thanks for reading.