Redpoint.StringEnum 2025.1135.143

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Redpoint.StringEnum --version 2025.1135.143
                    
NuGet\Install-Package Redpoint.StringEnum -Version 2025.1135.143
                    
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.1135.143" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Redpoint.StringEnum" Version="2025.1135.143" />
                    
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.1135.143
                    
#r "nuget: Redpoint.StringEnum, 2025.1135.143"
                    
#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.1135.143
                    
Install Redpoint.StringEnum as a Cake Addin
#tool nuget:?package=Redpoint.StringEnum&version=2025.1135.143
                    
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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.1136.150 0 5/16/2025
2025.1135.267 26 5/15/2025
2025.1135.143 27 5/15/2025
2025.1133.453 60 5/13/2025
2025.1133.351 53 5/13/2025
2025.1133.349 52 5/13/2025
2025.1133.347 57 5/13/2025
2025.1130.236 59 5/10/2025
2025.1129.831 93 5/9/2025
2025.1129.346 117 5/9/2025
2025.1129.345 114 5/9/2025
2025.1121.1370 135 5/1/2025
2025.1119.450 144 4/29/2025
2025.1119.436 143 4/29/2025
2025.1119.409 146 4/29/2025
2025.1119.388 146 4/29/2025
2025.1119.360 140 4/29/2025
2025.1119.328 161 4/29/2025
2025.1119.299 145 4/29/2025
2025.1119.287 146 4/29/2025
2025.1116.868 74 4/26/2025
2025.1116.841 69 4/26/2025
2025.1116.444 71 4/26/2025
2025.1115.498 115 4/25/2025
2025.1115.491 121 4/25/2025
2025.1100.365 167 4/10/2025
2025.1100.336 160 4/10/2025
2025.1100.331 168 4/10/2025
2025.1098.108 156 4/8/2025
2025.1093.291 168 4/3/2025
2025.1091.38 172 4/1/2025
2025.1091.26 172 4/1/2025
2025.1090.237 160 3/31/2025
2025.1089.1386 157 3/30/2025
2025.1083.515 405 3/24/2025
2025.1083.408 334 3/24/2025
2025.1083.398 335 3/24/2025
2025.1083.125 333 3/24/2025
2025.1080.41 143 3/21/2025
2025.1075.357 212 3/16/2025
2025.1073.332 132 3/14/2025
2025.1072.541 165 3/13/2025
2025.1072.536 147 3/13/2025
2025.1064.602 228 3/5/2025
2025.1064.546 209 3/5/2025
2025.1062.589 158 3/3/2025
2025.1061.513 112 3/2/2025
2025.1060.490 102 3/1/2025
2025.1059.134 110 2/28/2025
2025.1057.1020 104 2/26/2025
2025.1056.584 99 2/25/2025
2025.1050.282 126 2/19/2025
2025.1050.232 115 2/19/2025
2025.1049.55 136 2/18/2025
2025.1045.285 112 2/14/2025
2025.1043.288 103 2/12/2025
2025.1043.246 99 2/12/2025
2025.1043.197 110 2/12/2025
2025.1043.180 97 2/12/2025
2025.1043.108 98 2/12/2025
2025.1043.38 97 2/12/2025
2025.1043.27 96 2/12/2025
2025.1042.725 111 2/11/2025
2025.1042.690 101 2/11/2025
2025.1042.688 107 2/11/2025
2025.1042.418 99 2/11/2025
2025.1042.215 108 2/11/2025
2025.1042.203 109 2/11/2025
2025.1042.184 103 2/11/2025
2025.1042.142 110 2/11/2025
2025.1042.127 106 2/11/2025
2025.1037.1327 100 2/6/2025
2025.1036.280 109 2/5/2025
2025.1036.55 110 2/5/2025
2025.1035.1387 120 2/4/2025
2025.1031.111 118 1/31/2025
2025.1030.916 112 1/30/2025
2025.1030.895 112 1/30/2025
2025.1030.592 113 1/30/2025
2025.1029.664 95 1/29/2025
2025.1029.632 91 1/29/2025
2025.1029.596 97 1/29/2025
2025.1028.386 91 1/28/2025
2025.1025.723 94 1/25/2025
2025.1025.712 93 1/25/2025
2025.1019.913 97 1/19/2025
2025.1018.374 99 1/18/2025
2025.1018.285 132 1/18/2025
2025.1017.646 90 1/17/2025
2025.1017.379 124 1/17/2025
2025.1016.1370 98 1/16/2025
2025.1016.765 94 1/16/2025
2025.1016.712 95 1/16/2025
2025.1016.550 96 1/16/2025
2025.1016.541 97 1/16/2025
2025.1016.532 98 1/16/2025
2025.1016.325 92 1/16/2025
2025.1016.308 94 1/16/2025
2025.1016.296 89 1/16/2025
2025.1016.237 104 1/16/2025
2025.1016.184 90 1/16/2025
2025.1016.70 92 1/16/2025
2025.1016.6 93 1/16/2025
2025.1015.1438 93 1/16/2025
2025.1015.1437 90 1/16/2025
2025.1015.1411 90 1/15/2025
2025.1015.240 61 1/15/2025
2025.1015.223 53 1/15/2025
2025.1015.183 62 1/15/2025
2025.1014.1342 68 1/14/2025
2025.1014.273 80 1/14/2025
2025.1014.256 84 1/14/2025
2025.1012.440 86 1/12/2025
2025.1012.327 89 1/12/2025
2025.1012.279 89 1/12/2025
2025.1002.636 102 1/2/2025
2025.1001.1435 104 1/2/2025
2025.1001.1397 98 1/1/2025
2025.1001.770 106 1/1/2025
2025.1001.570 111 1/1/2025
2025.1001.558 100 1/1/2025
2025.1001.421 104 1/1/2025
2025.1001.390 105 1/1/2025
2025.1001.234 118 1/1/2025
2025.1001.123 111 1/1/2025
2024.1360.354 106 12/25/2024
2024.1360.60 96 12/25/2024
2024.1360.32 95 12/25/2024
2024.1358.450 96 12/23/2024
2024.1358.359 96 12/23/2024
2024.1358.312 94 12/23/2024
2024.1358.244 103 12/23/2024
2024.1358.120 90 12/23/2024
2024.1348.253 110 12/13/2024
2024.1345.1379 92 12/10/2024
2024.1345.506 92 12/10/2024
2024.1345.379 91 12/10/2024
2024.1345.145 95 12/10/2024
2024.1345.72 94 12/10/2024
2024.1345.69 91 12/10/2024
2024.1345.15 101 12/10/2024
2024.1344.1436 96 12/10/2024
2024.1344.600 102 12/9/2024
2024.1344.411 105 12/9/2024
2024.1340.379 108 12/5/2024
2024.1340.15 102 12/5/2024
2024.1338.786 108 12/3/2024
2024.1338.722 113 12/3/2024
2024.1338.697 103 12/3/2024
2024.1338.639 106 12/3/2024
2024.1338.541 104 12/3/2024
2024.1338.318 93 12/3/2024
2024.1338.298 96 12/3/2024
2024.1338.98 104 12/3/2024
2024.1337.756 105 12/2/2024
2024.1337.634 109 12/2/2024
2024.1337.625 97 12/2/2024
2024.1337.621 100 12/2/2024
2024.1337.594 99 12/2/2024
2024.1337.136 87 12/2/2024
2024.1336.793 110 12/1/2024
2024.1336.773 110 12/1/2024
2024.1336.305 99 12/1/2024
2024.1336.12 113 12/1/2024
2024.1335.1421 107 11/30/2024
2024.1335.1384 105 11/30/2024
2024.1334.1308 103 11/29/2024
2024.1334.764 99 11/29/2024
2024.1334.722 103 11/29/2024
2024.1330.185 102 11/25/2024
2024.1328.505 109 11/23/2024
2024.1328.470 99 11/23/2024
2024.1328.452 100 11/23/2024
2024.1323.910 113 11/18/2024
2024.1323.653 96 11/18/2024
2024.1323.185 96 11/18/2024
2024.1323.49 95 11/18/2024
2024.1322.714 97 11/17/2024
2024.1320.653 104 11/15/2024
2024.1320.619 97 11/15/2024
2024.1320.601 92 11/15/2024
2024.1320.159 98 11/15/2024
2024.1320.98 100 11/15/2024
2024.1320.2 105 11/15/2024
2024.1319.1431 102 11/15/2024
2024.1319.1335 105 11/14/2024
2024.1317.631 105 11/12/2024
2024.1316.330 112 11/11/2024
2024.1311.540 98 11/6/2024
2024.1306.225 103 11/1/2024
2024.1306.199 109 11/1/2024
2024.1306.171 97 11/1/2024
2024.1306.117 111 11/1/2024
2024.1305.506 97 10/31/2024
2024.1305.502 97 10/31/2024
2024.1305.465 98 10/31/2024
2024.1305.442 99 10/31/2024
2024.1305.399 98 10/31/2024
2024.1299.1070 105 10/25/2024
2024.1289.621 106 10/15/2024
2024.1289.338 102 10/15/2024
2024.1277.836 104 10/5/2024
2024.1277.711 105 10/3/2024
2024.1277.695 102 10/3/2024
2024.1270.409 115 9/26/2024
2024.1269.621 114 9/25/2024
2024.1269.619 105 9/25/2024
2024.1269.605 114 9/25/2024
2024.1242.282 119 8/29/2024
2024.1242.261 117 8/29/2024
2024.1242.233 121 8/29/2024
2024.1238.829 134 8/25/2024
2024.1238.327 138 8/25/2024
2024.1225.297 125 8/12/2024
2024.1205.140 122 7/23/2024
2024.1204.110 124 7/22/2024
2024.1204.62 117 7/22/2024
2024.1190.491 126 7/8/2024
2024.1177.305 122 6/25/2024
2024.1168.700 129 6/16/2024
2024.1168.649 127 6/16/2024
2024.1168.535 132 6/16/2024
2024.1167.643 124 6/15/2024
2024.1166.989 120 6/14/2024
2024.1166.818 121 6/14/2024
2024.1166.535 126 6/14/2024
2024.1166.422 115 6/14/2024
2024.1166.362 120 6/14/2024
2024.1166.360 122 6/14/2024
2024.1165.1212 120 6/13/2024
2024.1165.1160 121 6/13/2024
2024.1165.1019 124 6/13/2024
2024.1165.978 117 6/13/2024
2024.1165.920 116 6/13/2024
2024.1165.908 121 6/13/2024
2024.1165.873 119 6/13/2024
2024.1165.830 119 6/13/2024
2024.1165.806 122 6/13/2024
2024.1165.794 127 6/13/2024
2024.1165.792 123 6/13/2024
2024.1165.761 121 6/13/2024
2024.1165.743 115 6/13/2024
2024.1165.735 121 6/13/2024
2024.1165.713 120 6/13/2024
2024.1165.640 114 6/13/2024
2024.1165.574 121 6/13/2024
2024.1165.466 117 6/13/2024
2024.1165.417 119 6/13/2024
2024.1165.392 116 6/13/2024
2024.1164.341 107 6/12/2024
2024.1155.941 130 6/3/2024
2024.1140.783 132 5/19/2024
2024.1140.692 119 5/19/2024
2024.1140.673 125 5/19/2024
2024.1129.506 122 5/8/2024
2024.1128.831 138 5/7/2024
2024.1124.465 103 5/3/2024
2024.1123.1162 106 5/2/2024
2024.1123.1117 97 5/2/2024
2024.1123.1050 87 5/2/2024
2024.1122.352 124 5/1/2024
2024.1122.233 124 5/1/2024
2024.1115.1101 126 4/24/2024
2024.1115.1048 112 4/24/2024
2024.1115.932 115 4/24/2024
2024.1115.858 123 4/24/2024
2024.1115.665 124 4/24/2024
2024.1115.648 116 4/24/2024
2024.1115.591 124 4/24/2024
2024.1101.390 122 4/10/2024
2024.1100.741 129 4/9/2024
2024.1099.526 132 4/8/2024
2024.1099.466 125 4/8/2024
2024.1098.573 129 4/7/2024
2024.1095.977 130 4/4/2024
2024.1095.847 125 4/4/2024
2024.1095.604 126 4/4/2024
2024.1095.485 148 4/4/2024
2024.1094.930 124 4/3/2024
2024.1094.910 135 4/3/2024
2024.1094.387 136 4/3/2024
2024.1094.313 124 4/3/2024
2024.1093.520 123 4/2/2024
2024.1092.240 123 4/1/2024
2024.1089.1425 140 3/29/2024
2024.1089.983 128 3/29/2024
2024.1089.942 116 3/29/2024
2024.1089.2 134 3/29/2024
2024.1088.1343 127 3/28/2024
2024.1088.1139 131 3/28/2024
2024.1088.875 101 3/28/2024
2024.1088.700 117 3/28/2024
2024.1088.603 131 3/28/2024
2024.1088.590 135 3/28/2024
2024.1088.575 130 3/28/2024
2024.1088.561 129 3/28/2024
2024.1088.506 132 3/28/2024
2024.1088.18 132 3/28/2024
2024.1087.1181 140 3/27/2024
2024.1087.1173 131 3/27/2024
2024.1087.1143 138 3/27/2024
2024.1087.1108 117 3/27/2024
2024.1087.950 128 3/27/2024
2024.1087.939 115 3/27/2024
2024.1087.252 133 3/27/2024
2024.1070.736 132 3/10/2024
2024.1049.1437 138 2/19/2024
2024.1036.571 138 2/5/2024
2024.1036.508 125 2/5/2024
2024.1032.1204 127 2/1/2024
2024.1032.1133 122 2/1/2024
2024.1032.1122 145 2/1/2024
2024.1032.1071 121 2/1/2024
2024.1032.940 117 2/1/2024
2024.1031.912 118 1/31/2024
2024.1031.893 119 1/31/2024
2024.1031.851 109 1/31/2024
2024.1031.829 115 1/31/2024
2024.1031.386 112 1/31/2024
2024.1031.318 134 1/31/2024
2024.1017.460 141 1/17/2024
2024.1017.420 120 1/17/2024
2024.1017.163 123 1/17/2024
2024.1016.414 649 1/16/2024
2024.1012.167 140 1/12/2024
2024.1011.406 133 1/11/2024
2024.1010.315 147 1/10/2024
2023.1358.326 179 12/24/2023
2023.1351.473 141 12/17/2023
2023.1351.445 143 12/17/2023
2023.1351.432 151 12/17/2023
2023.1350.478 143 12/16/2023
2023.1344.600 158 12/10/2023
2023.1344.529 167 12/10/2023
2023.1339.582 155 12/5/2023
2023.1338.1072 162 12/4/2023
2023.1336.844 154 12/2/2023
2023.1335.378 156 12/1/2023
2023.1335.236 151 12/1/2023
2023.1335.203 135 12/1/2023