The cost of code duplication

What I want to talk about today is a special case of code duplication: when we take an F&O application element created by some other company (Microsoft, ISVs or so) and create a copy in our model.

Usually, people do it to deal with code that can’t be accessed or extended, e.g. when we want to use code of an internal class. Duplicating the element and adjusting its code can be done in seconds; it’s much easier than carefully thinking about other solutions, creating extensibility requests and so on.

But it’s expensive in a long term. Everything is fine as long as the original element remains the same, but what if Microsoft fixes a bug, ISVs adds a new feature by extending the standard element or so? You have two options:

1. Identify changes and apply them to your copy

When you receive a new version (of the standard F&O application, of an ISV solution), you’ll find changes of all elements that you’ve duplicated (and their extensions) and you’ll implement them in your copies too.

Both the identification and the implementation requires time and effort and as with any other development, there is a risk of making a mistake. A big problem is also a lack of tools helping with this scenario.

2. Ignore the situation

Unfortunately, this is the usual approach. You keep using the old logic and hope that it won’t cause any problems. Note that this doesn’t just mean that you’re missing a particular feature. The behavior may be unpredictable, because you may be mixing the old and the new logic. For example, Microsoft two changes methods to fix a bug. One change gets applied, but the other one doesn’t, because you’re using a copy with the old code. What will happen is impossible to say; it may end up with corrupted production data or anything. The problems gets bigger and bigger over time.

Both approaches are expensive. It takes time to proactively maintain all copies every time when you get a new version of models from Microsoft or ISVs. What is the cost of ignoring the problem is hard to predict: it may be fine, it may cause you some troubles while dealing with missing features or olds bugs (already fixed in standard code), it may ruin your application update schedule (because you find too late that your code doesn’t work correctly on the new version) or it may cause something catastrophic. It’s not guaranteed to fail, but it’s a lot of risk.

When you consider duplicating an application element owned by another company, you should think about the cost of maintaining the copy. You should try to avoid the duplication, because then you don’t have to deal with these problems. If you have to, you should have a maintenance process used every time when you apply a new version.

If the reason for duplication is that the object can’t be extended or reused in the way you need, create an extensibility request to get the actual problem fixed. If you can’t wait for the fix (it takes a lot of time indeed), duplicate the element but consider it a temporary solution. Add a reminder to re-implement it when it becomes possible.

And if you have to duplicate something, make sure you do it right. For example, a common mistake is duplicating a data entity and keeping the same label, despite of getting compiler warnings about it. Only one of them will have a label in the list of entities in GUI.

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.