TOP

ASN.1/C# Compiler Options Reference

Applies to: ASN.1/C# 4.5

This section lists the compiler options alphabetically and provides a thorough description of their function.

-1990 | -2015

Specifies the version of the standard used in the input ASN.1 specification files.

The -1990 option indicates that the ASN.1 specification should contain only syntax that conforms to the 1990 standard.

The -2015 option indicates that the ASN.1 specification should contain only syntax that conforms to a more modern ASN.1 standard than 1990.


-allow <badcase>

Enables the compiler to retain a previous behavior specified by <badcase>. Use this option sparingly, only when it is absolutely necessary for a specific task.


-allow BadExplicitAutomaticTagging

Instructs the ASN.1/C# compiler to use explicit automatic tagging not only for untagged but also for tagged CHOICE types, open types, and "DummyReference" types, based on the interpretation of clause 31.2.7 c of the X.680 2002 ASN.1 standard.

In the following example, if -allow BadExplicitAutomaticTagging is specified, the compiler uses explicit automatic tagging for the ch field that has the tagged CHOICE type. If -allow BadExplicitAutomaticTagging is not specified, the compiler uses implicit tagging for this field.

B4114 DEFINITIONS AUTOMATIC TAGS ::= BEGIN
   Seq ::= [65] SEQUENCE { ch Cho }
   Cho ::= [65] CHOICE { b BOOLEAN }
   s Seq ::= { ch b : TRUE }
END

Version Information

The -allow BadExplicitAutomaticTagging compiler option is available in version 4.5 and later.


-assignments

Instructs the ASN.1 compiler to process type and value assignments found outside input modules.

Example

Module1 DEFINITIONS ::= BEGIN
   MyInt ::= INTEGER
END

ExtraModularType ::= INTEGER

Module2 DEFINITIONS ::= BEGIN
   MyBit ::= INTEGER
END
  

Remarks

If the -assignments option is not specified, the ASN.1 compiler issues an error because ExtraModularType is outside the bounds of BEGIN and END.


-autoEncDec | -noAutoEncDec

Enables or disables code generation for automatic decoding of ASN.1 open types, such as resolving types using ASN.1 component relation constraints.

See Also

-constraints | -noConstraints


-ber -per -uper -der -oer -coer -json -xer -exer -cxer

Specifies the encoding rules available at runtime:

  • Basic Encoding Rules (-ber)
  • Aligned Packed Encoding Rules (-per)
  • Unaligned PER Encoding Rules (-uper)
  • Distinguished Encoding Rules (-der)
  • Octet Encoding Rules (-oer)
  • Canonical Octet Encoding Rules (-coer)
  • JSON Encoding Rules (-json)
  • XML Encoding Rules (-xer)
  • Extended XML Encoding Rules (-exer)
  • Canonical XML Encoding Rules (-cxer)

Version Information

The -cxer compiler option is available in version 4.4 and later.

The -exer compiler option is available in version 4.3 and later.


-commandFile <file>

Specifies the name of a text file that contains command-line options. The compiler reads the specified file and treats the options as if they were found on the command line.


-compat v4.0.0

Generates type representations compatible with applications written for version 4.0.


-constraints | -noConstraints

Specifies whether constraint validation code is generated. The size of the generated code is smaller and can be executed faster.


-designerWarnings

Instructs the ASN.1 compiler to generate additional warning messages for protocol designers writing ASN.1 specifications.

Remarks

Additional warning messages are issued if:

  • The -per or -uper option is specified, but the compiler finds a SET, SEQUENCE, or CHOICE type that contains a single component and no extension marker ("..."). When you use PER, you cannot add fields, therefore a structured type with only one field is inefficient.
  • The -per or -uper option is specified and there is more than one unreferenced type in the root module. This might cause problems to determine the PDU number when decoding, because PER encodings don't have tag information. In this case, the application developer must pass the desired PDU number to the decoder.
  • A defined object set is missing in a table constraint when the ObjectSetFromObject notation is used for dummy information object sets.
  • An information object CLASS is defined using the WITH SYNTAX notation, but an optional element is not enclosed in square brackets ("[]").
  • A contents constraint includes only the ENCODED BY clause without a containing type defined, and automatic encoding/decoding is enabled.
  • A WITH COMPONENTS clause that has the OPTIONAL or ABSENT keyword applied to a type defined with a DEFAULT value is present in the input ASN.1 specification.

-encodeonly | -decodeonly

Controls the presence of encoder and decoder methods in generated PDU classes.

Reduce the code size of classes generated with the encoder or decoder methods by using the -encodeonly or -decodeonly compiler option, respectively.

Version Information

These options are available in version 4.4 and later.


-errorFile <file>

Instructs the compiler to redirect all ASN.1 compiler messages to <file>. This is useful on platforms where you cannot redirect stdout and stderr to a file.


-genDir <genfile>

Instructs the ASN.1 compiler to generate a .gen file that captures all directives from the ASN.1 input file as well as directives for names produced by the compiler (_setof1, for example).

Remarks

The optional operand genfile specifies the name of the .gen file. If the filename is not specified, the ASN.1 compiler generates one from the last ASN.1 input file specified on the command line and substitutes .asn with .gen.

See Also

-keepNames


-genSchemaInfo

Generates C# serialization attributes that include additional ASN.1 schema information, such as original names, optionality, etc., and can be helpful for text XML or JSON serialization formats.

Note: When generating C# classes that will be used with .NET Standard, do not specify the -genschemainfo compiler option. This option generates C# attributes that are not supported by .NET Standard.


-help

Displays a list of all command-line options.

Example

By entering asn1cs –help you can obtain a summary of valid command-line options:

OSS ASN.1/C# Compiler Version 4.5
Copyright (C) 2017 OSS Nokalva, Inc.  All rights reserved.

Compiler parameters: (.D. indicates default)
  <input> <...input> . one or more ASN.1 input files

  -syntax          ... perform syntax checking only
  -output name     ... use name for output file names
  -nooutput        ... do not generate output files, same as syntaxonly.
  -errorfile file  ... write all messages to 'file' instead of stdout/stderr
  -path <path>     ... use base directory 'path' for generated output
  -names schemacase | -names camelcase
                   ... select conversion method of ASN.1 names to C# names
  -namespace <name>... use namespace 'name' for generated classes
  -list <listfile> ... generate an ASN.1 combined listing into 'listfile'
  -nolist          .D. do not generate an ASN.1 combined listing
  -mod <listfile>  ... generate single ASN.1 module listings into 'listfile'
  -nomod           .D. do not generate single ASN.1 module listings
  -gendir <genfile>... generate list of directives into <genfile>

  -uniquepdu       .D. check that pdu id's are unique 
  -nouniquepdu     ... do not check that pdu id's are unique 
  -prefix id       ... prefix variables with unique id

  -constraints     .D. check constraints at runtime
  -noconstraints   ... do not check constraints at runtime
  -valuerefs       .D. generate C# values for all valuereferences
  -novaluerefs     ... do not generate C# values for all valuereferences
  -encodeonly      ... generate only encoder methods
  -decodeonly      ... generate only decoder methods
  -test            ... generate a program to encode/decode ASN.1 values
  -notest          .D. do not test encoding/decoding of all ASN.1 values

  -warning         ... allow warning messages
  -nowarning       ... suppress warning messages
  -suppress msg#   ... suppress a specific message
  -verbose         ... display compilation progress messages
  -noverbose       .D. do not display compilation progress messages
  -pedantic        ... rigorously check all modules
  -nopedantic      .D. rigorously check only the root module(s)
  -relaxedMode     .D. automatically select command-line options that
                       result in relaxed compiler behavior, for example,
                       -noWarning, etc.
  -norelaxedMode   ... automatically select command-line options that
                       result in strict compiler behavior
  -informatory     ... allow informatory messages
  -noinformatory   ... suppress informatory messages
  -ignoreError msg#... ignore a specific error (issue a warning instead)
  -designerWarnings... issue additional warnings for protocol designers
  -compat version# ... disable new features for backward compatibility
  -allow badcase   ... enable badcases for backward compatibility
  -1990            ... all modules conform to 1990 ASN.1 syntax
  -2015            ... all modules conform to 2015 ASN.1 syntax

  -per             ... generate output file for Aligned PER encoder/decoder
  -uper            ... generate output file for Unaligned PER encoder/decoder
  -ber             .D. generate output file for BER encoder/decoder
  -der             ... generate output file for DER encoder/decoder
  -xer             ... generate output for XER
  -cxer            ... generate output file for Canonical XER encoder/decoder
  -exer            ... generate output file for EXTENDED XER encoder/decoder
  -oer             ... generate output file for OER encoder/decoder
  -coer            ... generate output file for Canonical OER encoder/decoder
  -json            ... generate output file for JSON encoder/decoder

  -commandfile <file> ... read command line from 'file'
  -root            ... treat all modules as root modules
  -keepnames       ... generate directives for keeping names
  -sampleCode <pdus|values>
                   ... generate a sample code to initialize, encode, decode
                       and traverse values of PDU types defined in the input
                       ASN.1 syntax
  -noSampleCode    ... do not generate a sample code
  -autoencdec      .D. generate metadata for automatic decoding of open types
  -noautoencdec    ... do not generate metadata for automatic decoding of
                       open types
  -messageFormat   <format>
                   ... display error messages in <format>:
                       'oss', 'emacs' or 'msvc'
  -assignments     ... process type and value assignments defined outside
                       ASN.1 modules
  -helperAPI       ... generate specific helper API's selected via a keyword:
                       'pdudecoder' - helper API's for PDU decoding
  -noHelperAPI     ... do not generate specific helper API's selected via a keyword:
                       'pdudecoder' - helper API's for PDU decoding
  -ignoreIncompleteItems
                   ... ignore incomplete ASN.1 definitions of types and values
  -ignoreRedefinedAssignments
                   ... ignore redefined ASN.1 definitions of types and values
  -reservedWords <reserved_words>
                   ... treat words specified in the parameter and separated
                       by commas as reserved words in the generated files
                       that should be always mangled
  -singlefile      ... generate a single output file instead of a
                       set of output files containing a single class each
  -singlens        ... generate all the code into a single namespace
  -genschemainfo   ... generate attributes with schema information
  -noserializable  ... do not generate Serializable attributes

.. Jun 29 2017 ..

You can obtain a synopsis of the command-line syntax by entering asn1cs with no arguments:

OSS ASN.1/C# Compiler Version 4.5
Copyright (C) 2017 OSS Nokalva, Inc.  All rights reserved.

asn1cs  <infile(s)>    [-errorfile file      ] [-list listingfile | -nolist ]
    [-ber]             [-commandfile file    ] [-mod listingfile  | -nomod  ]
    [-der]             [-1990   | -2015      ] [-output name| -noout        ]
    [-oer]             [-test   | -notest    ] [-relaxedMode| -norelaxedMode]
    [-coer]            [-suppress    msg#    ] [-constraints| -noconstraints]
    [-per]             [-ignoreError msg#    ] [-autoencdec | -noauto       ]
    [-uper]            [-allow badcase       ] [-valuerefs  | -novaluerefs  ]
    [-json]            [-designerWarnings    ] [-uniquepdu  | -nouniquepdu  ]
    [-xer]             [-warning|-nowarning  ] [-messageFormat format       ]
    [-exer]            [-verbose|-noverbose  ] [-reservedWords <words>      ]
    [-root]            [-inform |-noinform   ] [-ignoreIncompleteItems      ]
    [-syntax]          [-pedantic|-nopedantic] [-ignoreRedefinedAssignments ]
    [-prefix id]       [-genschemainfo       ] [-sampleCode | -noSampleCode ]
    [-assignments]     [-noserializable      ] [-namespace <name>           ]
    [-names schemacase | -names camelcase    ] [-encodeonly | -decodeonly   ]
    [-ignoresuppress]

enter "asn1cs -help" for more information

-helperAPI pdudecoder

Enables generation of the service PDU decoder class so PDUs can be decoded without explicit specification of the PDU type.

Remarks

Automatic detection of the incoming message type is available in the BER, DER, XER, and CXER codecs.

Version Information

This option is available in version 4.4 and later.


-ignoreError <msgN>

Instructs the ASN.1 compiler to treat certain errors as warnings.

This option is especially useful for application developers that need to generate a header file and a control table or code file without correcting the ASN.1 specification. Note that the values generated in the control table or code file are not valid according to the ASN.1 standard.

Remarks

You can ignore the following message numbers: 49, 76, 77, 305, 319, 811, 832, 1078, 1130, 1162, 1207, 1211.

See Also

-relaxedMode


-ignoreIncompleteItems

Instructs the ASN.1 compiler to treat certain errors related to undefined ASN.1 types and values as warnings, and to ignore incomplete ASN.1 definitions that directly or indirectly reference undefined ASN.1 types and values.

Remarks

This option helps application developers to generate a header file and a control table or code file without correcting the ASN.1 specification, when undefined and incomplete ASN.1 items are not used by the application. Note that the compiler will not consider the ASN.1 types that are referenced only by ignored incomplete types as PDUs, unless you apply the PDU directive.

To see the incomplete items ignored by the compiler, use the -verbose option.

Example

In this example, S is incomplete because B is not defined:

M DEFINITIONS ::= BEGIN
  S ::= SEQUENCE { a A, b B }
  A ::= INTEGER
END
   

See Also


-ignoreRedefinedAssignments

Instructs the ASN.1 compiler to ignore all duplicate definitions within the same ASN.1 module, and to issue warnings instead of errors.

Remarks

-relaxedMode implies the -ignoreRedefinedAssignments option.

See Also

-relaxedMode


-informatory | -noInformatory

Informs the compiler whether it should generate informatory messages.

Remarks

When you use -relaxedMode or -noWarningMessages, the -noInformatoryMessages option is implied.

See Also


-keepNames

Creates a directive file (.gen file) to preserve generated type identifiers in subsequent compilations.

Remarks

The ASN.1 compiler might generate different names for a given type each time the schema is compiled, which requires further changes in your code. To avoid this, use the -keepNames option. When the schema is recompiled, specify the previously created .gen file as the first input file at the command line.

See Also

-genDirectives


-list <listfile> | -noList

Specifies whether the compiler should generate an ASN.1 composite listing of root modules, containing all macro instances and parameterized items expanded, and all external references resolved into <listfile>.

Remarks

The listing file contains valid ASN.1 and can be used as input to any ASN.1 compiler. If you don't specify it, the default name is the last command-line input filename, with the .lst extension.

See Also

-modListingFile


-messageFormat <format>

Controls the format of the error, warning, or informatory messages issued by the ASN.1 compiler for further parsing by a compatible text editor. This helps you automatically find the location in the input file for which the message was issued.

Remarks

Three format schemes are available:

oss
The default message format scheme used by the ASN.1 compiler.
Format:
file, line [(module)]: code: message.
Example:
msgfmt.asn, line 9 (Module-1): A0217W: The identifier 'address' is missing from the value and is assumed.
emacs
The format scheme is compatible with many text editors.
Format:
file[:module:]line:[position:]
msvc
The format scheme is compatible with the Microsoft development tools.
Format:
file(line[,position]) : [moduleName:] code: message.

-mod <listfile> | -noMod

Instructs the compiler to generate a module listing file that contains information from multiple ASN.1 modules.

See Also

-listingFile


-names schemacase | camelcase

Controls names mapping from ASN.1 schema to C# types/variables.

Remarks

By default, names is not specified, dashes are removed and the first letter is capitalized, for example:

ASN.1: one-two-XML --> C#: OneTwoXML.

If -names schemacase is specified, dashes are converted to underscores and capitalization is preserved, for example:

ASN.1: DL-CCCH-Message --> C#: DL_CCCH_Message.

If -names camelcase is specified, dashes are removed, the first letters are capitalized, and the rest are lowercased:

ASN.1: one-two-XML --> C#: OneTwoXml.

-namespace <name>

Specifies a custom <name> to be used for the generated code namespace; it replaces MySchema in the MySchema.MyModule pattern.

See Also

ASN1.Nickname


-noSerializable

Disables generation of the [System.Serializable] attribute for .NET frameworks or platforms that do not support it (for example, Windows Phone).

The -noSerializable compiler option can also be specified to instruct the compiler to generate C# classes compatible with .NET Standard.


-output <name> | -noOutput

Specifies the subfolder <name> where all generated output is placed. The noOutput option suppresses code generation, therefore only syntax checking is performed.


-path <path>

Specifies the <path> to where all generated output is placed.


-pedantic | noPedantic

Instructs the ASN.1 compiler to thoroughly check the input file syntax.

Remarks

If a type is not defined and it is neither directly nor indirectly referenced by the root modules, the compiler does not consider it an error.

-pedantic implies the -syntax option, therefore no code is generated.


-prefix <name>

Instructs the compiler to generate top-level identifiers with the specified name prefix. This is useful when an application program supports multiple schemas.


-relaxedMode | -noRelaxedMode

When you specify -relaxedMode, the following options are automatically selected:


-reservedWords <words>

Instructs the compiler to treat <words> (separated by commas, case-sensitive) as "reserved". This option is useful when certain platforms contain keywords that are not recognized by the OSS ASN.1 compiler as reserved for C#.


-root

Instructs the ASN.1 compiler to treat all input modules as root modules. Consequently, all unreferenced types (they are not referenced by any other type) in all modules are considered PDUs that can be encoded and decoded.

Default Behavior

By default, only the last module specified on the command line is treated as a root module.

See Also

OSS.ROOT


-sampleCode

Enables generation of a test application (a program class with the Main() method) that demonstrates the encoding or decoding of schema types for mockup values (or schema values, if any).


-singleFile

Generates code into a single file rather than one file per class.


-singleNs

Generates code into a single namespace rather than using the MySchema.MyModule naming pattern.


-suppress <msgN>

Instructs the compiler to suppress a specific warning or informatory message.

Remarks

You can specify -suppress more than once on the command line.

<msgN> can be either the complete message identifier (A0210W, for example) or the numeric part (210, for example).


-syntax

Instructs the ASN.1 compiler to perform only syntax checking, no code is generated.

See Also

-pedantic


-test | -noTest

Enables or disables generation of a test application (a program class with the Main() method), that demonstrates the encoding or decoding and requires at least one ASN.1 value defined in the schema.


-uniquePDU | -noUniquePDU

Specifies whether Protocol Data Unit (PDU) tags should be unique.

-uniquePDU specifies that the tags for all PDUs must be unique.

-noUniquePDU informs the compiler that PDUs can have identical tags.

Default Behavior

By default, when BER or DER is expected to be used at runtime, the compiler issues a warning message upon detecting duplicate PDU tags.

Remarks

Note that in certain ASN.1 specifications such as the Presentation Layer Protocol (ISO/IEC 8823/ITU-T X.226), PDUs don't have unique tags. In other ASN.1 specifications, such as the Association Control Service Element (ACSE), PDU tags are unique.


-valueRefs | -noValueRefs

Enables or disables generation of C# classes for values defined in the schema.


-verbose | -noVerbose

Specifies whether ASN.1 compiler status messages should be issued.

The -verbose option instructs the ASN.1 compiler to issue status messages, such as the name of the current input file.


-warningMessages | -noWarningMessages

Specifies whether compiler warning and informatory messages should be generated.


This documentation applies to the OSS® ASN.1 Tools for C# release 4.5 and later.

Copyright © 2017 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.