private static bool TryGetChangedName(string identifierName, BaseTypeDeclarationSyntax typeDeclaration, bool isUnderscoreAccepted, out string suggestion) { var suggestionPrefix = typeDeclaration is InterfaceDeclarationSyntax ? "I" : string.Empty; var namesToCheck = identifierName.Split(new[] { "_" }, StringSplitOptions.None); if (LeadingIShouldBeIgnored(namesToCheck[0], typeDeclaration)) { namesToCheck[0] = namesToCheck[0].Substring(1); } var suggestedNames = namesToCheck.Select(s => CamelCaseConverter.Convert(s)); if (isUnderscoreAccepted) { suggestion = string.Join("_", suggestedNames); } else { var concatenated = string.Join(string.Empty, suggestedNames); // do a second path, to suggest a real camel case string. A_B_C -> ABC -> Abc suggestion = CamelCaseConverter.Convert(concatenated); } suggestion = suggestionPrefix + suggestion; return(identifierName != suggestion); }
private static bool TryGetChangedName(string identifierName, out string suggestion) { if (identifierName.Contains('_')) { suggestion = null; return(false); } suggestion = CamelCaseConverter.Convert(identifierName); return(identifierName != suggestion); }
public void Return_the_original_string_if_first_letter_is_lower_case(string input, string expectedResult) { _sut.Convert(input).Should().Be(expectedResult); }