The OSS ASN.1 C# compiler generates C# representations of ASN.1 schema types. The generated code provides a convenient API that can be used by your application to manipulate and encode/decode messages (or PDUs) defined in the schema. The generated code organization (folders and namespaces) reflects the schema structure (.asn files and ASN.1 modules) and can be either included in your .NET application project or C#-compiled into a separate .NET assembly that can be referenced by your application.
You can compile a schema in two ways: using ASN.1 Studio or using the command-line compiler. In both cases, the desired output is controlled by compiler options such as encoding rules, PDU features, encoding capabilities.
>asn1cs <schema(s)> [-<option(s)>]
The following command compiles myschema.asn and generates C# code compatible with BER encoding/decoding. The generated code is placed in the mycodec folder.
>asn1cs myschema -output mycodec -ber
The default file extension for input schema files is .asn. Similar to most language compilers, the OSS ASN.1 compiler accepts ASCII or UNICODE text files as input files. For more information, see Compiler Options.
A file that contains macro definitions must be specified prior to any files that reference such definitions, especially when the references include a macro argument.
Note that order is important when multiple schema files are used in the command line. By default, the last file defines the messages/PDUs for which C# data representation classes are generated. To change this behavior and generate classes for other files/types see the -root option and the OSS.ROOT directive.
Compiler command-line options are prefixed by a dash ("-"). They can be shortened to the fewest number of characters and they are not case-sensitive. For example, both of the following two command lines correctly specify -noWarning:
Both command lines will suppress all warning messages while compiling the contents of input1.asn.
If two command-line options contradict each other, the rightmost option is used. In the following example, the -Warning option is used:
asn1cs input1 -noWarning -Warning
Certain options accept operands, which are not prefixed with a dash, for example:
asn1cs input1 -listingFile myFile
The compiler creates an output listing file named myFile.lst. By default, output filenames are derived from the last input file name.
This documentation applies to the OSS® ASN.1 Tools for C# release 5.0 and later.
Copyright © 2020 OSS Nokalva, Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise, without the prior permission of OSS Nokalva, Inc.
Every distributed copy of the OSS® ASN.1 Tools for C# is associated with a specific license and related unique license number. That license determines, among other things, what functions of the OSS ASN.1 Tools for C# are available to you.