Attributes

The Intellenum attribute is used to define an Intellenum. It is applied to a class or struct, and it can optionally specify the underlying type.

[Intellenum]
          public partial class CustomerType
          {
          public static readonly CustomerType Standard = new(1);
          public static readonly CustomerType Gold = new(2);
          }
          

The MemberAttribute is used to define individual members of an Intellenum. It is applied to a class or struct, and it can optionally specify the name of the member and the value of the member.

[Intellenum]
          [Member("Standard", 1)]
          public partial class CustomerType
          {
          }
          

The MembersAttribute is used to define multiple members of an Intellenum. It is applied to a class or struct, and it takes a string that contains a comma-separated list of names.

[Intellenum]
          [Members("Standard,Gold")]
          public partial class CustomerType
          {
          }
          

The Member method is used to define individual members of an Intellenum. It is called from the static constructor of a class or struct, and it takes the name and value of the member.

[Intellenum]
          public partial class CustomerType
          {
          static CustomerType()
          {
          Member("Standard", 1);
          Member("Gold", 2);
          }
          }
          

The Members (plural) method is used to define multiple members of an Intellenum. It is called from the static constructor of a class or struct, and it takes a list of names.

[Intellenum]
          public partial class CustomerType
          {
          static CustomerType()
          {
          Members("Standard", "Gold");
          }
          }
          

The ValueObject attribute is used to define a value object. It is applied to a class or struct, and it can optionally specify the underlying type, the conversions to generate, the type of exception to throw when validation fails, and the customizations to apply.

[ValueObject]
          public readonly partial struct VogenStronglyTypedId {}
          

Example

[Intellenum]
          [Member("Standard", 1)]
          public partial class CustomerType
          {
          public static readonly CustomerType Gold = new CustomerType(2);
          public static readonly CustomerType Diamond = new CustomerType(3);
          
          }
          

This example defines an Intellenum named CustomerType that has three members: Standard, Gold, and Diamond. The Standard member is defined using the Member attribute, while the Gold and Diamond members are defined using field declarations.

Summary

Intellenum provides a fast and efficient way to deal with enums. It uses source generation that generates backing code for extremely fast, and allocation-free, lookups, with the FromName and FromValue methods (and the equivalent Try... methods).

Note: This outline is based on the information provided in the linked files. It may not be complete and may need to be updated as the project evolves.

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.

tests/Testbench/ - Contains a test bench for the Intellenum library.