Options

The Intellenum attribute provides a set of options to configure the generated code. The options can be set using the Intellenum attribute itself or via the VogenDefaults class.

Underlying Type

The underlyingType option specifies the underlying type of the enumeration. The default value is int. Supported types are:

  • byte, sbyte, short, ushort, int, uint, long, ulong, char, string, and bool
  • Guid, DateTime, DateTimeOffset, TimeSpan, DateOnly, TimeOnly
  • Custom types, e.g. MyCustomType

Restrictions for custom types:

  • Cannot be a collection.
  • Cannot be the same type as the enumeration itself.

Example:

[Intellenum(underlyingType = typeof(byte))]
          public partial class CustomerType
          {
              // ...
          }
          

Conversions

The conversions option specifies the type of conversion code to be generated. The default value is Conversions.Default.

Possible values:

  • Conversions.Default: Generates type converters and a converter to handle serialization using System.Text.Json.
  • Conversions.None: No conversion code is generated.
  • Conversions.Custom: You must provide custom conversion code.

Example:

[Intellenum(conversions = Conversions.None)]
          public partial class CustomerType
          {
              // ...
          }
          

Throws

The throws option specifies the type of exception thrown when validation fails. The default value is ValueObjectValidationException.

Example:

[Intellenum(throws = typeof(MyCustomException))]
          public partial class CustomerType
          {
              // ...
          }
          

Customizations

The customizations option enables simple customization switches. The default value is Customizations.None.

Possible values:

  • Customizations.None: No customization is applied.
  • Customizations.Immutable: Generates immutable classes.
  • Customizations.GenerateToString: Generates a ToString method.
  • Customizations.GenerateGetHashCode: Generates a GetHashCode method.

Example:

[Intellenum(customizations = Customizations.Immutable)]
          public partial class CustomerType
          {
              // ...
          }
          

Top-Level Directory Explanations

samples/ - This directory contains example projects demonstrating the usage of Intellenum.

samples/Intellenum.Examples/ - Contains various example projects demonstrating different aspects of Intellenum, such as serialization, conversion, syntax examples, types, typical scenarios, and more.

samples/WebApplication/ - Contains a sample web application that uses Intellenum.

src/ - This directory contains the source code of the Intellenum library.

src/Benchmarks/ - Contains benchmark tests for the Intellenum library.

src/Intellenum.SharedTypes/ - Contains shared types used across the Intellenum library.

src/Intellenum/ - Contains the main source code for the Intellenum library. This directory is further divided into subdirectories for diagnostics, extensions, generators, member building, properties, rules, static constructor building, templates, and more.

tests/ - This directory contains test projects for the Intellenum library.

tests/AnalyzerTests/ - Contains unit tests for the Intellenum analyzer.

tests/ConsumerTests/ - Contains tests for consuming the Intellenum library.

tests/Intellenum.Tests/ - Contains additional tests for the Intellenum library.

tests/Shared/ - Contains shared test files.

tests/SnapshotTests/ - Contains snapshot tests for the Intellenum library.