Redpoint.StringEnum 2025.1014.1342

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.1014.1342                
NuGet\Install-Package Redpoint.StringEnum -Version 2025.1014.1342                
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.1014.1342" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Redpoint.StringEnum --version 2025.1014.1342                
#r "nuget: Redpoint.StringEnum, 2025.1014.1342"                
#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.
// Install Redpoint.StringEnum as a Cake Addin
#addin nuget:?package=Redpoint.StringEnum&version=2025.1014.1342

// Install Redpoint.StringEnum as a Cake Tool
#tool nuget:?package=Redpoint.StringEnum&version=2025.1014.1342                

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 net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.
  • net8.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.1019.913 40 2 days ago
2025.1018.374 31 4 days ago
2025.1018.285 28 4 days ago
2025.1017.646 35 4 days ago
2025.1017.379 39 5 days ago
2025.1016.1370 38 5 days ago
2025.1016.765 37 5 days ago
2025.1016.712 37 5 days ago
2025.1016.550 38 6 days ago
2025.1016.541 37 6 days ago
2025.1016.532 40 6 days ago
2025.1016.325 33 6 days ago
2025.1016.308 35 6 days ago
2025.1016.296 32 6 days ago
2025.1016.237 37 6 days ago
2025.1016.184 32 6 days ago
2025.1016.70 33 6 days ago
2025.1016.6 34 6 days ago
2025.1015.1438 37 6 days ago
2025.1015.1437 37 6 days ago
2025.1015.1411 33 6 days ago
2025.1015.240 42 7 days ago
2025.1015.223 35 7 days ago
2025.1015.183 43 7 days ago
2025.1014.1342 34 7 days ago
2025.1014.273 50 8 days ago
2025.1014.256 49 8 days ago
2025.1012.440 58 10 days ago
2025.1012.327 62 10 days ago
2025.1012.279 63 10 days ago
2025.1002.636 81 19 days ago
2025.1001.1435 82 20 days ago
2025.1001.1397 78 20 days ago
2025.1001.770 87 20 days ago
2025.1001.570 92 20 days ago
2025.1001.558 82 20 days ago
2025.1001.421 84 21 days ago
2025.1001.390 85 21 days ago
2025.1001.234 98 21 days ago
2025.1001.123 91 21 days ago
2024.1360.354 83 a month ago
2024.1360.60 78 a month ago
2024.1360.32 77 a month ago
2024.1358.450 78 a month ago
2024.1358.359 79 a month ago
2024.1358.312 74 a month ago
2024.1358.244 85 a month ago
2024.1358.120 71 a month ago
2024.1348.253 88 a month ago
2024.1345.1379 75 a month ago
2024.1345.506 73 a month ago
2024.1345.379 72 a month ago
2024.1345.145 78 a month ago
2024.1345.72 75 a month ago
2024.1345.69 71 a month ago
2024.1345.15 83 a month ago
2024.1344.1436 78 a month ago
2024.1344.600 84 a month ago
2024.1344.411 84 a month ago
2024.1340.379 92 2 months ago
2024.1340.15 83 2 months ago
2024.1338.786 92 2 months ago
2024.1338.722 97 2 months ago
2024.1338.697 87 2 months ago
2024.1338.639 90 2 months ago
2024.1338.541 88 2 months ago
2024.1338.318 77 2 months ago
2024.1338.298 80 2 months ago
2024.1338.98 82 2 months ago
2024.1337.756 89 2 months ago
2024.1337.634 94 2 months ago
2024.1337.625 82 2 months ago
2024.1337.621 85 2 months ago
2024.1337.594 84 2 months ago
2024.1337.136 73 2 months ago
2024.1336.793 95 2 months ago
2024.1336.773 94 2 months ago
2024.1336.305 84 2 months ago
2024.1336.12 99 2 months ago
2024.1335.1421 93 2 months ago
2024.1335.1384 90 2 months ago
2024.1334.1308 88 2 months ago
2024.1334.764 82 2 months ago
2024.1334.722 89 2 months ago
2024.1330.185 88 2 months ago
2024.1328.505 94 2 months ago
2024.1328.470 85 2 months ago
2024.1328.452 85 2 months ago
2024.1323.910 99 2 months ago
2024.1323.653 83 2 months ago
2024.1323.185 83 2 months ago
2024.1323.49 80 2 months ago
2024.1322.714 83 2 months ago
2024.1320.653 90 2 months ago
2024.1320.619 83 2 months ago
2024.1320.601 77 2 months ago
2024.1320.159 85 2 months ago
2024.1320.98 85 2 months ago
2024.1320.2 92 2 months ago
2024.1319.1431 87 2 months ago
2024.1319.1335 90 2 months ago
2024.1317.631 91 2 months ago
2024.1316.330 99 2 months ago
2024.1311.540 85 3 months ago
2024.1306.225 87 3 months ago
2024.1306.199 94 3 months ago
2024.1306.171 82 3 months ago
2024.1306.117 95 3 months ago
2024.1305.506 82 3 months ago
2024.1305.502 80 3 months ago
2024.1305.465 83 3 months ago
2024.1305.442 83 3 months ago
2024.1305.399 82 3 months ago
2024.1299.1070 92 3 months ago
2024.1289.621 91 3 months ago
2024.1289.338 90 3 months ago
2024.1277.836 92 4 months ago
2024.1277.711 93 4 months ago
2024.1277.695 89 4 months ago
2024.1270.409 99 4 months ago
2024.1269.621 102 4 months ago
2024.1269.619 91 4 months ago
2024.1269.605 101 4 months ago
2024.1242.282 108 5 months ago
2024.1242.261 106 5 months ago
2024.1242.233 110 5 months ago
2024.1238.829 123 5 months ago
2024.1238.327 127 5 months ago
2024.1225.297 115 5 months ago
2024.1205.140 112 6 months ago
2024.1204.110 109 6 months ago
2024.1204.62 104 6 months ago
2024.1190.491 116 6 months ago
2024.1177.305 111 7 months ago
2024.1168.700 118 7 months ago
2024.1168.649 117 7 months ago
2024.1168.535 123 7 months ago
2024.1167.643 115 7 months ago
2024.1166.989 109 7 months ago
2024.1166.818 113 7 months ago
2024.1166.535 117 7 months ago
2024.1166.422 105 7 months ago
2024.1166.362 112 7 months ago
2024.1166.360 114 7 months ago
2024.1165.1212 111 7 months ago
2024.1165.1160 111 7 months ago
2024.1165.1019 112 7 months ago
2024.1165.978 108 7 months ago
2024.1165.920 108 7 months ago
2024.1165.908 110 7 months ago
2024.1165.873 111 7 months ago
2024.1165.830 111 7 months ago
2024.1165.806 113 7 months ago
2024.1165.794 112 7 months ago
2024.1165.792 114 7 months ago
2024.1165.761 112 7 months ago
2024.1165.743 107 7 months ago
2024.1165.735 113 7 months ago
2024.1165.713 112 7 months ago
2024.1165.640 106 7 months ago
2024.1165.574 112 7 months ago
2024.1165.466 109 7 months ago
2024.1165.417 110 7 months ago
2024.1165.392 108 7 months ago
2024.1164.341 99 7 months ago
2024.1155.941 121 8 months ago
2024.1140.783 123 8 months ago
2024.1140.692 111 8 months ago
2024.1140.673 116 8 months ago
2024.1129.506 112 8 months ago
2024.1128.831 130 8 months ago
2024.1124.465 92 9 months ago
2024.1123.1162 91 9 months ago
2024.1123.1117 83 9 months ago
2024.1123.1050 76 9 months ago
2024.1122.352 114 9 months ago
2024.1122.233 113 9 months ago
2024.1115.1101 118 9 months ago
2024.1115.1048 103 9 months ago
2024.1115.932 102 9 months ago
2024.1115.858 113 9 months ago
2024.1115.665 114 9 months ago
2024.1115.648 106 9 months ago
2024.1115.591 113 9 months ago
2024.1101.390 112 9 months ago
2024.1100.741 118 9 months ago
2024.1099.526 124 9 months ago
2024.1099.466 116 9 months ago
2024.1098.573 121 9 months ago
2024.1095.977 121 10 months ago
2024.1095.847 116 10 months ago
2024.1095.604 115 10 months ago
2024.1095.485 134 10 months ago
2024.1094.930 116 10 months ago
2024.1094.910 126 10 months ago
2024.1094.387 128 10 months ago
2024.1094.313 116 10 months ago
2024.1093.520 114 10 months ago
2024.1092.240 114 10 months ago
2024.1089.1425 131 10 months ago
2024.1089.983 119 10 months ago
2024.1089.942 106 10 months ago
2024.1089.2 124 10 months ago
2024.1088.1343 117 10 months ago
2024.1088.1139 120 10 months ago
2024.1088.875 92 10 months ago
2024.1088.700 108 10 months ago
2024.1088.603 122 10 months ago
2024.1088.590 125 10 months ago
2024.1088.575 120 10 months ago
2024.1088.561 119 10 months ago
2024.1088.506 123 10 months ago
2024.1088.18 123 10 months ago
2024.1087.1181 130 10 months ago
2024.1087.1173 121 10 months ago
2024.1087.1143 128 10 months ago
2024.1087.1108 108 10 months ago
2024.1087.950 118 10 months ago
2024.1087.939 105 10 months ago
2024.1087.252 123 10 months ago
2024.1070.736 122 3/10/2024
2024.1049.1437 125 2/19/2024
2024.1036.571 130 2/5/2024
2024.1036.508 116 2/5/2024
2024.1032.1204 118 2/1/2024
2024.1032.1133 113 2/1/2024
2024.1032.1122 135 2/1/2024
2024.1032.1071 112 2/1/2024
2024.1032.940 108 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 110 1/17/2024
2024.1017.163 115 1/17/2024
2024.1016.414 579 1/16/2024
2024.1012.167 125 1/12/2024
2024.1011.406 124 1/11/2024
2024.1010.315 139 1/10/2024
2023.1358.326 170 12/24/2023
2023.1351.473 130 12/17/2023
2023.1351.445 133 12/17/2023
2023.1351.432 134 12/17/2023
2023.1350.478 133 12/16/2023
2023.1344.600 149 12/10/2023
2023.1344.529 152 12/10/2023
2023.1339.582 145 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 141 12/1/2023
2023.1335.203 127 12/1/2023