diff --git a/README.md b/README.md index 0d51947..c09cce6 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,8 @@ Defines the behavior that is executed when a defined enum value has no associate |`SnakeCasing`|Returns the enum name as a `snake_cased_string`. Assumes the name is in PascalCase.| |`RawValueToString`|The raw constant value itself is returned by calling `object.ToString()` on the value.| |`EmptyString`|Returns an empty string. This is useful if you want to implement a wrapper around the generated method and handle this case in user code.| +|`ToLowerInvariant`|Returns the enum name lowercased (culture invariant).| +|`ToUpperInvariant`|Returns the enum name uppercased (culture invariant).| diff --git a/src/EnumValues.Core/MissingValueHandling.cs b/src/EnumValues.Core/MissingValueHandling.cs index 17d790a..0244017 100644 --- a/src/EnumValues.Core/MissingValueHandling.cs +++ b/src/EnumValues.Core/MissingValueHandling.cs @@ -18,5 +18,9 @@ public enum MissingValueHandling /// The raw constant value itself is returned by calling on the value. RawValueToString, /// Returns an empty string. This is useful if you want to implement a wrapper around the generated method and handle this case in user code. - EmptyString + EmptyString, + /// Returns the enum name lowercased (culture invariant). + ToLowerInvariant, + /// Returns the enum name uppercased (culture invariant). + ToUpperInvariant } \ No newline at end of file diff --git a/src/EnumValues/Generator/Models/EnumValueCase.cs b/src/EnumValues/Generator/Models/EnumValueCase.cs index 3f505c1..6f7ca29 100644 --- a/src/EnumValues/Generator/Models/EnumValueCase.cs +++ b/src/EnumValues/Generator/Models/EnumValueCase.cs @@ -56,6 +56,8 @@ public static ImmutableArray CreateMany(INamedTypeSymbol enumType { MissingValueHandling.ThrowMissingValueException => null, MissingValueHandling.ToString => symbol.Name, + MissingValueHandling.ToLowerInvariant => symbol.Name.ToLowerInvariant(), + MissingValueHandling.ToUpperInvariant => symbol.Name.ToUpperInvariant(), MissingValueHandling.RawValueToString => symbol.ConstantValue?.ToString() ?? "", MissingValueHandling.EmptyString => "", _ => CodeText.AlterCasing(symbol.Name, missingValueHandling)