Minerals.StringCases 0.2.1

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

// Install Minerals.StringCases as a Cake Tool
#tool nuget:?package=Minerals.StringCases&version=0.2.1                

Minerals.StringCases

Optimized NuGet package with minimum memory allocation designed to help you convert strings to names cases such as Pascal, Camel, Kebab, Snake, Macro, Train and Title.

Features

  • Wide choice of cases: PascalCase, camelCase, _underscoreCamelCase, kebab-case, snake_case, MACRO_CASE, Train-Case, Title Case.
  • Performance: The package is optimized for speed and memory allocation.
  • Universal: Convert from any freely formatted string.
  • Compatible with .NET Standard 2.0: Works on a wide range of platforms and development environments.

Installation

Add the Minerals.StringCases nuget package to your C# project using the following methods:

1. Project file definition

<PackageReference Include="Minerals.StringCases" Version="0.2.1" />

2. dotnet command

dotnet add package Minerals.StringCases

Usage

using Minerals.StringCases;

string sampleText = "  _ example Variable - - Name   321";

string pascalCase = sampleText.ToPascalCase();
// ExampleVariableName321

string camelCase = sampleText.ToCamelCase();
// exampleVariableName321

string underscoreCamelCase = sampleText.ToUnderscoreCamelCase();
// _exampleVariableName321

string kebabCase = sampleText.ToKebabCase();
// example-variable-name-321

string snakeCase = sampleText.ToSnakeCase();
// example_variable_name_321

string macroCase = sampleText.ToMacroCase();
// EXAMPLE_VARIABLE_NAME_321

string trainCase = sampleText.ToTrainCase();
// Example-Variable-Name-321

string titleCase = sampleText.ToTitleCase();
// Example Variable Name 321

Performance and comparison

Here is a comparison of the speed and amount of memory allocation with the most popular NuGet package similar to Minerals.StringCases version 0.2.0 - CaseExtesions version 1.1.0.

String used to perform the comparison:

string sampleText = "  _ example Variable - - Name   321";

Results

BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4412/22H2/2022Update)
AMD Ryzen 5 2600, 1 CPU, 12 logical and 6 physical cores
.NET SDK 8.0.301
  [Host]     : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2
  Job-KUHBVV : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX2

Runtime=.NET 8.0  
Method Mean Error StdDev Gen0 Allocated
PascalCase_Minerals_StringCases 158.4 ns 0.95 ns 0.79 ns 0.0343 144 B
CamelCase_Minerals_StringCases 167.4 ns 1.94 ns 1.72 ns 0.0343 144 B
SnakeCase_Minerals_StringCases 182.4 ns 0.71 ns 0.63 ns 0.0362 152 B
KebabCase_Minerals_StringCases 196.0 ns 1.75 ns 1.55 ns 0.0362 152 B
TrainCase_Minerals_StringCases 206.1 ns 2.62 ns 2.46 ns 0.0362 152 B
- - - - - -
PascalCase_CaseExtensions 505.9 ns 1.83 ns 1.71 ns 0.0973 408 B
KebabCase_CaseExtensions 506.1 ns 1.68 ns 1.49 ns 0.0992 416 B
CamelCase_CaseExtensions 520.6 ns 4.91 ns 4.59 ns 0.0973 408 B
SnakeCase_CaseExtensions 525.1 ns 3.05 ns 2.55 ns 0.0992 416 B
TrainCase_CaseExtensions 527.3 ns 2.47 ns 2.06 ns 0.0992 416 B

Versioning

We use SemVer for versioning. For the versions available, see the branches on this repository.

Authors

  • Szymon Hałucha - Maintainer

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1 1,070 6/10/2024
0.2.0 97 6/10/2024
0.1.0 126 5/15/2024

Fixed bug with last uppercase letter