Redpoint.StringEnum 2025.1093.291

Prefix Reserved
dotnet add package Redpoint.StringEnum --version 2025.1093.291
                    
NuGet\Install-Package Redpoint.StringEnum -Version 2025.1093.291
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Redpoint.StringEnum" Version="2025.1093.291" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Redpoint.StringEnum" Version="2025.1093.291" />
                    
Directory.Packages.props
<PackageReference Include="Redpoint.StringEnum" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Redpoint.StringEnum --version 2025.1093.291
                    
#r "nuget: Redpoint.StringEnum, 2025.1093.291"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Redpoint.StringEnum&version=2025.1093.291
                    
Install Redpoint.StringEnum as a Cake Addin
#tool nuget:?package=Redpoint.StringEnum&version=2025.1093.291
                    
Install Redpoint.StringEnum as a Cake Tool

Redpoint.StringEnum

This library provides an API for defining and using string-backed enumeration types. These are useful when used with databases, where storing string values for enumerations improves forward and backward compatibility (unlike storing numeric values).

Defining a string-backed enumeration type

You can create a string-backed enumeration, by defining a class like so:

class Example : StringEnum<Example>
{
    public static readonly StringEnumValue<Example> FirstValue = Create("first-value");

    public static readonly StringEnumValue<Example> SecondValue = Create("second-value");

    public static readonly StringEnumValue<Example> ThirdValue = Create("third-value");

    // ...
}

The string values that represent the enumeration are case-and-byte sensitive (ordinal comparison). You can not create enumeration values from a null string; ArgumentNullException will be thrown if you pass a null value to Create.

Defining additional enumeration values at runtime

There is currently no API for defining additional enumeration values at runtime; the possible enumeration values are lazy-loaded once by looking at the static fields and static properties of the class that inherits from StringEnum<T> (via the T type parameter). Both public and non-public fields/properties are included.

This library is both trim and AOT-compatible, as it uses [DynamicallyAccessedMembers] to ensure the fields and properties of the enumeration type are available at runtime for reflection.

Static usage of values

In most code, you'll simply use the static readonly fields you've defined, such as Example.FirstValue. All instances of the value - even those from parsing - are guaranteed to be reference and value equal.

Parsing known values from strings

To parse a value that is known to be valid from a string, you can use Example.Parse or StringEnumValue<Example>.Parse:

var value = Example.Parse("first-value");
var value2 = StringEnumValue<Example>.Parse("second-value");

If the value is not valid when calling Parse, StringEnumParseException will be thrown. You should use TryParse (see below) if the value is potentially invalid.

If you pass a null value to Parse, ArgumentNullException will be thrown.

Parsing potentially invalid string values

If you're unsure whether a string is a valid enumeration value, you can use Example.TryParse or StringEnumValue<Example>.TryParse:

var isValid = Example.TryParse("...", out var value);
var isValid2 = StringEnumValue<Example>.TryParse("...", out var value2);

If you pass a null value to TryParse, ArgumentNullException will be thrown.

Parsing strings to runtime-based enumeration types

If you don't know the type of the string enumeration you want to parse into at compile time, you can use DynamicStringEnumValue.TryParse to parse any string value into an instance of StringEnumValue<T> by passing the StringEnumValue<T> type as the first parameter, like so:

var type = typeof(StringEnumValue<Example>);
var isValid = DynamicStringEnumValue.TryParse(type, "...", out var value);

You can use DynamicStringEnumValue.IsStringEnumValueType to check if type is a constructed generic type of StringEnumValue<T>. The APIs provided by DynamicStringEnumValue are primarily intended to be used with database serialization and deserialization, where the concrete types of values are not known at the point of deserialization.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Redpoint.StringEnum:

Package Downloads
Redpoint.CloudFramework

A framework for building ASP.NET Core applications on top of Google Cloud Firestore in Datastore mode. Not only does this framework provide a model-based API for interacting with Google Cloud Firestore, it contains useful implementations of things like database migrations, distributed locks, geographic indexes and sharded counters.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2025.1093.291 83 4/3/2025
2025.1091.38 116 4/1/2025
2025.1091.26 117 4/1/2025
2025.1090.237 104 3/31/2025
2025.1089.1386 103 3/30/2025
2025.1083.515 388 3/24/2025
2025.1083.408 317 3/24/2025
2025.1083.398 319 3/24/2025
2025.1083.125 319 3/24/2025
2025.1080.41 129 3/21/2025
2025.1075.357 201 3/16/2025
2025.1073.332 123 3/14/2025
2025.1072.541 156 3/13/2025
2025.1072.536 137 3/13/2025
2025.1064.602 219 3/5/2025
2025.1064.546 200 3/5/2025
2025.1062.589 149 3/3/2025
2025.1061.513 103 3/2/2025
2025.1060.490 92 3/1/2025
2025.1059.134 101 2/28/2025
2025.1057.1020 95 2/26/2025
2025.1056.584 89 2/25/2025
2025.1050.282 117 2/19/2025
2025.1050.232 105 2/19/2025
2025.1049.55 126 2/18/2025
2025.1045.285 102 2/14/2025
2025.1043.288 94 2/12/2025
2025.1043.246 90 2/12/2025
2025.1043.197 101 2/12/2025
2025.1043.180 88 2/12/2025
2025.1043.108 89 2/12/2025
2025.1043.38 88 2/12/2025
2025.1043.27 87 2/12/2025
2025.1042.725 102 2/11/2025
2025.1042.690 92 2/11/2025
2025.1042.688 98 2/11/2025
2025.1042.418 90 2/11/2025
2025.1042.215 99 2/11/2025
2025.1042.203 99 2/11/2025
2025.1042.184 94 2/11/2025
2025.1042.142 101 2/11/2025
2025.1042.127 97 2/11/2025
2025.1037.1327 91 2/6/2025
2025.1036.280 100 2/5/2025
2025.1036.55 101 2/5/2025
2025.1035.1387 111 2/4/2025
2025.1031.111 110 1/31/2025
2025.1030.916 103 1/30/2025
2025.1030.895 104 1/30/2025
2025.1030.592 105 1/30/2025
2025.1029.664 86 1/29/2025
2025.1029.632 83 1/29/2025
2025.1029.596 89 1/29/2025
2025.1028.386 83 1/28/2025
2025.1025.723 85 1/25/2025
2025.1025.712 85 1/25/2025
2025.1019.913 89 1/19/2025
2025.1018.374 91 1/18/2025
2025.1018.285 124 1/18/2025
2025.1017.646 82 1/17/2025
2025.1017.379 116 1/17/2025
2025.1016.1370 90 1/16/2025
2025.1016.765 86 1/16/2025
2025.1016.712 87 1/16/2025
2025.1016.550 87 1/16/2025
2025.1016.541 89 1/16/2025
2025.1016.532 90 1/16/2025
2025.1016.325 84 1/16/2025
2025.1016.308 86 1/16/2025
2025.1016.296 81 1/16/2025
2025.1016.237 96 1/16/2025
2025.1016.184 81 1/16/2025
2025.1016.70 83 1/16/2025
2025.1016.6 85 1/16/2025
2025.1015.1438 85 1/16/2025
2025.1015.1437 82 1/16/2025
2025.1015.1411 82 1/15/2025
2025.1015.240 53 1/15/2025
2025.1015.223 46 1/15/2025
2025.1015.183 54 1/15/2025
2025.1014.1342 60 1/14/2025
2025.1014.273 70 1/14/2025
2025.1014.256 74 1/14/2025
2025.1012.440 76 1/12/2025
2025.1012.327 81 1/12/2025
2025.1012.279 81 1/12/2025
2025.1002.636 94 1/2/2025
2025.1001.1435 96 1/2/2025
2025.1001.1397 89 1/1/2025
2025.1001.770 98 1/1/2025
2025.1001.570 103 1/1/2025
2025.1001.558 92 1/1/2025
2025.1001.421 96 1/1/2025
2025.1001.390 97 1/1/2025
2025.1001.234 110 1/1/2025
2025.1001.123 103 1/1/2025
2024.1360.354 98 12/25/2024
2024.1360.60 88 12/25/2024
2024.1360.32 87 12/25/2024
2024.1358.450 88 12/23/2024
2024.1358.359 88 12/23/2024
2024.1358.312 85 12/23/2024
2024.1358.244 95 12/23/2024
2024.1358.120 82 12/23/2024
2024.1348.253 102 12/13/2024
2024.1345.1379 84 12/10/2024
2024.1345.506 82 12/10/2024
2024.1345.379 82 12/10/2024
2024.1345.145 86 12/10/2024
2024.1345.72 84 12/10/2024
2024.1345.69 81 12/10/2024
2024.1345.15 92 12/10/2024
2024.1344.1436 87 12/10/2024
2024.1344.600 93 12/9/2024
2024.1344.411 95 12/9/2024
2024.1340.379 99 12/5/2024
2024.1340.15 92 12/5/2024
2024.1338.786 99 12/3/2024
2024.1338.722 104 12/3/2024
2024.1338.697 94 12/3/2024
2024.1338.639 97 12/3/2024
2024.1338.541 95 12/3/2024
2024.1338.318 84 12/3/2024
2024.1338.298 87 12/3/2024
2024.1338.98 94 12/3/2024
2024.1337.756 95 12/2/2024
2024.1337.634 101 12/2/2024
2024.1337.625 89 12/2/2024
2024.1337.621 92 12/2/2024
2024.1337.594 91 12/2/2024
2024.1337.136 79 12/2/2024
2024.1336.793 102 12/1/2024
2024.1336.773 101 12/1/2024
2024.1336.305 90 12/1/2024
2024.1336.12 105 12/1/2024
2024.1335.1421 99 11/30/2024
2024.1335.1384 97 11/30/2024
2024.1334.1308 95 11/29/2024
2024.1334.764 90 11/29/2024
2024.1334.722 95 11/29/2024
2024.1330.185 94 11/25/2024
2024.1328.505 101 11/23/2024
2024.1328.470 91 11/23/2024
2024.1328.452 92 11/23/2024
2024.1323.910 105 11/18/2024
2024.1323.653 88 11/18/2024
2024.1323.185 88 11/18/2024
2024.1323.49 86 11/18/2024
2024.1322.714 89 11/17/2024
2024.1320.653 95 11/15/2024
2024.1320.619 89 11/15/2024
2024.1320.601 84 11/15/2024
2024.1320.159 90 11/15/2024
2024.1320.98 91 11/15/2024
2024.1320.2 97 11/15/2024
2024.1319.1431 94 11/15/2024
2024.1319.1335 96 11/14/2024
2024.1317.631 97 11/12/2024
2024.1316.330 104 11/11/2024
2024.1311.540 90 11/6/2024
2024.1306.225 95 11/1/2024
2024.1306.199 101 11/1/2024
2024.1306.171 89 11/1/2024
2024.1306.117 103 11/1/2024
2024.1305.506 89 10/31/2024
2024.1305.502 88 10/31/2024
2024.1305.465 90 10/31/2024
2024.1305.442 91 10/31/2024
2024.1305.399 90 10/31/2024
2024.1299.1070 97 10/25/2024
2024.1289.621 98 10/15/2024
2024.1289.338 94 10/15/2024
2024.1277.836 96 10/5/2024
2024.1277.711 97 10/3/2024
2024.1277.695 94 10/3/2024
2024.1270.409 106 9/26/2024
2024.1269.621 106 9/25/2024
2024.1269.619 97 9/25/2024
2024.1269.605 106 9/25/2024
2024.1242.282 111 8/29/2024
2024.1242.261 109 8/29/2024
2024.1242.233 113 8/29/2024
2024.1238.829 126 8/25/2024
2024.1238.327 130 8/25/2024
2024.1225.297 117 8/12/2024
2024.1205.140 114 7/23/2024
2024.1204.110 116 7/22/2024
2024.1204.62 109 7/22/2024
2024.1190.491 118 7/8/2024
2024.1177.305 114 6/25/2024
2024.1168.700 121 6/16/2024
2024.1168.649 119 6/16/2024
2024.1168.535 124 6/16/2024
2024.1167.643 116 6/15/2024
2024.1166.989 112 6/14/2024
2024.1166.818 113 6/14/2024
2024.1166.535 117 6/14/2024
2024.1166.422 107 6/14/2024
2024.1166.362 112 6/14/2024
2024.1166.360 114 6/14/2024
2024.1165.1212 112 6/13/2024
2024.1165.1160 112 6/13/2024
2024.1165.1019 115 6/13/2024
2024.1165.978 109 6/13/2024
2024.1165.920 108 6/13/2024
2024.1165.908 113 6/13/2024
2024.1165.873 111 6/13/2024
2024.1165.830 111 6/13/2024
2024.1165.806 114 6/13/2024
2024.1165.794 119 6/13/2024
2024.1165.792 115 6/13/2024
2024.1165.761 113 6/13/2024
2024.1165.743 107 6/13/2024
2024.1165.735 113 6/13/2024
2024.1165.713 112 6/13/2024
2024.1165.640 106 6/13/2024
2024.1165.574 113 6/13/2024
2024.1165.466 109 6/13/2024
2024.1165.417 111 6/13/2024
2024.1165.392 108 6/13/2024
2024.1164.341 99 6/12/2024
2024.1155.941 122 6/3/2024
2024.1140.783 124 5/19/2024
2024.1140.692 111 5/19/2024
2024.1140.673 117 5/19/2024
2024.1129.506 113 5/8/2024
2024.1128.831 130 5/7/2024
2024.1124.465 95 5/3/2024
2024.1123.1162 98 5/2/2024
2024.1123.1117 88 5/2/2024
2024.1123.1050 79 5/2/2024
2024.1122.352 116 5/1/2024
2024.1122.233 116 5/1/2024
2024.1115.1101 118 4/24/2024
2024.1115.1048 103 4/24/2024
2024.1115.932 107 4/24/2024
2024.1115.858 115 4/24/2024
2024.1115.665 116 4/24/2024
2024.1115.648 106 4/24/2024
2024.1115.591 116 4/24/2024
2024.1101.390 114 4/10/2024
2024.1100.741 120 4/9/2024
2024.1099.526 124 4/8/2024
2024.1099.466 117 4/8/2024
2024.1098.573 121 4/7/2024
2024.1095.977 122 4/4/2024
2024.1095.847 117 4/4/2024
2024.1095.604 118 4/4/2024
2024.1095.485 140 4/4/2024
2024.1094.930 116 4/3/2024
2024.1094.910 126 4/3/2024
2024.1094.387 128 4/3/2024
2024.1094.313 116 4/3/2024
2024.1093.520 115 4/2/2024
2024.1092.240 115 4/1/2024
2024.1089.1425 131 3/29/2024
2024.1089.983 119 3/29/2024
2024.1089.942 107 3/29/2024
2024.1089.2 125 3/29/2024
2024.1088.1343 118 3/28/2024
2024.1088.1139 121 3/28/2024
2024.1088.875 92 3/28/2024
2024.1088.700 108 3/28/2024
2024.1088.603 122 3/28/2024
2024.1088.590 126 3/28/2024
2024.1088.575 121 3/28/2024
2024.1088.561 119 3/28/2024
2024.1088.506 123 3/28/2024
2024.1088.18 123 3/28/2024
2024.1087.1181 131 3/27/2024
2024.1087.1173 122 3/27/2024
2024.1087.1143 129 3/27/2024
2024.1087.1108 108 3/27/2024
2024.1087.950 119 3/27/2024
2024.1087.939 106 3/27/2024
2024.1087.252 124 3/27/2024
2024.1070.736 123 3/10/2024
2024.1049.1437 130 2/19/2024
2024.1036.571 130 2/5/2024
2024.1036.508 117 2/5/2024
2024.1032.1204 118 2/1/2024
2024.1032.1133 114 2/1/2024
2024.1032.1122 136 2/1/2024
2024.1032.1071 113 2/1/2024
2024.1032.940 109 2/1/2024
2024.1031.912 110 1/31/2024
2024.1031.893 111 1/31/2024
2024.1031.851 100 1/31/2024
2024.1031.829 107 1/31/2024
2024.1031.386 104 1/31/2024
2024.1031.318 126 1/31/2024
2024.1017.460 132 1/17/2024
2024.1017.420 111 1/17/2024
2024.1017.163 115 1/17/2024
2024.1016.414 640 1/16/2024
2024.1012.167 132 1/12/2024
2024.1011.406 125 1/11/2024
2024.1010.315 139 1/10/2024
2023.1358.326 170 12/24/2023
2023.1351.473 133 12/17/2023
2023.1351.445 135 12/17/2023
2023.1351.432 143 12/17/2023
2023.1350.478 134 12/16/2023
2023.1344.600 150 12/10/2023
2023.1344.529 159 12/10/2023
2023.1339.582 146 12/5/2023
2023.1338.1072 154 12/4/2023
2023.1336.844 145 12/2/2023
2023.1335.378 148 12/1/2023
2023.1335.236 142 12/1/2023
2023.1335.203 127 12/1/2023