ASN.1/C# Compiler Directives Reference

Applies to: ASN.1/C# 4.5

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


Sets a special representation for INTEGERs whose size is not limited by the C# long integer type. When either directive is used, the corresponding INTEGER types are represented by the System.Numerics.BigInteger value type. By default, INTEGER types are represented by int or long depending on the value range constraints imposed on the INTEGER type.

The OSS.HUGE directive supports both global and local forms. When specified globally, absoluteReference refers to an ASN.1 INTEGER type that will be represented using the BigInteger representation. When specified locally, the directive takes no operands.

Local Directive Example

    A ::= INTEGER --<HUGE>--

Global Directive Example

--<ASN1.HugeInteger LengthModule.LengthData.lengthOfSolarSystem>--
    LengthData ::= SEQUENCE {
       lengthOfSolarSystem  INTEGER,
       units ENUMERATED{mm(0), cm(1), m(2), km(3), lightyears(4)}


  • The ASN.1/C# compiler does not support value notation for huge INTEGER values that are less than -18446744073709551615 or greater than 18446744073709551615. It will report the "C0267E: Number is too large" error if such a value is encountered in the ASN.1 schema. Note, however, that there is no limitation on values that the application can set using the C# BigInteger struct API.
  • The PER codec does not support coding of constrained INTEGER type values with bounds less than -18446744073709551615 or greater than 18446744073709551615.
  • The PER codec does not support coding of semi-constrained INTEGER type values with lower bounds less than -18446744073709551615 or greater than 18446744073709551615.
  • The PER codec does not support coding of semi-constrained and unconstrained INTEGER type values that are longer than 128K (131072) bits.
  • .NET 4.0 or later is required to build and run the application that maps particular INTEGER types to the BigInteger representation. When compiling the generated classes, the reference to the System.Numerics assembly should be explicitly added to the csc command-line (/r:System.Numerics.dll) or to the corresponding Visual Studio project.

Version Information

These directives are available in version 4.4 and later.

--<ASN1.Nickname ref nickname>--
--<OSS.Nickname ref nickname>--

Provides an alias to a type or module name from an ASN.1 module to be used in the generated code.

See Also

--<ASN1.PDU type [, type ] ...>--
--<OSS.PDU [type]>-- | --<OSS.NOPDU [type]>--

Indicates whether an ASN.1 type should be a PDU.

Default Behavior

By default, only unreferenced types are considered PDUs by the compiler, therefore can be encoded/decoded as complete units.

--<ASN1.Version 1990 | 1994 | 1997 | 2002 | 2008 | 2015
      moduleName [{ oid }]>--

This directive is useful for applications that have several versions of ASN.1 source in use.

If ASN1.Version conflicts with a -1990 | -2015 compiler option, the higher version year is used.

--<ASN1.WorkingSet name type [, type] ... >--

Enables you to select from the input ASN.1 schema, a subset of types that can be used in your application. In other words, the ASN1.WorkingSet directive enables you to specify, using one directive, all PDUs (the types of the messages to encode and decode). Values, information objects, etc. defined in the working set are also represented in the compiler generated code.

name is a working set name required for consistency between the ASN.1/C product and the ASN.1/C++ and ASN.1/Java products; otherwise it is ignored.

If type is a module name, this directive has the same effect as the OSS.ROOT directive, which causes all unreferenced types within this module to be considered PDUs.

See Also


--<OSS.ASN1VER type 1990 | 1994 | 1997 | 2002 | 2008 | 2015>--

Specifies the version of the ASN.1 standard for the input files.

Default Behavior

By default, before detecting a particular type of notation, the compiler uses neutral mode. After the compiler detects notation particular to a version, it switches out of neutral mode and enforces conformance to that standard.

See Also


--<OSS.BMPSTRING [type]>--

Determines the representation of the ASN.1 UTF8String type as either a C# string (default) or int[], which is the same as the representation of an ASN.1 UniversalString).

--<OSS.DECIMAL [type]>--
--<OSS.DOUBLE [type]>--

Determines the representation of the ASN.1 REAL type as either a C# double (default) or decimal.

--<OSS.EXTENSIBLE [type]>--

Provides the same function as the ASN.1 formal extension marker ("..."). You can use either the directive or the extension marker, but not both.

--<OSS.FIELDNAME ref newName>--
--<OSS.VALNAME ref newName>--
--<OSS.TYPENAME ref newName>--

Instructs the ASN.1 compiler to use the specified newName for a value, field in a structure, or a type.

See Also


--<OSS.INCLUDES "file"[, "file"...]>--

Specifies the name of one or more configuration files that you can add to the ASN.1 input. This is useful when defining different sets of compiler directives that can be included or excluded, depending on the application.

--<OSS.LONG [type]>--

Determines the representation of the ASN.1 INTEGER type as a C# long (64-bit).

--<OSS.NOVALUE val>--

Disables generation of C# value representations for the specified name.

--<OSS.ROOT [module [{oid}] ...]>--

Identifies ASN.1 modules that are used as root modules. In a root module, all unreferenced types are considered PDUs. In addition, the scope of non-root modules is to supply external references to root modules. If no module is provided, all input modules are considered root modules.

Default Behavior

By default, the last ASN.1 input file specified on the command line contains the root module.

See Also


--<OSS.SUPPRESS msgID[, msgID ...]>--

Disables printing of specific informatory and warning messages.

messageID specifies which message needs to be suppressed. The messageID can be either the full message identifier (A0178W) or just the numeric part of the message number (178).

By default, informatory and warning messages are suppressed when -noRelaxedMode is turned on.

See Also

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.