![]() |
VOOZH | about |
dotnet add package CaseConverter --version 2.0.1
NuGet\Install-Package CaseConverter -Version 2.0.1
<PackageReference Include="CaseConverter" Version="2.0.1" />
<PackageVersion Include="CaseConverter" Version="2.0.1" />Directory.Packages.props
<PackageReference Include="CaseConverter" />Project file
paket add CaseConverter --version 2.0.1
#r "nuget: CaseConverter, 2.0.1"
#:package CaseConverter@2.0.1
#addin nuget:?package=CaseConverter&version=2.0.1Install as a Cake Addin
#tool nuget:?package=CaseConverter&version=2.0.1Install as a Cake Tool
โNaming Conventions is one of the two hard things in Computer Scienceโ --- Jeff Atwood (Stack Overflow Co-founder).
This library is designed to make it easier to convert the different case conventions in c# / .net through some simple to use string extension methods.
Simple string extension library designed to make it easy to convert strings between different cases such as camelCase, snake_case, kebab-case, PascalCase, Train-Case and Title Case.
This is a .NET STANDARD 2.0 and .NET STANDARD 2.1 Library
NuGet:
Install-Package CaseConverter
dotnet CLI
dotnet add package CaseConverter
using CaseConverter;
Console.WriteLine("Hello World!".ToCamelCase());
Console.WriteLine("Hello World!".ToSnakeCase());
Console.WriteLine("Hello World!".ToKebabCase());
Console.WriteLine("Hello World!".ToPascalCase());
Console.WriteLine("Hello World!".ToTitleCase());
Console.WriteLine("Hello World!".ToTrainCase());
String extensions:
Supplementary string extensions included:
We added a lot more tests in the latest version.
To run tests:
dotnet test
For the latest version we're working on improving performance and memory efficiency.. here is a comparison of the improvements.
Additional gains will likely be possible if also target .net 6+. So far we've only done that with ToTitleCase() but we'll update the other methods soon.
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---|---|---|---|---|---|
| ToPascalCaseBenchmark | 179.9 ns | 3.00 ns | 2.34 ns | 0.0315 | 264 B |
| ToPascalCaseBenchmarkOld | 2,269.5 ns | 43.25 ns | 36.12 ns | 0.4005 | 3352 B |
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---|---|---|---|---|---|
| ToKebabCaseBenchmark | 132.1 ns | 2.69 ns | 4.02 ns | 0.0324 | 272 B |
| ToKebabCaseBenchmarkOld | 1,423.1 ns | 27.69 ns | 27.19 ns | 0.0496 | 424 B |
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---|---|---|---|---|---|
| ToTitleCaseBenchmark | 218.3 ns | 2.59 ns | 2.43 ns | 0.0200 | 168 B |
| ToTitleCaseBenchmarkOld | 225.8 ns | 3.26 ns | 3.05 ns | 0.0381 | 320 B |
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---|---|---|---|---|---|
| ToCamelCaseBenchmark | 1.497 us | 0.0206 us | 0.0193 us | 0.1659 | 1.36 KB |
| ToCamelCaseOldBenchmark | 5.362 us | 0.0730 us | 0.0609 us | 0.4272 | 3.52 KB |
Wasn't able to improve it so left the original code intact.
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---|---|---|---|---|---|
| ToSnakeCaseBenchmark | 1.765 us | 0.0112 us | 0.0094 us | 0.1793 | 1.47 KB |
| Method | Job | Runtime | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|---|---|---|
| ToSnakeCaseBenchmark | .NET 5.0 | .NET 5.0 | 199.257 ns | 3.8065 ns | 3.9090 ns | 0.95 | 0.02 | 0.0343 | 288 B | 1.00 |
| ToSnakeCaseBenchmark | .NET 6.0 | .NET 6.0 | 177.983 ns | 3.4400 ns | 3.6807 ns | 0.84 | 0.02 | 0.0343 | 288 B | 1.00 |
| ToSnakeCaseBenchmark | .NET 7.0 | .NET 7.0 | 164.851 ns | 1.4823 ns | 1.3140 ns | 0.78 | 0.01 | 0.0343 | 288 B | 1.00 |
| ToSnakeCaseBenchmark | .NET Core 3.1 | .NET Core 3.1 | 211.328 ns | 2.4708 ns | 2.0633 ns | 1.00 | 0.00 | 0.0343 | 288 B | 1.00 |
| ToCamelCaseBenchmark | .NET 5.0 | .NET 5.0 | 115.336 ns | 2.3167 ns | 2.2753 ns | 0.77 | 0.05 | 0.0200 | 168 B | 1.00 |
| ToCamelCaseBenchmark | .NET 6.0 | .NET 6.0 | 82.941 ns | 1.4910 ns | 1.3946 ns | 0.56 | 0.03 | 0.0200 | 168 B | 1.00 |
| ToCamelCaseBenchmark | .NET 7.0 | .NET 7.0 | 86.708 ns | 1.3273 ns | 1.0363 ns | 0.58 | 0.03 | 0.0200 | 168 B | 1.00 |
| ToCamelCaseBenchmark | .NET Core 3.1 | .NET Core 3.1 | 156.865 ns | 3.6809 ns | 10.8532 ns | 1.00 | 0.00 | 0.0200 | 168 B | 1.00 |
| ToKebabCaseBenchmark | .NET 5.0 | .NET 5.0 | 188.836 ns | 2.3753 ns | 2.1056 ns | 0.89 | 0.03 | 0.0324 | 272 B | 1.00 |
| ToKebabCaseBenchmark | .NET 6.0 | .NET 6.0 | 129.301 ns | 1.7678 ns | 1.5671 ns | 0.61 | 0.02 | 0.0324 | 272 B | 1.00 |
| ToKebabCaseBenchmark | .NET 7.0 | .NET 7.0 | 127.751 ns | 2.3711 ns | 2.2179 ns | 0.60 | 0.02 | 0.0324 | 272 B | 1.00 |
| ToKebabCaseBenchmark | .NET Core 3.1 | .NET Core 3.1 | 210.257 ns | 4.2073 ns | 6.0339 ns | 1.00 | 0.00 | 0.0324 | 272 B | 1.00 |
| ToPascalCaseBenchmark | .NET 5.0 | .NET 5.0 | 278.123 ns | 3.2519 ns | 3.0418 ns | 0.85 | 0.02 | 0.0315 | 264 B | 1.00 |
| ToPascalCaseBenchmark | .NET 6.0 | .NET 6.0 | 189.604 ns | 2.2500 ns | 1.9945 ns | 0.58 | 0.02 | 0.0315 | 264 B | 1.00 |
| ToPascalCaseBenchmark | .NET 7.0 | .NET 7.0 | 170.063 ns | 2.5240 ns | 2.1076 ns | 0.52 | 0.01 | 0.0315 | 264 B | 1.00 |
| ToPascalCaseBenchmark | .NET Core 3.1 | .NET Core 3.1 | 324.897 ns | 6.4022 ns | 8.0968 ns | 1.00 | 0.00 | 0.0315 | 264 B | 1.00 |
| ToTitleCaseBenchmark | .NET 5.0 | .NET 5.0 | 281.820 ns | 5.5559 ns | 4.6395 ns | 0.90 | 0.02 | 0.0200 | 168 B | 1.00 |
| ToTitleCaseBenchmark | .NET 6.0 | .NET 6.0 | 506.287 ns | 8.0127 ns | 8.9061 ns | 1.62 | 0.05 | 0.1211 | 1016 B | 6.05 |
| ToTitleCaseBenchmark | .NET 7.0 | .NET 7.0 | 485.576 ns | 8.4432 ns | 8.6705 ns | 1.54 | 0.04 | 0.1211 | 1016 B | 6.05 |
| ToTitleCaseBenchmark | .NET Core 3.1 | .NET Core 3.1 | 314.564 ns | 4.8291 ns | 4.0325 ns | 1.00 | 0.00 | 0.0200 | 168 B | 1.00 |
| ToTrainCaseBenchmark | .NET 5.0 | .NET 5.0 | 488.572 ns | 9.3516 ns | 8.7475 ns | 0.90 | 0.02 | 0.0639 | 536 B | 1.00 |
| ToTrainCaseBenchmark | .NET 6.0 | .NET 6.0 | 343.272 ns | 4.4961 ns | 4.2056 ns | 0.63 | 0.02 | 0.0639 | 536 B | 1.00 |
| ToTrainCaseBenchmark | .NET 7.0 | .NET 7.0 | 302.115 ns | 5.8996 ns | 6.5574 ns | 0.56 | 0.02 | 0.0639 | 536 B | 1.00 |
| ToTrainCaseBenchmark | .NET Core 3.1 | .NET Core 3.1 | 542.426 ns | 10.8240 ns | 10.6306 ns | 1.00 | 0.00 | 0.0639 | 536 B | 1.00 |
| IsAllUpperBenchmark | .NET 5.0 | .NET 5.0 | 6.971 ns | 0.1332 ns | 0.1480 ns | 0.74 | 0.02 | - | - | NA |
| IsAllUpperBenchmark | .NET 6.0 | .NET 6.0 | 5.091 ns | 0.1288 ns | 0.1533 ns | 0.54 | 0.02 | - | - | NA |
| IsAllUpperBenchmark | .NET 7.0 | .NET 7.0 | 4.166 ns | 0.0988 ns | 0.1057 ns | 0.44 | 0.01 | - | - | NA |
| IsAllUpperBenchmark | .NET Core 3.1 | .NET Core 3.1 | 9.476 ns | 0.0494 ns | 0.0385 ns | 1.00 | 0.00 | - | - | NA |
| ReplaceWhitespaceBenchmark | .NET 5.0 | .NET 5.0 | 7,583.997 ns | 132.7825 ns | 124.2049 ns | 0.40 | 0.01 | 0.0839 | 728 B | 0.06 |
| ReplaceWhitespaceBenchmark | .NET 6.0 | .NET 6.0 | 7,196.590 ns | 125.6170 ns | 117.5022 ns | 0.38 | 0.01 | 0.0839 | 728 B | 0.06 |
| ReplaceWhitespaceBenchmark | .NET 7.0 | .NET 7.0 | 7,353.717 ns | 144.7446 ns | 148.6420 ns | 0.39 | 0.02 | 0.0839 | 728 B | 0.06 |
| ReplaceWhitespaceBenchmark | .NET Core 3.1 | .NET Core 3.1 | 18,699.030 ns | 362.7740 ns | 542.9830 ns | 1.00 | 0.00 | 1.4343 | 12168 B | 1.00 |
If you can suggest further improvements please get in touch or better still make the improvements and send us a PR ๐
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-featureThe MIT License (MIT) See LICENCE file for Licence (MIT Licence)
ยฉ 2021-2023 Captive Reality Ltd. All Rights Reserved. Author: Mark Castle
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on CaseConverter:
| Package | Downloads |
|---|---|
|
ThunderPropagator.BuildingBlocks
ThunderPropagator (Project ARC): High-performance data propagation; effortless, blazingly fast and cloud-native for maximum impact |
|
|
Envy
An environment variable loading utility inspired by the Rust crate of the same name. |
|
|
Spiderly.Shared
Spiderly.Shared package provides shared features that can be used by all other Spiderly packages. |
|
|
ThunderPropagator.BuildingBlocks.Debug
ThunderPropagator (Project ARC): High-performance data propagation; effortless, blazingly fast and cloud-native for maximum impact |
|
|
ThunderPropagator.BuildingBlocks.Debug.x86
ThunderPropagator (Project ARC): High-performance data propagation; effortless, blazingly fast and cloud-native for maximum impact |
Showing the top 3 popular GitHub repositories that depend on CaseConverter:
| Repository | Stars |
|---|---|
| LANCommander/LANCommander | |
|
minhsangdotcom/clean-architecture
Clean Architecture template for .NET ๐
|
|
|
drasticactions/FishyFlip
Fishyflip - a .NET ATProtocol/Bluesky Library
|