Skip to content
This repository has been archived by the owner on Oct 27, 2018. It is now read-only.
/ CamelCaser Public archive

A .NET micro-library for converting "PascalCase" names to "camelCase".

License

Notifications You must be signed in to change notification settings

stakx/CamelCaser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CamelCaser

A small .NET library for converting identifiers to "camelCase".

AppVeyor AppVeyor tests

partial interface ICamelCaser { }

nameof(ICamelCaser).ToLowerCamelCase();
// => "camelCaser"

What could this be useful for?

The main purpose behind this library is to be able to automatically derive suitable variable names from type names e.g. in Reflection-based tools. The usual .NET conventions state that variable names should be in "camelCase", while type names should be in "PascalCase".

While this conversion is a no-brainer for humans, it's actually made more complicated than one might realise at first by several .NET naming conventions:

  • For interface types whose name starts with an I, that I should be dropped: IFruitPickerfruitPicker (not iFruitPicker!)

  • When there are several initial upper-case characters, all but the last of them should be lower-cased: IDESettingsideSettings (not idesettings, nor idesEttings!)

  • … but not if all characters are in upper-case: IDEide (not idE!)

This library takes care of that transformation, so that you don't have to.

How do I use it?

By importing the CamelCaser namespace, the following extension method becomes available:

  • string.ToLowerCamelCase():
    Converts the original string to "camelCase" according to the rules shown above.

But it doesn't lower-case <some string> correctly!

If you think you've found a bug, please raise an issue so it can be looked into. (Make sure to mention the string that doesn't get formatted as expected, along with your expectation of how it should have been formatted.)

Releases

No releases published

Packages

No packages published

Languages