Redpoint.StringEnum 2025.1083.515

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.1083.515
                    
NuGet\Install-Package Redpoint.StringEnum -Version 2025.1083.515
                    
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.1083.515" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Redpoint.StringEnum" Version="2025.1083.515" />
                    
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.1083.515
                    
#r "nuget: Redpoint.StringEnum, 2025.1083.515"
                    
#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.1083.515
                    
Install Redpoint.StringEnum as a Cake Addin
#tool nuget:?package=Redpoint.StringEnum&version=2025.1083.515
                    
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.1100.365 51 a day ago
2025.1100.336 47 a day ago
2025.1100.331 50 a day ago
2025.1098.108 74 3 days ago
2025.1093.291 158 8 days ago
2025.1091.38 165 10 days ago
2025.1091.26 166 10 days ago
2025.1090.237 154 11 days ago
2025.1089.1386 150 11 days ago
2025.1083.515 394 18 days ago
2025.1083.408 323 18 days ago
2025.1083.398 325 18 days ago
2025.1083.125 323 18 days ago
2025.1080.41 137 21 days ago
2025.1075.357 205 a month ago
2025.1073.332 127 a month ago
2025.1072.541 160 a month ago
2025.1072.536 142 a month ago
2025.1064.602 223 a month ago
2025.1064.546 204 a month ago
2025.1062.589 153 a month ago
2025.1061.513 107 a month ago
2025.1060.490 97 a month ago
2025.1059.134 105 a month ago
2025.1057.1020 99 2 months ago
2025.1056.584 93 2 months ago
2025.1050.282 121 2 months ago
2025.1050.232 109 2 months ago
2025.1049.55 130 2 months ago
2025.1045.285 106 2 months ago
2025.1043.288 98 2 months ago
2025.1043.246 94 2 months ago
2025.1043.197 105 2 months ago
2025.1043.180 92 2 months ago
2025.1043.108 93 2 months ago
2025.1043.38 92 2 months ago
2025.1043.27 91 2 months ago
2025.1042.725 106 2 months ago
2025.1042.690 96 2 months ago
2025.1042.688 102 2 months ago
2025.1042.418 94 2 months ago
2025.1042.215 103 2 months ago
2025.1042.203 103 2 months ago
2025.1042.184 98 2 months ago
2025.1042.142 105 2 months ago
2025.1042.127 101 2 months ago
2025.1037.1327 95 2 months ago
2025.1036.280 104 2 months ago
2025.1036.55 105 2 months ago
2025.1035.1387 115 2 months ago
2025.1031.111 114 2 months ago
2025.1030.916 107 2 months ago
2025.1030.895 108 2 months ago
2025.1030.592 109 2 months ago
2025.1029.664 90 2 months ago
2025.1029.632 87 2 months ago
2025.1029.596 93 2 months ago
2025.1028.386 87 2 months ago
2025.1025.723 89 3 months ago
2025.1025.712 89 3 months ago
2025.1019.913 93 3 months ago
2025.1018.374 95 3 months ago
2025.1018.285 128 3 months ago
2025.1017.646 86 3 months ago
2025.1017.379 120 3 months ago
2025.1016.1370 94 3 months ago
2025.1016.765 90 3 months ago
2025.1016.712 91 3 months ago
2025.1016.550 91 3 months ago
2025.1016.541 93 3 months ago
2025.1016.532 94 3 months ago
2025.1016.325 88 3 months ago
2025.1016.308 90 3 months ago
2025.1016.296 85 3 months ago
2025.1016.237 100 3 months ago
2025.1016.184 85 3 months ago
2025.1016.70 87 3 months ago
2025.1016.6 89 3 months ago
2025.1015.1438 89 3 months ago
2025.1015.1437 86 3 months ago
2025.1015.1411 86 3 months ago
2025.1015.240 57 3 months ago
2025.1015.223 48 3 months ago
2025.1015.183 58 3 months ago
2025.1014.1342 64 3 months ago
2025.1014.273 74 3 months ago
2025.1014.256 78 3 months ago
2025.1012.440 80 3 months ago
2025.1012.327 85 3 months ago
2025.1012.279 85 3 months ago
2025.1002.636 98 3 months ago
2025.1001.1435 100 3 months ago
2025.1001.1397 93 3 months ago
2025.1001.770 102 3 months ago
2025.1001.570 107 3 months ago
2025.1001.558 96 3 months ago
2025.1001.421 100 3 months ago
2025.1001.390 101 3 months ago
2025.1001.234 114 3 months ago
2025.1001.123 107 3 months ago
2024.1360.354 102 4 months ago
2024.1360.60 92 4 months ago
2024.1360.32 91 4 months ago
2024.1358.450 92 4 months ago
2024.1358.359 92 4 months ago
2024.1358.312 89 4 months ago
2024.1358.244 99 4 months ago
2024.1358.120 86 4 months ago
2024.1348.253 106 4 months ago
2024.1345.1379 88 4 months ago
2024.1345.506 86 4 months ago
2024.1345.379 86 4 months ago
2024.1345.145 90 4 months ago
2024.1345.72 88 4 months ago
2024.1345.69 85 4 months ago
2024.1345.15 96 4 months ago
2024.1344.1436 91 4 months ago
2024.1344.600 97 4 months ago
2024.1344.411 99 4 months ago
2024.1340.379 103 4 months ago
2024.1340.15 96 4 months ago
2024.1338.786 103 4 months ago
2024.1338.722 108 4 months ago
2024.1338.697 98 4 months ago
2024.1338.639 101 4 months ago
2024.1338.541 100 4 months ago
2024.1338.318 89 4 months ago
2024.1338.298 92 4 months ago
2024.1338.98 99 4 months ago
2024.1337.756 100 4 months ago
2024.1337.634 105 4 months ago
2024.1337.625 93 4 months ago
2024.1337.621 96 4 months ago
2024.1337.594 95 4 months ago
2024.1337.136 83 4 months ago
2024.1336.793 106 4 months ago
2024.1336.773 105 4 months ago
2024.1336.305 94 4 months ago
2024.1336.12 109 4 months ago
2024.1335.1421 103 4 months ago
2024.1335.1384 101 4 months ago
2024.1334.1308 99 4 months ago
2024.1334.764 94 4 months ago
2024.1334.722 99 4 months ago
2024.1330.185 98 5 months ago
2024.1328.505 105 5 months ago
2024.1328.470 95 5 months ago
2024.1328.452 96 5 months ago
2024.1323.910 109 5 months ago
2024.1323.653 92 5 months ago
2024.1323.185 92 5 months ago
2024.1323.49 90 5 months ago
2024.1322.714 93 5 months ago
2024.1320.653 99 5 months ago
2024.1320.619 93 5 months ago
2024.1320.601 88 5 months ago
2024.1320.159 94 5 months ago
2024.1320.98 95 5 months ago
2024.1320.2 101 5 months ago
2024.1319.1431 98 5 months ago
2024.1319.1335 100 5 months ago
2024.1317.631 101 5 months ago
2024.1316.330 108 5 months ago
2024.1311.540 94 5 months ago
2024.1306.225 99 5 months ago
2024.1306.199 105 5 months ago
2024.1306.171 93 5 months ago
2024.1306.117 107 5 months ago
2024.1305.506 93 5 months ago
2024.1305.502 92 5 months ago
2024.1305.465 94 5 months ago
2024.1305.442 95 5 months ago
2024.1305.399 94 5 months ago
2024.1299.1070 101 6 months ago
2024.1289.621 102 6 months ago
2024.1289.338 98 6 months ago
2024.1277.836 100 6 months ago
2024.1277.711 101 6 months ago
2024.1277.695 98 6 months ago
2024.1270.409 110 7 months ago
2024.1269.621 110 7 months ago
2024.1269.619 101 7 months ago
2024.1269.605 110 7 months ago
2024.1242.282 115 7 months ago
2024.1242.261 113 7 months ago
2024.1242.233 117 7 months ago
2024.1238.829 130 8 months ago
2024.1238.327 134 8 months ago
2024.1225.297 121 8 months ago
2024.1205.140 118 9 months ago
2024.1204.110 120 9 months ago
2024.1204.62 113 9 months ago
2024.1190.491 122 9 months ago
2024.1177.305 118 10 months ago
2024.1168.700 125 10 months ago
2024.1168.649 123 10 months ago
2024.1168.535 128 10 months ago
2024.1167.643 120 10 months ago
2024.1166.989 116 10 months ago
2024.1166.818 117 10 months ago
2024.1166.535 121 10 months ago
2024.1166.422 111 10 months ago
2024.1166.362 116 10 months ago
2024.1166.360 118 10 months ago
2024.1165.1212 116 10 months ago
2024.1165.1160 116 10 months ago
2024.1165.1019 119 10 months ago
2024.1165.978 113 10 months ago
2024.1165.920 112 10 months ago
2024.1165.908 117 10 months ago
2024.1165.873 115 10 months ago
2024.1165.830 115 10 months ago
2024.1165.806 118 10 months ago
2024.1165.794 123 10 months ago
2024.1165.792 119 10 months ago
2024.1165.761 117 10 months ago
2024.1165.743 111 10 months ago
2024.1165.735 117 10 months ago
2024.1165.713 116 10 months ago
2024.1165.640 110 10 months ago
2024.1165.574 117 10 months ago
2024.1165.466 113 10 months ago
2024.1165.417 115 10 months ago
2024.1165.392 112 10 months ago
2024.1164.341 103 10 months ago
2024.1155.941 126 6/3/2024
2024.1140.783 128 5/19/2024
2024.1140.692 115 5/19/2024
2024.1140.673 121 5/19/2024
2024.1129.506 117 5/8/2024
2024.1128.831 134 5/7/2024
2024.1124.465 99 5/3/2024
2024.1123.1162 102 5/2/2024
2024.1123.1117 92 5/2/2024
2024.1123.1050 83 5/2/2024
2024.1122.352 120 5/1/2024
2024.1122.233 120 5/1/2024
2024.1115.1101 122 4/24/2024
2024.1115.1048 107 4/24/2024
2024.1115.932 111 4/24/2024
2024.1115.858 119 4/24/2024
2024.1115.665 120 4/24/2024
2024.1115.648 110 4/24/2024
2024.1115.591 120 4/24/2024
2024.1101.390 118 4/10/2024
2024.1100.741 124 4/9/2024
2024.1099.526 128 4/8/2024
2024.1099.466 121 4/8/2024
2024.1098.573 125 4/7/2024
2024.1095.977 126 4/4/2024
2024.1095.847 121 4/4/2024
2024.1095.604 122 4/4/2024
2024.1095.485 144 4/4/2024
2024.1094.930 120 4/3/2024
2024.1094.910 130 4/3/2024
2024.1094.387 132 4/3/2024
2024.1094.313 120 4/3/2024
2024.1093.520 119 4/2/2024
2024.1092.240 119 4/1/2024
2024.1089.1425 135 3/29/2024
2024.1089.983 123 3/29/2024
2024.1089.942 111 3/29/2024
2024.1089.2 129 3/29/2024
2024.1088.1343 122 3/28/2024
2024.1088.1139 125 3/28/2024
2024.1088.875 96 3/28/2024
2024.1088.700 112 3/28/2024
2024.1088.603 126 3/28/2024
2024.1088.590 130 3/28/2024
2024.1088.575 125 3/28/2024
2024.1088.561 123 3/28/2024
2024.1088.506 127 3/28/2024
2024.1088.18 127 3/28/2024
2024.1087.1181 135 3/27/2024
2024.1087.1173 126 3/27/2024
2024.1087.1143 133 3/27/2024
2024.1087.1108 112 3/27/2024
2024.1087.950 123 3/27/2024
2024.1087.939 110 3/27/2024
2024.1087.252 128 3/27/2024
2024.1070.736 127 3/10/2024
2024.1049.1437 134 2/19/2024
2024.1036.571 134 2/5/2024
2024.1036.508 121 2/5/2024
2024.1032.1204 122 2/1/2024
2024.1032.1133 118 2/1/2024
2024.1032.1122 140 2/1/2024
2024.1032.1071 117 2/1/2024
2024.1032.940 113 2/1/2024
2024.1031.912 114 1/31/2024
2024.1031.893 115 1/31/2024
2024.1031.851 104 1/31/2024
2024.1031.829 111 1/31/2024
2024.1031.386 108 1/31/2024
2024.1031.318 130 1/31/2024
2024.1017.460 136 1/17/2024
2024.1017.420 115 1/17/2024
2024.1017.163 119 1/17/2024
2024.1016.414 644 1/16/2024
2024.1012.167 136 1/12/2024
2024.1011.406 129 1/11/2024
2024.1010.315 143 1/10/2024
2023.1358.326 174 12/24/2023
2023.1351.473 137 12/17/2023
2023.1351.445 139 12/17/2023
2023.1351.432 147 12/17/2023
2023.1350.478 138 12/16/2023
2023.1344.600 154 12/10/2023
2023.1344.529 163 12/10/2023
2023.1339.582 150 12/5/2023
2023.1338.1072 158 12/4/2023
2023.1336.844 149 12/2/2023
2023.1335.378 152 12/1/2023
2023.1335.236 146 12/1/2023
2023.1335.203 131 12/1/2023