Class NamingSanitizer
Single source of truth for the file-name and C#-identifier sanitization rules the editor asset creators (GameSettingCreator, FeedbackCreator, CutsceneCreator, ModalCreator, ThemeCreator, AudioChannelCreator, and the audio/music batch importers) each duplicated near-identically. Engine-agnostic (pure string logic over GetInvalidFileNameChars()), so it lives in Shared rather than any one Business or Unity module.
Inherited Members
Namespace: Serenity.Shared.Utils
Assembly: Serenity.Shared.dll
Syntax
public static class NamingSanitizer
Methods
FileNameSafe(string, string)
Strips characters that are illegal in file names (replacing each with '_'), so the result is
always a valid asset file name. Trims whitespace first; a null name is treated
as empty. Returns fallback when the sanitized result would be empty.
Declaration
public static string FileNameSafe(string name, string fallback)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The candidate name to sanitize. |
| string | fallback | Value returned when sanitizing |
Returns
| Type | Description |
|---|---|
| string |
ToPascalIdentifier(string, string)
Converts an arbitrary name into a valid PascalCase C# identifier (alphanumeric, letter-led;
non-alphanumeric runs become a capitalization boundary). Returns fallback
(default: empty string) when value is null/blank or yields no identifier
characters.
Declaration
public static string ToPascalIdentifier(string value, string fallback = "")
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The candidate name to convert. |
| string | fallback | Value returned when |
Returns
| Type | Description |
|---|---|
| string |