{"id":13629485,"url":"https://github.com/SteveDunn/Intellenum","last_synced_at":"2025-04-17T09:34:29.517Z","repository":{"id":139337898,"uuid":"606882644","full_name":"SteveDunn/Intellenum","owner":"SteveDunn","description":"Intelligent Enums","archived":false,"fork":false,"pushed_at":"2024-09-12T17:51:24.000Z","size":8508,"stargazers_count":197,"open_issues_count":5,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-12T22:29:55.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SteveDunn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-26T20:43:40.000Z","updated_at":"2024-10-02T21:45:11.000Z","dependencies_parsed_at":"2024-01-29T09:18:55.773Z","dependency_job_id":"99453988-b6bc-4a71-ac11-0e574fe80168","html_url":"https://github.com/SteveDunn/Intellenum","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveDunn%2FIntellenum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveDunn%2FIntellenum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveDunn%2FIntellenum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SteveDunn%2FIntellenum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SteveDunn","download_url":"https://codeload.github.com/SteveDunn/Intellenum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223751177,"owners_count":17196584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:01:11.783Z","updated_at":"2024-11-08T20:31:07.662Z","avatar_url":"https://github.com/SteveDunn.png","language":"C#","funding_links":[],"categories":["Contributors Welcome for those"],"sub_categories":["1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category"],"readme":"| Name           | Operating System      | Status                                                                              | History                                                                                                                                                                            |\n|:---------------|:----------------------|:------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| GitHub Actions | Ubuntu, Mac \u0026 Windows | ![Build](https://github.com/stevedunn/intellenum/actions/workflows/build.yaml/badge.svg) | [![GitHub Actions Build History](https://buildstats.info/github/chart/SteveDunn/intellenum?branch=main\u0026includeBuildsFromPullRequest=false)](https://github.com/SteveDunn/intellenum/actions) |\n\n [![GitHub release](https://img.shields.io/github/release/stevedunn/intellenum.svg)](https://GitHub.com/stevedunn/intellenum/releases/) [![GitHub license](https://img.shields.io/github/license/stevedunn/intellenum.svg)](https://github.com/SteveDunn/intellenum/blob/main/LICENSE) \n[![GitHub issues](https://img.shields.io/github/issues/Naereen/StrapDown.js.svg)](https://GitHub.com/stevedunn/intellenum/issues/) [![GitHub issues-closed](https://img.shields.io/github/issues-closed/Naereen/StrapDown.js.svg)](https://GitHub.com/stevedunn/intellenum/issues?q=is%3Aissue+is%3Aclosed) \n[![NuGet Badge](https://buildstats.info/nuget/intellenum)](https://www.nuget.org/packages/Intellenum/)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/social-preview.png\" alt=\"The Intellenum logo\"\u003e\n\u003c/p\u003e\n\n[![Sparkline](https://stars.medv.io/stevedunn/intellenum.svg)](https://stars.medv.io/stevedunn/intellenum)\n# Give a Star!\n:star: If you like or are using this project please give it a star. Thanks! :star:\n\n# Intellenum: intelligence, for your enums!\n\n\n\u003c!-- TOC --\u003e\n  * [Give a Star!](#give-a-star)\n* [Intellenum: intelligence, for your enums!](#intellenum-intelligence-for-your-enums)\n  * [Overview](#overview)\n  * [Installation](#installation)\n  * [Usage](#usage)\n    * [Configuration](#configuration)\n    * [Underlying types](#underlying-types)\n    * [Hoisting](#hoisting)\n    * [FromName](#fromname)\n    * [TryFromName](#tryfromname)\n    * [FromValue](#fromvalue)\n    * [TryFromValue](#tryfromvalue)\n    * [List](#list)\n    * [Deconstructing](#deconstructing)\n    * [ToString](#tostring)\n    * [Serialization](#serialization)\n* [Comparison with other libraries](#comparison-with-other-libraries)\n* [FAQ](#faq)\n  * [How fast is it? ⚡](#how-fast-is-it-)\n  * [What does `ToString` return?](#what-does-tostring-return)\n  * [What can the `TypeConverters` convert to and from?](#what-can-the-typeconverters-convert-to-and-from)\n  * [Can it serialize/deserialize?](#can-it-serializedeserialize)\n  * [I use an Intellenum as a key in a Dictionary - can I serialize that dictionary?](#i-use-an-intellenum-as-a-key-in-a-dictionary---can-i-serialize-that-dictionary)\n  * [A look at the generated code](#a-look-at-the-generated-code)\n\u003c!-- TOC --\u003e\n\n\n## Overview\n\nIntellenum is an open source C# project that provides a fast and efficient way to deal with enums. \nIt uses source generation that generates backing code for extremely fast, and allocation-free, lookups, \nwith the `FromName` and `FromValue` methods (and the equivalent `Try...` methods).\n\n\n```csharp\n[Intellenum]\npublic partial class CustomerType\n{\n    public static readonly CustomerType Standard, Gold;\n}\n```\n\nJust like normal enums, they default to integers as the underlying type, and the values are zero based.\n\nAs well as speed, it also has code analyzers for safety; safety from defaulting, e.g.:\n\n\u003e ![img.png](assets/img.png)\n\nor:\n\n\u003e ![img_1.png](assets/img_1.png)\n\nor:\n\n\u003e ![img_2.png](assets/img_2.png)\n\nIntellenum provides speed benefits over standard enums for when you need to see if an enum has a member \nof a particular name or value.\nBenchmarks are provided below, but here is a snippet showing the performance gains for using `IsDefined`:\n\n| Method          | Mean          | Error       | StdDev      | Median       | Gen0   | Allocated |\n|-----------------|---------------|-------------|-------------|--------------|--------|-----------|\n| StandardEnums   | 107.4646 ns   | 1.1617 ns   | 1.0867 ns   | 107.3232 ns  | 0.0057 | 96 B      |\n| **Intellenums** | **0.0022 ns** | **0.0031 ns**   | **0.0027 ns**   | **0.0010 ns**    | **-**      | **-**         |\n\n\n## Installation\n\nAdd the NuGet package to your project:\n\n```\nInstall-Package Intellenum\n```\n\n## Usage\n\nTo get started, add a using for the `Intellenum` namespace and declare an enumeration like this:\n\n```csharp\n[Intellenum]\npublic partial class CustomerType\n{\n    public static readonly CustomerType Standard, Gold;\n}\n```\n\nYou can also specify different values:\n\n```csharp\n[Intellenum]\npublic partial class CustomerType\n{\n    public static readonly CustomerType Standard = new(1000), Gold = new(2000);\n}\n```\n\nNote that you **don't need to repeat the member name** as it is inferred from the field name **at compile time**. \nYou can also supply a different name, e.g.:\n```csharp\npublic static readonly CustomerType Standard = new(\"STD\", 1);\n```\nBy default, the underlying type is `int`, but you can specify a different type, e.g. `[Intellenum\u003cshort\u003e]`.\n\nAs well as explicitly declaring members like above, there are a couple of other ways. You can use a static \nconstructor that calls `Member`. \n\n```csharp\n[Intellenum]\npublic partial class CustomerType\n{\n    static CustomerType()\n    {\n        Member(\"Standard\", 0);\n        Member(\"Gold\", 0);\n    }\n}\n```\n\n`Member` is actually executed at runtime, it is used at compile time to generate field declarations.\n\nAnother way is via attributes. You can use the `Member` attribute for single values, or the `Members` for multiple \nattributes. Here's an example of the `Member` attribute:\n\n```csharp\n[Intellenum]\n[Member(\"Standard\", 1)]\n[Member(\"Gold\", 2)]\npublic partial class CustomerType { }\n```\n\nHere's an example of the `Members` attribute. Not that this can only be applied to `int` based enums:\n\n```csharp\n[Intellenum]\n[Members(\"Standard, Gold, Diamond, Platinum\")]\npublic partial class CustomerType { }\n```\n\nUsing this attribute will generate the items in the order specified and the values will start at zero and \nincrease. \nThe `Members` attribute _can_ be applied with other `Member` attributes, \nbut only one `Members` attribute can be specified per type.\n\nYou can also use a mixture of all of the above methods!\n\n```csharp\n[Intellenum]\n[Members(\"Standard, Gold\")]\n[Member(\"Diamond\", 2)]\npublic partial class CustomerType \n{\n    static CustomerType()\n    {\n        Member(\"Platinum\", 3);\n    }\n    public static readonly CustomerType Royalty = new(4);\n}\n```\n\n... you can then treat the type just like an enum:\n\n```csharp\nif(type == CustomerType.Standard) Reject();\nif(type == CustomerType.Gold) Accept();\n```\n\n\n### Switch\nC# doesn't treat Intellenums as constants like it does with native enums. This makes it difficult to use in \nscenarios were a constant expression is needed, like in switch expressions. To get around this, const fields are \ngenerated which _can_ be used in switch expressions:\n```c#\nstring shortCode = vendorType.Value switch\n{\n    VendorType.StandardValue =\u003e \"STD\",\n    VendorType.PreferredValue =\u003e \"PRFRD\",\n    VendorType.BlockedValue =\u003e \"BLCKED\",\n    _ =\u003e throw new InvalidOperationException(\"Unknown vendor type\")\n};\n```\n\n### Configuration\n\nEach Intellenum can have its own *optional* configuration. Configuration includes:\n\n* The underlying type\n* Any 'conversions' (Dapper, System.Text.Json, Newtonsoft.Json, etc.) - see below for more information\n* Any 'customizations' (for instance, treating a number as string in JSON serialization)\n\nIf any of those above are not specified, then global configuration is used. You can define global config like this:\n\n```csharp\n[assembly: IntellenumDefaults(underlyingType: typeof(int), conversions: Conversions.Default)]\n```\nThose values are all optional and default to:\n\n* Underlying type = `int`\n* Conversions = `Conversions.Default` (`TypeConverter` and `System.Text.Json`)\n* Customizations = `Customizations.None`\n\n### Underlying types\nSupports underlying types such as `byte`, `sbyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `char`, `string`, and `bool`. \n\nAlso supports other types such as `Guid`, `DateTime`, `DateTimeOffset`, `TimeSpan`, `DateOnly`, `TimeOnly` etc.\n\nYou can also specify a custom type, e.g. `MyCustomType`. There are some restrictions for this custom type:\n* It cannot be a collection\n* It cannot be the same type as the enumeration itself\n\n###  Hoisting\nIf the underlying type implements `IComparable`, then the generated enum code will also implement `IComparable`. \nThe code that is generated will delegate to the underlying type's implementation. This means that you can use the `\u003e` and `\u003c` \noperators on the enum type. e.g.\n\n```csharp\n[Intellenum\u003cPlanet\u003e]\npublic partial class PlanetEnum\n{\n    public static readonly PlanetEnum\n        Jupiter = new(new Planet(\"Brown\", 273_400)),\n        Mars = new(new Planet(\"Red\", 13_240)),\n        Venus = new(new Planet(\"White\", 23_622));\n}\n\npublic record class Planet(string Colour, int CircumferenceInMiles) : IComparable\u003cPlanet\u003e\n{\n    public int CompareTo(Planet other) =\u003e CircumferenceInMiles.CompareTo(other.CircumferenceInMiles);\n}\n\nConsole.WriteLine(PlanetEnum.Mars \u003c PlanetEnum.Jupiter); // true\n\nConsole.WriteLine(string.Join(\", \", PlanetEnum.List().OrderDescending())); // Jupiter, Venus, Mars\n```\n\nAdditionally, if the underlying type contains a static method named `TryParse`, then a `TryParse` method will be generated for the enum itself.\nThis `TryParse` method is useful if you want to find an enum by an alternative representation of its value.\nThe generated `TryParse` first calls the static `TryParse` on the underlying type, and then does a lookup with `TryFromValue`.\nThe code below demonstrates this. The enum has an underlying type of `Planet`, which has a `TryParse` method that parses a string in the format `'Colour-Circumference'.\nBecause the underlying type has a `TryParse` method, the generated enum also has a `TryParse` method which delegates to the underlying type's `TryParse` method:\n\n```csharp\n[Intellenum\u003cPlanet\u003e]\npublic partial class PlanetEnum\n{\n    public static readonly PlanetEnum\n        Jupiter = new(new Planet(\"Brown\", 273_400)),\n        Mars = new(new Planet(\"Red\", 13_240)),\n        Venus = new(new Planet(\"White\", 23_622));\n}\n\npublic record class Planet(string Colour, int CircumferenceInMiles)  : IComparable\u003cPlanet\u003e\n{\n    public int CompareTo(Planet other) =\u003e CircumferenceInMiles.CompareTo(other.CircumferenceInMiles);\n\n    public static bool TryParse(string input, out Planet result)\n    {\n        string pattern = \"^(?\u003ccolour\u003e[a-zA-Z]+)-(?\u003ccircumference\u003e\\\\d+)$\";\n\n        Match match = Regex.Match(input, pattern);\n\n        if (!match.Success)\n        {\n            result = default!;\n            return false;\n        }\n\n        string colour = match.Groups[\"colour\"].Value;\n        string circumference = match.Groups[\"circumference\"].Value;\n\n        result = new Planet(colour, Convert.ToInt32(circumference));\n\n        return true;\n    }\n }\n\n// the following tests pass    \n{\n    // this is defined\n    bool r = PlanetEnum.TryParse(\"Brown-273400\", out var p);\n    r.Should().BeTrue();\n    p.Should().Be(PlanetEnum.Jupiter);\n}\n\n{\n    // this is not defined\n    bool r = PlanetEnum.TryParse(\"Blue-24901\", out _);\n    r.Should().BeFalse();\n}    \n}\n```\n                  \n### FromName\nGets the member of the enum with the specified name. If the name is not found, then a `IntellenumMatchFailedException` exception is thrown.\n\n```csharp\nvar ct = CustomerType.FromName(\"Gold\");\nConsole.WriteLine(ct.ToString()); // Gold\n```\n\n### TryFromName\nTries to get the instance of that name. Returns `true` if the name is found, otherwise `false`. Sets the output value if found.\n\n```csharp\nbool b = CustomerType.TryFromName(\"Gold\", out var ct);\nConsole.WriteLine(b); // True\nConsole.WriteLine(ct.ToString()); // Gold\n```\n\n### FromValue\nTries to get the instance of that value. If not found, then a `IntellenumMatchFailedException` exception is thrown.\n\n```csharp\nvar ct = CustomerType.FromValue(2);\nConsole.WriteLine(ct.ToString()); // Gold \n```\n\n### TryFromValue\nTries to get the value. Returns true or false. Sets the output value if found.\n\n```csharp\nbool b = CustomerType.TryFromValue(2, out var ct);\nConsole.WriteLine(b); // True\nConsole.WriteLine(ct.ToString()); // Gold\n```\n### List\nReturns an `IEnumerable\u003cT\u003e` of all the members of the enum. \n\n### Deconstructing\n\nDeconstructs an enum into it's name and value. For example:\n\n```csharp\nvar (name, value) = CustomerType.Gold;\nConsole.WriteLine(name); // Gold\nConsole.WriteLine(value); // 2\n```\n### ToString\n\nThe `ToString` method returns the name of the enum member. For example:\n\n```csharp\nConsole.WriteLine(CustomerType.Gold); // Gold\n```\n\n### Serialization\nIntellenum supports serialization to and from JSON using `System.Text.Json` and `Newtonsoft.Json`.\nIt also supports storing and retrieving from Dapper, EFCore and Linq2Db.\n\n\n# Comparison with other libraries\nThe bulk of Intellenum is based on the work done for Vogen which is a source generator for value objects. One of the features of Vogen\nis the ability to specify 'instances'. These instances are very similar to the members of an enum, but they are not enums.\nThere were a few requests to use the same source generation and analyzers used for Vogen but to generate enums instead. \nThis is what Intellenum is.\n\nThere are a few other libraries for dealing with enums. Some, for example, SmartEnum, declare a base class containing functionality.\nOthers, e.g. EnumGenerators, use attributes on standard enums to generate source code. \n\nIntellenum is a mixture of both. It uses an attribute to specify an 'enum' and then source-generates the functionality.\n\n\n\n\n# FAQ\n\n## How fast is it? ⚡\n\nVery fast! Here's some comparisons of various libraries (and the default `enum` in C#) \n\n* `IsDefined` ... or `TryFromValue`\n\n| Method          | Mean          | Error       | StdDev      | Median       | Gen0   | Allocated |\n|-----------------|---------------|-------------|-------------|--------------|--------|-----------|\n| StandardEnums   | 107.4646 ns   | 1.1617 ns   | 1.0867 ns   | 107.3232 ns  | 0.0057 | 96 B      |\n| EnumGenerators  | 0.0113 ns     | 0.0108 ns   | 0.0101 ns   | 0.0095 ns    | -      | -         |\n| SmartEnums      | 13.1542 ns    | 0.0863 ns   | 0.0720 ns   | 13.1441 ns   | -      | -         |\n| **Intellenums** | **0.0022 ns** | **0.0031 ns**   | **0.0027 ns**   | **0.0010 ns**    | **-**      | **-**         |\n\n* `ToString()`\n\n| Method          | Mean          | Error       | StdDev      | Gen0   | Allocated  |\n|-----------------|---------------|-------------|-------------|--------|------------|\n| StandardEnums   | 11.9803 ns    | 0.0961 ns   | 0.0852 ns   | 0.0014 | 24 B       |\n| EnumGenerators  | 1.5292 ns     | 0.0230 ns   | 0.0215 ns   | -      | -          |\n| SmartEnums      | 0.8921 ns     | 0.0109 ns   | 0.0096 ns   | -      | -          |\n| **Intellenums** | **0.8934 ns** | **0.0193 ns**   | **0.0180 ns**   | **-**      | **-**          |\n\n* `FromName()`\n\n| Method         | Mean        | Error      | StdDev     | Allocated | Example |\n|----------------|------------|------------|------------|-----------|------|\n| StandardEnums  | 123.937 ns | 0.5615 ns  | 0.4977 ns  | -         |                   `Enum.TryParse\u003cCustomerType\u003e(\"Standard\", out _)` |\n| EnumGenerators | 9.067 ns   | 0.0523 ns  | 0.0489 ns  | -         |                   `CustomerTypeExtensions.TryParse(\"Standard\", out _)` |\n| SmartEnums     | 30.719 ns  | 0.4043 ns  | 0.3782 ns  | -         |                   `CustomerType.TryFromName( \"Gold\", out _)` |\n| **Intellenums**    | **11.460 ns** | **0.2545 ns** | **0.2380 ns** | **-**         |   **`CustomerType.TryFromName(\"Standard\", out _)`** |\n\n* `Value` (_note that EnumGenerators isn't here as we use the standard C# enum to get its value_)\n\n| Method         | Mean       | Error      | StdDev     | Allocated |\n|----------------|-----------|------------|------------|-----------|\n| StandardEnums  | 0.0092 ns | 0.0082 ns  | 0.0077 ns  | -         |\n| SmartEnums     | 0.3246 ns | 0.0082 ns  | 0.0069 ns  | -         |\n| **Intellenums**   | **0.3198 ns** | **0.0103 ns** | **0.0096 ns** | **-**         |\n           \nIntellenum constantly monitors its performance. [The benchrmarks are here](https://intellenum.netlify.app/dev/bench/)\n, and are generated with a combination of excellent tools, namely Benchmark.NET and the [github-action-benchmark \nworkflow plugin](https://github.com/marketplace/actions/continuous-benchmark).\n\n## What does `ToString` return?\nIt returns the **name** of the member.\nThere is also a TypeConverter; when this is asked to convert a member to a `string',\nit returns the **value** of the member as a string.\n\n## What can the `TypeConverters` convert to and from?\nThey can convert an underlying type back to a matching enum.\n\n## Can it serialize/deserialize?\nYes, it can. There's various ways to do this, including:\n* System.Text.Json\n* Newtonsoft.Json\n* Dapper\n* Entity Framework Core\n* Linq2Db\n* TypeConverters\n\nRight now, Intellenum serializes using the `Value` property just like native enums.\n\n## I use an Intellenum as a key in a Dictionary - can I serialize that dictionary?\nYes, at least if you use `System.Text.Json`. \n\n# A look at the generated code\nFor compile-time constant (and `decimal`) values, a switch expression is generated for `IsDefined`:\n\n```csharp\npublic static bool IsDefined(System.Int32 value)\n{\n    return value switch { \n      1 =\u003e true,\n      2 =\u003e true,\n      3 =\u003e true,\n      4 =\u003e true,\n      _ =\u003e false\n    };\n}\n```\nFor `FromValue` (and `TryFromValue`), a switch statement is used:\n```csharp\npublic static bool TryFromValue(System.Int32 value, out CustomerType member)\n{\n  switch (value) \n  {\n      case 1:\n          member = CustomerType.Unspecified; \n          return true;\n      case 2:\n          member = CustomerType.Normal; \n          return true;\n      case 3:\n          member = CustomerType.Gold; \n          return true;\n      case 4:\n          member = CustomerType.Diamond; \n          return true;\n      default:\n          member = default;\n          return false;\n  }\n}\n```\n\nAs an aside, we experimented with using switch expressions for this too, but they turned out to be slower than normal\nswitch statements (about twice as slow) due to the need for having a tuple in the expression.\n\nThe generated code look like this:\n```csharp\npublic static bool TryFromValue(int value, out CustomerType member)\n{\n    Func\u003c(CustomerType, bool)\u003e f = value switch\n    {\n        1 =\u003e () =\u003e (CustomerType.Unspecified, true), \n        2 =\u003e () =\u003e (CustomerType.Normal, true), \n        3 =\u003e () =\u003e (CustomerType.Gold, true), \n        4 =\u003e () =\u003e (CustomerType.Diamond, true), \n        _ =\u003e () =\u003e (default, false)\n    };\n    \n    var r = f();\n    member = r.Item1;\n    return r.Item2;\n}\n```\n_If you can think of a way of making this faster, please let us know!_\n\nA 'compile time constant' is one of the following:\n* byte (and unsigned byte)\n* int16 (and unsigned int16)\n* int32 (and unsigned int32)\n* int64 (and unsigned int64)\n* string\n* decimal\n\nFor underlying types that are not one of these, then a lookup table is used.\nWhy is a lookup table used if the underlying is not one of the above? It is because the left hand side of a switch expression must be \na constant expression.\nA constant expression is used in the 'constant pattern' of the switch expression. The 'constant pattern' is [described as](https://learn.microsoft.com/en-US/dotnet/csharp/language-reference/operators/patterns#constant-pattern):\n\n\u003e A constant pattern is a pattern that matches a constant value. The constant value is specified by a constant expression. A constant expression is an expression that can be fully evaluated at compile time.n a constant pattern, you can use any constant expression, such as:\n\u003e\n\u003e * an integer or floating-point numerical literal\n\u003e * a char\n\u003e * a string literal.\n\u003e * a Boolean value true or false\n\u003e * an enum value\n\u003e * the name of a declared const field or local\n\u003e * null\n\nSo, types like `Guid` and `DateTime` are not allowed on the left hand side of a switch expression (but Span\u003c\u003e's are).\nThe alternative in this case is to use a dictionary to map between names and values.\n\n\n\u003e NOTE: Intellenum is in beta at the moment; I've tested it out and I think it works. The main functionality is present and the API probably \n\u003e won't change significantly from now on. Although it's a fairly new library, it borrows a lot of code and features from [Vogen](https://github.com/SteveDunn/Vogen) which \n\u003e has been in use for a while now by many projects and has lots of downloads, which should provide some confidence.\n\u003e Please feel free to try it and provide feedback.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSteveDunn%2FIntellenum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSteveDunn%2FIntellenum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSteveDunn%2FIntellenum/lists"}