public static IWordsConverter Create(Configuration.WordsConverter wordsConverter) { IWordsConverter converter = default; switch (wordsConverter.Type) { case "Camel": { converter = new CamelCaseConverter(); break; } case "Pascal": { converter = new PascalCaseConverter(); break; } case "Delimiter": { converter = new DelimiterConverter(); break; } default: { return(new NoneConverter()); } } converter.Initialize(wordsConverter.Parameters); return(converter); }
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 UseCamelCase() { CaseConverter = new CamelCaseConverter(); }
public void TestMethod1() { Assert.AreEqual("building", CamelCaseConverter.ToCamelCaseWrong("BUILDING")); }
public void TestMethod4() { Assert.AreEqual("buildinG PROPERTY", CamelCaseConverter.ToCamelCaseWrong("BUILDING PROPERTY")); }
public void TestMethod3() { Assert.AreEqual("building Property", CamelCaseConverter.ToCamelCaseWrong("Building Property")); }
public void TestMethod2() { Assert.AreEqual("buildinG Property", CamelCaseConverter.ToCamelCaseWrong("BUILDING Property")); }