GitHub Copilot in Visual Studio

Last time, I mentioned using of GitHub Copilot for X++ development, but I didn’t realize that not everyone is aware of the option of using GitHub Copilot in Visual Studio. A lot of examples on Internet shows it in Visual Studio Code and don’t mention Visual Studio at all, which may be confusing.

To use GitHub Copilot in Visual Studio, you need Visual Studio 2022. And ideally version 17.10 or later, because GitHub Copilot is integrated there as one of the optional components of Visual Studio. Because it’s optional, you may need to run the VS installer and add the component. To make is easier for you, VS offers a button to start the installation:

You can also add GitHub Copilot to older versions of VS 2022 as extensions, but simply using a recent version of VS makes a better sense to me. You can learn more in Install GitHub Copilot in Visual Studio, if needed.

You’ll also need a GitHub Copilot subscription (there is a one-month trial available) and be logged in GitHub in Visual Studio.

Then you’ll start getting code completion suggestion, can use Alt+/ shortcut inside the code editor to interact with Copilot, chat with the Copilot and so on.

X++ documentation comments by GitHub Copilot

I’ve finally started looking more closely on GitHub Copilot. What it can do with languages like C# is impressive; I also checked that it can help with things like Powershell scripts or Excel formulas.

But because I’m still primarily an X++ guy, I’m keen to explore how it can help there. So far, I tried asking GitHub Copilot to explain X++ code snippets, which was almost useless in most cases.

But I’ve found another use cases where it can save my time: creation of documentation comments. For example, this is pretty good:

Of course, good comments often contain information that isn’t included in the code as such, such as the business requirement or why we made a particular implementation decision. On the other hand, most methods are quite simple, but a good practice is having documentation comments for them anyway. Writing them isn’t difficult, but it takes time and it’s boring. I don’t complain if GitHub Copilot helps me with that. 🙂

MVP Summit 2024

Microsoft MVP Summit is an annual conference in Redmond (USA), where Microsoft Most Valuable Professionals (MVPs) meet to share experience, learn about new features coming to Microsoft products and to give feedback to Microsoft on what works well and where attention is needed.

I just came back from this year’s one and want to share some recollections.

Discussions there are covered by a Non-Disclosure Agreement (NDA), therefore I can’t share what we talked about. But I won’t reveal anything surprising by saying that a lot of investment is going to AI (such as copilots).

There wasn’t much content on F&O as such, but I attended many sessions about Power Platform (Power Apps, Dataverse…). Because there were tracks about many technologies in parallel, I’m now catching up with recordings of what I couldn’t attend in person, either stuff that I work with (C#, GitHub) or new things to learn (AI).

I was coming to Redmond every year since 2013, but there were no in-person Summits in 2020-2022 and I skipped the one last year, therefore it was my first visit in five years. Several new MVPs were awarded in past years and I finally got a chance to meet some of them. I know some from events in Europe, but MVP Summit is often the only chance to meet MVPs from places like India or Australia.

And it’s not just about new people, but maybe even more about meeting old friends, both MVPs and from Microsoft.

Some pictures with fellow F&O MVPs:

F&O MVPs with Microsoft logo

The Microsoft campus and cities around have changed too. There are new Microsoft buildings (and the F&O team moved there) and a railway from Redmond to Bellevue will open in a few weeks. Next year, it’s going to continue to downtown Seattle, therefore one will be able to get all the way from SeaTac airport to the Microsoft campus by train.

And by the way, I often use the opportunity to visit some places in or around Seattle. This time, I went to Portland (Oregon), mainly to see the local Japanese garden.

Japanese garden - a pond and a waterfall

OfflineAuthenticationAdminEmail overwritten

My F&O environment asked me to log in every time to when I started debugging. I changed OfflineAuthenticationAdminEmail in DynamicsDevConfig.xml (at %USERPROFILE%\Documents\Visual Studio Dynamics 365), but I noticed that the value got overwritten every time when I started Visual Studio and opened an F&O project.

I tried changing the value in j:\AosService\PackagesLocalDirectory\bin\DynamicsDevConfig.xml, but it didn’t have any effect.

After some searching, I found that the value is copied from Provisioning.AdminPrincipalName in web.config (e.g. j:\AosService\WebRoot\web.config). Setting my account name there finally fixed the problem.

Entity collection as OData action parameter

Data entities in F&O can be exposed through OData protocol. You can also add OData actions by creating methods in X++ and decorating them with SysODataCollectionAttribute.

You can see an example in MssLeaveRequestDateEntity.getDirects():

[
    SysODataActionAttribute('getDirects', false),
    SysODataCollectionAttribute('return', Types::Record, 'MssLeaveRequestDateEntity')
]
public static List getDirects(
    str reportingPersonnelNumber,
    date fromDate,
    date toDate,
    LeaveRequestApprovalStatus leaveRequestStatus)
{
    List list = new List(Types::Record);
    ...
    return list;
}

It has parameters of several types and it returns a collection of entity records (additional metadata is provided in SysODataActionAttribute).

Now what if you want to add such a collection as an input parameter? It sounds straightforward, but if you do it, the action will completely disappear from the entity because it fails to generate.

I was able to get a confirmation that such a parameter type isn’t supported. It’s another case when event logs helped me. Namely, I found a warning in Application and Services Logs > Microsoft > Dynamics > AX-ODataService > Operational log. At the General tab, it said merely OData Metadata Build Warning, but the Details tab revealed much more:

ComponentNameODataServiceMetadataBuilder
infoMessageAction myTest (Method = myTest) on Entity MyEntity has a parameter (Type = Microsoft.Dynamics.Ax.Xpp.List, Name = inRecords) that resolves to an EntityType collection, which is not currently supported. Remove the parameter.

All right, so it’s explicitly unsupported. Note that this is just about a collection of records; you can use collections of primitive types such as numbers and strings.

The fact that this kind of warning can be found in event logs may be the most important information in this blog post. It may help with debugging of other issues related to OData in F&O.