Class HumlNamingPolicy

Namespace
Huml.Net.Serialization
Assembly
Huml.Net.dll

Determines the naming policy used to convert a .NET property name to a HUML key during serialisation and deserialisation.

public abstract class HumlNamingPolicy
Inheritance
HumlNamingPolicy
Inherited Members

Remarks

Use KebabCase for HUML documents that use kebab-case keys (the most common HUML convention). When null is used as the policy in HumlOptions.PropertyNamingPolicy, the .NET property name is used as-is (ordinal-exact, PascalCase by default in C#). A HumlPropertyAttribute name override always takes precedence over this policy.

Constructors

HumlNamingPolicy()

Initialises a new instance of HumlNamingPolicy.

protected HumlNamingPolicy()

Properties

CamelCase

Gets the naming policy that converts PascalCase names to camelCase: FullNamefullName.

public static HumlNamingPolicy CamelCase { get; }

Property Value

HumlNamingPolicy

KebabCase

Gets the naming policy that converts PascalCase names to kebab-case: FullNamefull-name.

public static HumlNamingPolicy KebabCase { get; }

Property Value

HumlNamingPolicy

Remarks

Acronyms split letter-by-letter: URLu-r-l. Digits are treated as word boundaries: B2Bb-2-b, Version2Nameversion-2-name. For acronym-aware conversion, use HumlPropertyAttribute directly.

PascalCase

Gets the naming policy that ensures the first character is uppercase: fullNameFullName.

public static HumlNamingPolicy PascalCase { get; }

Property Value

HumlNamingPolicy

SnakeCase

Gets the naming policy that converts PascalCase names to snake_case: FullNamefull_name.

public static HumlNamingPolicy SnakeCase { get; }

Property Value

HumlNamingPolicy

Remarks

Acronyms split letter-by-letter: URLu_r_l. Digits are treated as word boundaries: B2Bb_2_b, Version2Nameversion_2_name.

Methods

ConvertName(string)

When overridden in a derived class, converts the specified .NET property name according to the policy.

public abstract string ConvertName(string name)

Parameters

name string

The .NET property name to convert.

Returns

string

The converted HUML key name.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

Remarks

Two HumlNamingPolicy instances of the same concrete type are considered equal. This ensures that custom stateless policy subclasses stored as separate instances still share a single Huml.Net.Serialization.PropertyDescriptor cache entry rather than producing unbounded cache growth. Override in a derived class if instance identity is required.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.