public string SanitizeIdentifier(string name) { var sb = new StringBuilder(); var characterEnum = StringInfo.GetTextElementEnumerator(name); while (characterEnum.MoveNext()) { string c = characterEnum.GetTextElement(); int i = characterEnum.ElementIndex; var cat = CharUnicodeInfo.GetUnicodeCategory(name, i); if (IsValidIdentifier(i, cat) && !IsHighUnicode(c)) { sb.Append(i == 0 && cat == UnicodeCategory.LowercaseLetter ? c.ToUpper() : c); } else { sb.Append(unicodeMapper.MapToUnicodeName(c)); } } if (CSKeywords.IsKeyword(sb.ToString())) { sb.Append('_'); } return(sb.ToString()); }
static NetParam Uniquify(NetParam p, List <NetParam> pl, int startPoint) { while (!IsUnique(p, pl, startPoint) || CSKeywords.IsKeyword(p.Name)) { p = new NetParam(p.Name + '0', p.Type); } return(p); }