Custom Data Type Mappings


CodeGen includes several field loop tokens that emit, based on the Synergy data type of a field, an appropriate data type for use in various other languages. These tokens are  <FIELD_CSTYPE>, <FIELD_OCTYPE>, <FIELD_SNTYPE>, <FIELD_SQLTYPE> and <FIELD_VBTYPE>.

The data type mappings used by these tokens are hard coded to suitable default values within CodeGen. These default values generally follow the same rules that xfNetLink has always used when converting traditional Synergy types into .NET and Java types, and should work well in most scenarios. However if the defaults don't work in a particular scenario then it is possible to customize the values by specifying the data type mappings that you wish to use in an XML file.

The XML file must be defined in a specific way, and an example file called DataMappingsExample.xml is provided when you install or build CodeGen.

Within the XML file there are several main sections that correspond to the various languages that CodeGen supports:


Field Loop Token

XML File Section




Objective C



Synergy .NET










Visual Basic



Within each of these main sections there are data type mappings for each of the field types that CodeGen supports. For example, the default mappings for C# look like this:

<?xml version='1.0'?>

Note that <SmallDecimal> is used for D1-8 fields, <LargeDecimal> is used for D9-18, and <VeryLargeDecimal> is used for D19-28.

In some data mappings you may need to specify the length of a variable (e.g. the Alpha data type for SQL), or length and precision (e.g. the ImpliedDecimal data type for SQL). To support this requirement CodeGen will search for and replace the following specific patterns of characters within data mapping values defined in your XML file:

Pattern of Characters

Replaced With


The length if the field in parentheses. E.g. (10)


The length and precision of the field, separated by a period, in parentheses. E.g. (10.2)


The length and precision of the field, separated by a comma, in parentheses. E.g. (10,2)

You only need to specify the parts of the XML file that correspond to the specific data mappings that you wish to change. For example, if all you want to do is make the <FIELD_CSTYPE> token insert the TimeSpan data type for D8 and D6 date fields (YYYYMMDD and YYMMDD) then you would configure your data mappings file like this:

<?xml version='1.0'?>

Once you have configured your custom data mappings file you tell CodeGen to use it by using the -cdm command line option, or if you are using the CodeGenerator API via the CodeGenTaskSet.DataMappingsFile property.




Copyright © 2021  Synergex International, Inc.