Automatic comments with Copilot for the Visual Studio Editor

Copilot automatically creates comments for code sections in the Visual Studio Editor. This works with projects in C++ and C#.

listen Print view
Lead story AI robots

(Image: erstellt mit Dall-E von ix)

1 min. read
By
  • Manuel Masiero

The AI assistant GitHub Copilot can now create comments on functions and expressions in Visual Studio. This should make the documentation process easier for programmers.

Copilot gets to work by entering the desired comment format in the editor at the relevant code location, for example, ///. Based on the function content, the AI then automatically creates the function description and summarizes all parameters and available return types. The suggested comment can then be accepted like a code completion using the Tab key.

Videos by heise

The Copilot integration is available for Visual Studio 17.14 Preview 2 and supports project files written in C# and C++. A GitHub Copilot subscription is required for access, although the AI feature is already included in the free plan.

The co-pilot in the Visual Studio Editor comments the code section automatically (green here).

(Image: Microsoft)

To use Copilot's services, the automatic generation of comments must be activated in the Visual Studio Editor. For projects in C++, programmers can configure the documentation style via Tools, Options as shown in the image below. In addition to XML comments, Doxygen comments are also supported.

Configuring the copilot comments for projects written in C++

(Image: Microsoft)

For C# projects, the following check mark must be set under Tools, Options under Advanced:

Configure the copilot comments for projects written in C#.

(Image: Microsoft)

Further information can be found in the VS blog.

(mho)

Don't miss any news – follow us on Facebook, LinkedIn or Mastodon.

This article was originally published in German. It was translated with technical assistance and editorially reviewed before publication.