StringUtils.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Linq; 6 7 namespace WorkspacesEditor.Utils 8 { 9 public static class StringUtils 10 { 11 public static string UpperCamelCaseToDashCase(this string str) 12 { 13 // If it's a single letter variable, leave it as it is 14 return str.Length == 1 15 ? str 16 : string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "-" + x.ToString() : x.ToString())).ToLowerInvariant(); 17 } 18 } 19 }