Beware of the TFS X++ Code Merge Bug: How to Avoid Losing Your Code
We recently encountered a project issue that caused some "project noise" when code from one developer was overwritten by another without any warnings from TFS. I'm sharing this case here in the hope that it might help you avoid similar issues in your project.
Initial Situation:
Let's consider a scenario in which we have a class committed to TFS, and the code on the development virtual machines (VMs) is identical.
Step 1(VM1):
Developer1 modifies method1 and commits the changes.
Step 2(VM2):
Developer2 opens the same class in the editor and, before making any changes, executes a “Get Latest Version” command—without closing the class edit window. At this point, the class appears unmodified in the project window, and all seems well.
领英推荐
Step 3(VM2):
Developer2 modifies method2 and commits his changes. No warning is given from TFS.
But if we check the source control history, we will see that the first commit from Developer1 was deleted by the latest commit from Developer2. Oops...
Possible Reasons and How to Avoid:
I suspect that the reason for this behaviour comes from the fact that in X++, source code is stored in ".xml" files, but what you see in the editor is a ".xpp" file. When the "Get Latest Version" command is executed, it updates the ".xml" file, and if you have the ".xpp" file open during this, the synchronization between the files becomes broken. So when Developer2 saves the file, it just overwrites ".xml" with the current open window text.
How to Resolve This:
If you close all open windows before you execute the "Get Latest Version" command, this issue will not happen. So, don't forget to update your project guidance to avoid issues like this. I tested this on .38, hope Microsoft resolves this in the future releases
Senior Enterprise Architect and PM, and Family Winemaker
12 个月Thanks for sharing Denis Trunin
Solution Architect @ Saina Cloud | Microsoft Dynamics 365, Power Apps
1 年Insightful, thanks for sharing
Technical Architect with 16 years in Microsoft D365FO/AX
1 年Good catch! Thank you!
That's why you should review changes before you check in the code. Report this to Microsoft so they can fix this. Was your VS updated? 2019 or 2022?