Creating a WIT Adapter for the TFS Integration Platform for a source with no history

imageI have recently been working on a TFS Integration Platform Adapter for integrating with Test Track Pro. The problem with TTP is that it does not contain any history.

  • Update 2011-06-03 – Found the problem with the “index” and I can now migrate new work items again.

Although I have had my Test Track Pro Tip Adapter working for quite some time, the customer came back and asked if they could have a rolling migration. i.e. Shipping changes on a regular basis, but only the TIP each time.

The problem I ran into was that as all of the example Adapters are TIP adapters they do not take into account history at all. Here is the code for my first run through that was heavily based on Robert MacLean’s code from How to create an adapter for the TFS Integration Platform:

Figure: Full source for the Analysis Provider v1


Figure: Snipit of the Analysis Provider v1

The problem that I have encountered is that although it adds new Work Items that come into scope, it does not do any updates to those work item. Now, I can understand this if there had been any updates on the TFS side, but I can guarantee that there has not. So I sought help:

  • Action == Edit when pushing changes and == Add for a new one is correct.
  • Version … without debugging the consensus is that the lack of version information is causing the TIP type migration, rather than auctioning the history (edits).
  • Version Merge property … for VC only.
  • Ideas for Version property:
    • Option 1 – Create fake version numbers for the TTP side and using a single incrementing integer watermark across all of the TTP items.
    • Option 1 – Create fake version numbers for the TTP side and just copy the ChangeAction’s ChangeActionId value for this.

Willy-Peter Schaub, VSALM Ranger Mother

So I changed my code so that when the create action occurred it passed in a version (work item revision) number. As my source system does not have revisions, and does not even keep track of edits I just have to make up the number as long as it is greater than the one before. I went for Option 1 provided by Willy.

Figure: Full source code for new Analysis Provider v2

Figure: Snipit of the Analysis Provider v2

You can see in the full source for v2 of the Analysis Provider that I have added a new high watermark for the revision that should stay in sync with the number of runs of the migration there have been. This way, all of the edit’s  that happen on the third run will have a revision number of 3.


Figure: None of the originally imported data has a revision.

The problem now is that no matter how many times I run the import in my test environment I can’t get it to perform an edit. I am hoping that someone will be able to spot a silly mistake on my code that will solve this problem. it is one of those “stare at it for hours hoping it will just work” problems.

And it gets worse, now when I try to run the code I get an “Index was out of range” exception for the TFS server that I just can’t track down. I have even backed all my code back to a known working version and I still get the error. I have even gone so far as to restart the Target TFS server and try another one. Here is the log I keep getting:

Figure: Index was out of range. Must be non-negative and less than the size of the collection

My last and only hope is that in all the development and debugging the I broke the TFS Integration Platform install, so I am going to:

  1. Uninstall TFS Integration Platform
  2. Clean “C:Program Files (x86)Microsoft Team Foundation Server Integration Tools” of all files
  3. Check all locations where files are stored after the craziness that is getting the source for the TFS Integration Platform to build



Figure: Reinstalling the TFS Integration Platform is thankfully quick

So, that did not help and I am now getting two error messages for the data that I am parsing. Both of which are coming from TFS and are realy confusing me. The first is a “Index was out of range” error, which is just beyond me as I am not even passing any arrays.

Figure: Index was out of range. Must be non-negative and less than the size of the collection

The second is a date format exception that I would have thought should be taken care of by the Integration Platform and not wait until it gets to TFS.

Figure: String was not recognized as a valid DateTime

I have even checked the output that is sent to the TFS web service and I can’t see anything that jumps out as a problem…

In order to find out what is happening with the data (ChangeGroups) you can run the following query against your tfs_IntegrationPlatform database:


This will show you the actual data that is stored in the middle tier and allow you to maybe debug it. The result?


This data is what is actually produced as a change to be saved to TFS. I am a little concerned that the dates are in a variety of formats, but it was one of the ones that resulted in the “index” error:

Hopefully someone on the team will be able to help me out, but so far I have not been able to get this running…

On an whim I decided that the Dates might be  the problem all along and that the “Index was out of range” issue was a red hearing. So I commented out all of the date fields in the configuration file and what do you know… the “Index was out of range” errors went way…

So I dutifully check all of the date input and redo it so that everything is in the correct time zone and that


Figure: Refactored code to process the dates to the correct timezone

This did nothing! What I eventually had to do was to remove that mapping from the file. So no dates…

Figure: New mapping for Bugs

There are a number of things to note on the new mapping. After removing all of the Date fields I found that due to coning changes in the Adapter to achieve the “on behalf of” capability I have to remove both the “Modified By” and the “Created By” fields from the mapping otherwise I get a TF223001 error during the mapping.


Figure: Editing on behalf of

During the production run the “Created by [account]” will be the service account that Team Foundation Server runs under so it will be a little cleaner than having my name plastered all over it. Although it is OK to have the company name there Winking smile