From 3fd2c506025ea26aa7bac10286c3f4c3e5c87158 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Mon, 22 Jan 2024 09:05:29 +0000 Subject: [PATCH] Keep leading underscores in generated identifiers --- Bonsai.Sgen/CSharpNamingConvention.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Bonsai.Sgen/CSharpNamingConvention.cs b/Bonsai.Sgen/CSharpNamingConvention.cs index 3c2e884..53f1d18 100644 --- a/Bonsai.Sgen/CSharpNamingConvention.cs +++ b/Bonsai.Sgen/CSharpNamingConvention.cs @@ -13,7 +13,9 @@ private CSharpNamingConvention() public string Apply(string value) { - return PascalCaseNamingConvention.Instance.Apply(value).Replace("_", string.Empty); + var result = PascalCaseNamingConvention.Instance.Apply(value); + var prefix = result.StartsWith('_') ? "_" : string.Empty; + return prefix + result.Replace("_", string.Empty); } } }