TOP

ASN.1/C# Compiler Options Reference

Applies to: ASN.1/C# v5.3

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

-1990 | -2021

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 -2021 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


-avn

Instructs the compiler to generate additional C# code that implements parsing of ASN.1 value notation data into C# objects that represent values defined by value notation.

Remarks

When the -avn option is specified, the compiler generates two additional C# classes in the ValueNotationParser.cs source file:

  • The ValueNotationParser class, which can parse a single value contained in a string.
  • The ValueNotationReader class, which can parse one or more values contained in a System.IO.TextReader object.

By default, the -avn option is disabled.

See Also

Value Parsing


-ber -per -uper -cper -cuper -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)
  • Canonical Aligned Packed Encoding Rules (-cper)
  • Canonical Unaligned PER Encoding Rules (-cuper)
  • 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)

Remarks

Currently, the OSS ASN.1 Tools for C# does not support CER.

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.

The -cper and -cuper compiler options are available in version 4.6 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 <flag>

Instructs the compiler to generate files compatible with previous versions of the OSS ASN.1 compiler. This option takes a single operand or flag, and can be specified more than once.

The following table contains the -compat flags listed alphabetically and provides a description.

Name Description
NoSeparatePduWrapperClasses
The same as the v4.0.0 flag.
ManglePduClassNameWhenDirectiveUnsupported
Prior to version 4.7.0, the PDU class names could depend on the presence of the directives that were applied to the ASN.1 types but were not supported and therefore were ignored. The following example demonstrates what has been changed:
--<ASN1.DeferDecoding M.S.s>--

M DEFINITIONS ::= BEGIN
    Foo ::= OCTET STRING

    S ::= SEQUENCE {
        s Foo --<NOCOPY>--
    }
END
Previously the SSEncodable class was generated instead of the Foo class for the Foo ASN.1 type. The ManglePduClassNameWhenDirectiveUnsupported flag restores generation of previous PDU class names in this case.
v4.0.0
Generates type representations compatible with applications written for version 4.0.
 v5.0.1ImportedWithSuccessorForwardedReferences
Restores the behavior of ASN.1 compiler versions prior to version 5.1 and instructs the ASN.1 compiler to not report errors or warnings for some unresolved forwarded references imported using WITH SUCCESSORS. Note that this behavior might cause an error or, in some cases, constraints (for example, contents constraints) specified inside inner subtype constraints applied to a parameterized type whose right-hand side type includes an instance of another parameterized type can be ignored.
v5.1ArtificialPDUsForRecursivesTypes
Restores the behavior of ASN.1 compiler versions prior to version 5.1 and instructs the ASN.1 compiler to create new artificial PDUs for complex recursive types defined through a CONSTRAINED BY syntax inside parameterized types.
The v5.1ContentsConstraintInsideOpenTypeValue compat flag was added in version 5.1.0.1.
v5.1ArtificialPDUsForRecursivesTypes
Restores the behavior of ASN.1 compiler versions prior to version 5.1 and instructs the ASN.1 compiler to create a new artificial PDU for a type with contents constraint inside an open type value even when a matching type exists in the information object set specified in the component relation constraint.
The v5.1ContentsConstraintInsideOpenTypeValue compat flag was added in version 5.1.0.1.
v5.1ForwardedNonParamReferencesImportedWithSuccessors
Restores the behavior of ASN.1 compiler versions prior to version 5.1 and instructs the ASN.1 compiler to skip some forwarded non-parameterized references that are defined later, are imported using WITH SUCCESSORS, and included inside actual parameters with inner subtype constraints in instances of parameterized types. This behavior might cause warnings in relaxed mode or errors in non-relaxed mode.
The v5.1ForwardedNonParamReferencesImportedWithSuccessors compat flag was added in version 5.1.0.1.
v5.1ConstrainedIntegerTypes
Restores the behavior of ASN.1 compiler versions prior to version 5.1 and instructs the ASN.1 compiler to generate the following:
  • The C# "int" type for INTEGER types constrained to have negative bounds that fit within the C# "int" type.
  • The C# "long" type for INTEGER types constrained with a MIN lower bound, a (MIN..MAX) value range, or with ALL EXCEPT.
v5.1.0
Provides compatibility with version 5.1.0 of the ASN.1 compiler. The v5.1.0 flag is equivalent to the following -compat options: v5.1ConstrainedIntegerTypes and v4.0.0.
v5.2.0
Provides compatibility with version 5.2.0 of the ASN.1/C# compiler. The v5.2.0 flag is equivalent to the v5.2TypesFromConstrainedBy and v5.2PdusForTypesFromDEFAULTInsideInfoObjClass -compat options.
v5.2PdusForTypesFromDEFAULTInsideInfoObjClass
Restores the behavior of ASN.1 compiler versions prior to version 5.2 and instructs the ASN.1 compiler to disambiguate conflicting PDU names with an additional module name for types used in a DEFAULT syntax applied to VariableTypeFields inside information object classes.
v5.2TypesFromConstrainedBy
Restores the behavior of ASN.1 compiler version prior to version 5.2. This flag instructs the ASN.1 compiler to generate names that were generated by previous versions of the ASN.1 compiler for types defined in a CONSTRAINED BY syntax. Note that this compat flag could restore an unexpected circular reference error for some syntaxes.

-constraints | -noConstraints

Specifies whether constraint validation code is generated. When -noCostraints is used, 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.

-enablePartialDecode

Instructs the ASN.1 compiler to enable partial decoding, in addition to standard decoding. Encoding is not affected.

Remarks

The -enablePartialDecode option is supported by the BER, DER, PER, UPER, CPER, CUPER, OER, and COER encoding rules.

By default, the -enablePartialDecode option is disabled.

See Also


-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.


-genSizeValueRangeAttributes

Instructs the ASN.1 compiler to generate the OSS-specific SizeAttribute and ValueRangeAttribute attributes that include the minimum and maximum values of all permitted counts, lengths, or values computed based on subtype constraints applied to the corresponding ASN.1 types.

Example:

  • For the ASN.1 subtype constraints (SIZE((1..5) | (10..20))), the effective minimum value is 1 and the effective maximum value is 20.
  • For the ASN.1 subtype constraints INTEGER ((-5..0) | (1..100)), the effective minimum value is -5 and the effective maximum value is 100.

Typically, attributes are attached to properties associated with classes that represent ASN.1 types with size or value range constraints. Attributes that correspond to constrained ASN.1 types that are defined as elements of SEQUENCE OF and SET OF types are attached to their parent collection class. Attributes can be retrieved by an application using C# Reflection at runtime.

SizeAttribute is generated for the following types with size constraints:

  • SEQUENCE OF
  • SET OF
  • restricted character strings
  • BIT STRING
  • OCTET STRING

SizeAttribute stores the effective minimum value in the Min property and the effective maximum value in the Max property. The C# "int" type has values between 0 and INT_MAX (2147483647). An additional IsExtensible property returns true if the corresponding size constraint is extensible, for example, (SIZE(1..2, ...)).

For semi-bounded size constraints, the Max property has the int.MaxValue value.

ASN.1 C#
name IA5String (SIZE(10..MAX))
[Oss.Asn1.Size(10, int.MaxValue, false)]
   public string Name { get; set; }

ValueRangeAttribute is generated for INTEGER types that have value range constraints and are not marked with a HUGE directive. The attribute stores the effective minimum value in the Min property and the effective maximum value in the Max property. The Min and Max properties have the C# "object" type. An additional OperandType property can be used to determine the actual C# integer type that can be either an "int", "long", or "ulong" type. The IsExtensible property returns true if the corresponding value range constraint is extensible.

You can access the minimum and maximum values of the Min and Max properties as follows:

if (rangeAttr.OperandType == typeof(int))
      int min = (int)rangeAttr.Min; 
      int max = (int)rangeAttr.Max;
} ...

For value ranges with MIN and/or MAX effective bounds, the long.MinValue and/or long.MaxValue values are generated:

ASN.1 C#
valueMin INTEGER (MIN..50)

valueMax INTEGER (10..MAX)
  [Oss.Asn1.ValueRange(long.MinValue, (long)50, false)]
  public long ValueMin { get; set; }

   [Oss.Asn1.ValueRange(long)10, long.MaxValue, false)]
    public long ValueMax { get; set; }

Example

ASN.1 C#
Bcas DEFINITIONS ::= BEGIN
BBCard ::= SEQUENCE {
    name IA5String (SIZE (1..60)),
    
    age INTEGER (1..100, ...),
    
    positions SEQUENCE (SIZE(2)) 
                   OF IA5String (SIZE (1..30)) 
}

END
  public partial class BBCard : Oss.Asn1.BasePdu
 {
     [Oss.Asn1.Size(1, 60, false)]
     public string Name { get; set; }

     [Oss.Asn1.ValueRange((int)1, (int)100, true)]
     public int Age { get; set; }

     [Oss.Asn1.Size(1, 30, false)]
     public partial class PositionsType : System.Collections.Generic.List<string>
	
     [Oss.Asn1.Size(2, 2, false)]
     public PositionsType Positions { get; set; }

-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 5.3
Copyright (C) 2023 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 generated output
  -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
  -2021            .D. all modules conform to 2021 ASN.1 syntax

  -per             ... generate output for Aligned PER
  -cper            ... generate output for Canonical Aligned PER
  -uper            ... generate output for Unaligned PER
  -cuper           ... generate output for Canonical Unaligned PER
  -ber             .D. generate output for BER
  -der             ... generate output for DER
  -xer             ... generate output for XER
  -cxer            ... generate output for Canonical XER
  -exer            ... generate output for Extended XER
  -oer             ... generate output for OER
  -coer            ... generate output for Canonical OER
  -json            ... generate output for JSON
  
  -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
  -enablePartialDecode
                   ... generate time-optimized full and partial decoders
  -partialDecodeOnly
                   ... generate time-optimized partial decoder only
  -avn             ... generate output for ASN.1 value notation parser

  -genSizeValueRangeAttributes
                   ... generate attributes for effective size constraints
                       and effective value ranges applied to INTEGER types
  -nullableReferenceTypes
                   ... enable C# nullable reference types
  -noNullableReferenceTypes
                   .D. disable C# nullable reference types

.. Sep  1 2023 ..

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

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

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

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.


-nullableReferenceTypes

Instructs the ASN.1/C# compiler to generate a nullable aware context with nullable reference types for the following schema fields:

  • Fields that have ASN.1 reference types marked as OPTIONAL or DEFAULT within a SET, SEQUENCE, or CLASS type
  • Fields that appear after the extension marker ("...") in a SET or SEQUENCE type
  • Alternatives in a CHOICE type

Previously, only C# nullable value types were supported for the following ASN.1 simple types: BOOLEAN, INTEGER, NULL, ENUMERATED, and REAL.

When -nullableReferenceTypes option is specified, each generated C# file includes a "#nullable enable annotations" directive. Variables with nullable reference types are generated with a "?" nullable modifier. A C# compiler that supports C# language version 8.0 or later (available in Visual Studio 2019 or later) must be used during compilation.

Example

ASN.1 Type.cs
Mod DEFINITIONS ::= BEGIN
   BBCard ::= SEQUENCE {
       name IA5String OPTIONAL,
       age INTEGER DEFAULT 20,
       ...,
       positions SEQUENCE OF IA5String
   }
END
        /// <summary>Field 'name'</summary>
        public string? Name { get; set; }
        /// <summary>Field 'age'</summary>
        public int? Age { get; set; }
        ...
        /// <summary>Field 'positions'</summary>
        public PositionsType? Positions { get; set; }

-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.


-partialDecodeOnly

Instructs the compiler to replace standard decoding with partial decoding. In this case, no standard decoding functions are generated.

Remarks

The -partialDecodeOnly option is supported for the BER, DER, PER, UPER, CPER, CUPER, OER, and COER encoding rules.

By default, the -partialDecodeOnly option is disabled.

See Also


-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 5.3 and later.

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