Skip to content

Instantly share code, notes, and snippets.

View occluder's full-sized avatar
🍯
There is no honey

Elias A. occluder

🍯
There is no honey
View GitHub Profile
@occluder
occluder / SnakeCaseNamingPolicy.cs
Created October 19, 2023 17:58
Snake case naming policy for C# 's System.Text.Json.JsonSerializer
public class SnakeCaseNamingPolicy : JsonNamingPolicy
{
public override string ConvertName(string name)
{
const char underscore = '_';
ReadOnlySpan<char> chars = name;
Span<char> replacement = stackalloc char[chars.Length * 2];
int i = 1;
int offset = 0;