Example #1
0
        private static string GetPluralName(string originalName, out string name)
        {
            name = originalName.EndsWithNumber() ? originalName.WithoutNumberSuffix() : originalName;

            if (name.EndsWithAny(Constants.Markers.Collections))
            {
                return(Pluralizer.GetPluralName(name, StringComparison.OrdinalIgnoreCase, Constants.Markers.Collections));
            }

            return(Pluralizer.GetPluralName(name));
        }
Example #2
0
        protected static string FindBetterNameForEntityMarker(ISymbol symbol)
        {
            var expected = HandleSpecialEntityMarkerSituations(symbol.Name);

            if (expected.HasCollectionMarker())
            {
                var plural = Pluralizer.GetPluralName(expected, StringComparison.OrdinalIgnoreCase, Constants.Markers.Collections);

                // symbol may have both Entity and Collection marker, such as 'ModelCollection', so 'plural' may be null
                expected = plural ?? (symbol.Name[0].IsUpperCase() ? Constants.Entities : Constants.entities);
            }

            return(expected);
        }
Example #3
0
        protected override IEnumerable <Diagnostic> AnalyzeNamespaceName(string qualifiedName, Location location)
        {
            var name = qualifiedName.GetNameOnlyPart();

            // maybe it's a number, so we have to check for that
            if (name.EndsWithNumber() || name.EndsWithAny(AllowedSuffixes))
            {
                return(Enumerable.Empty <Diagnostic>());
            }

            var pluralName = Pluralizer.GetPluralName(name);

            return(new[] { Issue(qualifiedName, location, pluralName) });
        }
Example #4
0
        internal static string FindBetterName(ITypeSymbol symbol)
        {
            var symbolName = symbol.Name;

            var betterName = symbolName
                             .Replace("TypeEnum", "Kind")
                             .Without(WrongNames);

            if (betterName.IsNullOrWhiteSpace() is false)
            {
                if (symbol.IsEnum() && symbol.GetAttributeNames().Any(_ => _ == nameof(FlagsAttribute)) &&
                    betterName.EndsWith("s", StringComparison.OrdinalIgnoreCase) is false)
                {
                    betterName = Pluralizer.GetPluralName(symbolName, betterName);
                }
            }

            return(betterName);
        }
 public string Creates_correct_plural_name_(string singularName) => Pluralizer.GetPluralName(singularName);
Example #6
0
        protected Diagnostic AnalyzeCollectionSuffix(ISymbol symbol, string suffix, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
        {
            var betterName = Pluralizer.GetPluralName(symbol.Name, comparison, suffix);

            return(betterName.IsNullOrWhiteSpace() ? null : Issue(symbol, betterName));
        }