예제 #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));
        }
예제 #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);
        }
예제 #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) });
        }
예제 #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);
        }
예제 #5
0
 public string Creates_correct_plural_name_(string singularName) => Pluralizer.GetPluralName(singularName);
예제 #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));
        }