alsi-lawr / alsi.caseconversions

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.
MIT License
2 stars 1 forks source link
csharp dotnet nuget nuget-package open-source

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

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

The primary method exposed by ALSI.CaseConversions is ToSnakeCase, a static method that converts strings into snake_case format.

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

Constraints

The conversion is limited by the following:

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