Creation of Temporary Types

Temporary types are created when a SEQUENCE (or any other constructed type) definition contains other embedded constructed types. An example of this is as follows:

   A ::= SEQUENCE {
            x SEQUENCE {
               a1 INTEGER,
               a2 BOOLEAN
            },
            y OCTET STRING SIZE (10)
         }

In this example, the production has two elements – x and y. The nested SEQUENCE x has two additional elements – a1 and a2.

The ASN1C compiler first recursively pulls all of the embedded constructed elements out of the SEQUENCE and forms new temporary types. The names of the temporary types are of the form <name>_<element-name1>_<element-name2>_ … <element-nameN>. Using this algorithm, the ASN.1 type defined above would be reduced to the following equivalent ASN.1 types:

   A-x ::= SEQUENCE {
      a1 INTEGER,
      a2 BOOLEAN
   }

   A ::= SEQUENCE {
      x A-x,
      y OCTET STRING SIZE (10)
   }

The mapping of the ASN.1 types to C# classes would then be done.

In the case of nesting levels greater than two, all of the intermediate element names are used to form the final name. For example, consider the following type definition that contains three nesting levels:

   X ::= SEQUENCE {
      a SEQUENCE {
         aa SEQUENCE { x INTEGER, y BOOLEAN },
         bb INTEGER
      }
   }

In this case, the generation of temporary types results in the following equivalent type definitions:

   X-a-aa ::= SEQUENCE { x INTEGER, y BOOLEAN }

   X-a ::= SEQUENCE { aa X-a-aa, bb INTEGER }

   X ::= SEQUENCE { X-a a }

Note that the name for the aa element type is X-a-aa. It contains both the name for a (at level 1) and aa (at level 2). This is a change from v5.1x and lower where only the production name and last element name would be used (i.e., X-aa). The change was made to ensure uniqueness of the generated names when multiple nesting levels are used.