Extension methods for string manipulation commonly needed in source generators.
Line Splitting
Zero-allocation line enumeration using ref structs:
LineSplitEnumerator is a ref struct that handles \n, \r, and \r\n line
endings correctly without heap allocations.
Convert between naming conventions with C# keyword handling:
All C# reserved keywords are automatically prefixed with @ to ensure valid identifiers.
Whitespace Normalization
Clean up generated code whitespace:
Identifier Sanitization
Create valid C# identifiers:
Type Name Utilities
Work with fully-qualified type names:
C# Keyword Aliases
Map between BCL type names and C# keywords:
Supported keywords: int, long, short, byte, sbyte, uint, ulong, ushort, float, double, decimal, bool, string, char, object, void
Type Classification
Quick type checks:
Prefix/Suffix Stripping
Remove prefixes or suffixes from strings:
Examples
Generate Property from Field
Clean Generated Output
Route Parameter Type Matching
Process Code Line-by-Line