The ASN1C code generation tool translates an Abstract Syntax Notation 1 (ASN.1) or XML Schema Definitions (XSD) source file into computer language source files that allow typed data to be encoded/decoded. This release of ASN1C includes options to generate code in the following languages: C, C++, C#, Java, Python, or Go. This manual discusses the C# code generation capabilities. The following other manuals discuss the other language code generation capabilities:
ASN1C C/C++ Compiler User’s Manual : C/C++ code generation
ASN1C Java Compiler User’s Manual : Java code generation
ASN1C Python Compiler User’s Manual : Python code generation
ASN1C Go Compiler User’s Manual : Go code generation
Each module or namespace that is encountered in an ASN.1 or XSD source file results in the generation of a series of C# source files. A separate C# file is generated for each production (type or global element) in the source file. Additional files are generated for compiler-generated productions and to hold value specification constants.
There is also a set of classes that form the run-time component of the C# package. These classes provide the primitive component building blocks that are assembled by the compiler to encode/decode complex structures. They also provide support for managing message buffers that hold the encoded message components.
ASN1C works with the version of ASN.1 specified in ITU-T international standards X.680 through X.683. It generates code for encoding/decoding data in accordance with the following encoding rules:
Basic Encoding Rules (BER), Distinguished Encoding Rules (DER), and Canonical Encoding Rules (CER) as published in the ITU-T X.690 and ISO/IEC 8825-1 standards.
Packed Encoding Rules (PER) as published in the ITU-T X.691 and ISO/IEC 8825-2 standards. Both aligned and unaligned variants are supported.
XML Encoding Rules (XER) as published in the ITU-T X.693 and ISO/IEC 8825-3 standards.
Octet Encoding Rules (OER) as published in the ITU-T X.696 and ISO/IEC 8825-7:2014 standards.
JSON Encoding Rules (JER) as published in the ITU-T X.697 and ISO/IEC 8825-8:2018 standards.
The compiler is capable of parsing all ASN.1 syntax as defined in the standards. It is capable of parsing advanced syntax including Information Object Specifications as defined in the ITU-T X.681 standard as well as Parameterized Types as defined in ITU-T X.683.
Note that XER support does not include support for the EXTENDED-XER syntax. This is accomplished through direct compilation of XSD files. An internal translation of XSD to ASN.1 based on the rules in the X.694 standard is done within the compiler and the resulting ASN.1 syntax is compiled into C# classes.
ASN1C also contains a special command-line option - -asnstd x208 - that allows compilation of deprecated features from the older X.208 and X.209 standards. These include the ANY data type and unnamed fields in SEQUENCE, SET, and CHOICE types. The compiler can also parse type syntax from common macro definitions such as the ROSE OPERATION and ERROR macros.