You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Utils.cs 651 B

12345678910111213141516171819202122232425
  1. using System.Text;
  2. namespace Discord.Net.SourceGenerators.Serialization
  3. {
  4. internal static class Utils
  5. {
  6. private static readonly StringBuilder CaseChangeBuffer = new();
  7. public static string ConvertToSnakeCase(string value)
  8. {
  9. foreach (var c in value)
  10. {
  11. if (char.IsUpper(c) && CaseChangeBuffer.Length > 0)
  12. _ = CaseChangeBuffer.Append('_');
  13. _ = CaseChangeBuffer.Append(char.ToLower(c));
  14. }
  15. var result = CaseChangeBuffer.ToString();
  16. _ = CaseChangeBuffer.Clear();
  17. return result;
  18. }
  19. }
  20. }

No Description