ALSI.CaseConversions 1.0.0-rc.16

This is a prerelease version of ALSI.CaseConversions.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ALSI.CaseConversions --version 1.0.0-rc.16                
NuGet\Install-Package ALSI.CaseConversions -Version 1.0.0-rc.16                
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="ALSI.CaseConversions" Version="1.0.0-rc.16" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ALSI.CaseConversions --version 1.0.0-rc.16                
#r "nuget: ALSI.CaseConversions, 1.0.0-rc.16"                
#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 ALSI.CaseConversions as a Cake Addin
#addin nuget:?package=ALSI.CaseConversions&version=1.0.0-rc.16&prerelease

// Install ALSI.CaseConversions as a Cake Tool
#tool nuget:?package=ALSI.CaseConversions&version=1.0.0-rc.16&prerelease                

ALSI.CaseConversions

NuGet Version Build Status Downloads codecov

ALSI.CaseConversions is a .NET library that converts various string formats into other cases. It provides robust handling of different casing conventions, separators, and special characters, making it an ideal utility for consistent string formatting in your applications.

Supported Case Conversions

  • PascalCase
  • snake_case
  • camelCase
  • kebab-case
  • dot.case
  • MACRO_CASE

Getting Started

Installation

Install the NuGet package using the .NET CLI:

dotnet add package ALSI.CaseConversions

Or via the NuGet Package Manager:

Install-Package ALSI.CaseConversions

Usage

Basic Example
using ALSI.CaseConversions;

string result = SnakeCase.Converter.Convert("HelloWorld");
// result: "hello_world"
Handling Various String Formats

The converters can handle can handle different types of input formats, using snake_case as an example:

// PascalCase to snake_case
var pascalResult = SnakeCase.Converter.Convert("PascalCaseInput");
// pascalResult: "pascal_case_input"

// camelCase to snake_case
var camelResult = SnakeCase.Converter.Convert("camelCaseInput");
// camelResult: "camel_case_input"

// Hyphen-separated words
var hyphenResult = SnakeCase.Converter.Convert("Hello-World-Example");
// hyphenResult: "hello_world_example"

// Dot-separated words
var dotResult = SnakeCase.Converter.Convert("Hello.World.Example");
// dotResult: "hello_world_example"

// Mixed case with numbers
var mixedResult = SnakeCase.Converter.Convert("File123Name");
// mixedResult: "file123_name"

Supported Conversions

  • PascalCase: "PascalCaseInput""pascal_case_input"
  • camelCase: "camelCaseInput""camel_case_input"
  • Hyphenated Words: "Hello-World-Example""hello_world_example"
  • Dot-Separated Words: "Hello.World.Example""hello_world_example"
  • Whitespace-Separated Words: "Hello World""hello_world"
  • Mixed-Case with Numbers: "File123Name""file123_name"
  • Special Characters: "Hello@world!""helloworld"
  • Consecutive Uppercase Letters: "XMLRequest""xml_request".

Constraints

The conversion is limited by the following:

  • Empty Strings: Returns an empty string.
  • Null Input: Returns an empty string.
  • Fast for small inputs: For inputs ⇐ 128 characters, this is extremely fast, outperforming System.Text.Json. Beyond that, shared array buffers are used to attempt to retain performance improvements.
  • ASCII-only: Converting to snake case is an extended ASCII-only operation, limited to character hex codes 0x00 → 0xFF.

Contributing

We welcome contributions! Feel free to open an issue or submit a pull request on GitHub.

Building Locally

Clone the repository:

git clone https://github.com/alsi-lawr/alsi.caseconversions.git
cd ALSI.CaseConversions

Build the project:

dotnet build

Run tests:

dotnet test
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net8.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
1.0.0 146 8/31/2024
1.0.0-rc.16 48 9/23/2024
0.0.0-rc.8 54 8/31/2024
0.0.0-rc.7 52 8/31/2024