private static bool AssignMethodNameUsingUniqueParameter(IEnumerable <string> parameterNames, IDictionary <string, int> allParameterNamesCounts,
                                                                 string defaultMethodName, ISet <string> unavailableMethodNames, IDictionary <string, string> methodNamesMap, string methodId)
        {
            // filter by unique method parameter names
            var uniqueParameterNames = allParameterNamesCounts
                                       .Where(p => p.Value == 1)
                                       .Select(p => p.Key);

            // find first unique parameter within current parameters
            string firstUniqueParameter = parameterNames
                                          .Intersect(uniqueParameterNames)
                                          .FirstOrDefault();

            if (string.IsNullOrEmpty(firstUniqueParameter))
            {
                return(false);
            }

            // use first unique parameter as part of method name
            var modifiedName = MethodNamesMapper.AddParametersToDefaultMethodName(defaultMethodName, firstUniqueParameter);

            unavailableMethodNames.Add(modifiedName);
            methodNamesMap.Add(methodId, modifiedName);

            return(true);
        }
        private static void AssignMethodNameUsingAnyParameters(List <string> parameterNames, IDictionary <string, int> allParameterNamesCounts,
                                                               string defaultMethodName, ISet <string> unavailableMethodNames, IDictionary <string, string> methodNamesMap, string methodId)
        {
            // assign method name with first available combo of one or more params based on low usage counts
            // if initial combos are not available then eventually all parameters will be used as part of the name (which is guaranteed to be unique)

            // sort param names by lowest usage counts to increase probability of getting a shorter method name with fewer params
            // and decrease long names for methods with a lot of params
            var sortedParameterNames = parameterNames
                                       .OrderBy(name => allParameterNamesCounts[name])
                                       .ToList();

            var parameterCounts = Enumerable.Range(1, parameterNames.Count);

            foreach (var parameterCount in parameterCounts)
            {
                var filteredNames = sortedParameterNames
                                    .Take(parameterCount)
                                    .ToArray();

                var modifiedName = MethodNamesMapper.AddParametersToDefaultMethodName(defaultMethodName, filteredNames);

                if (unavailableMethodNames.Contains(modifiedName))
                {
                    continue;
                }

                unavailableMethodNames.Add(modifiedName);
                methodNamesMap.Add(methodId, modifiedName);

                return;
            }
        }
        private static bool AssignDefaultNameToFirstMethod(IEnumerable <string> parameterNames, int parametersCount, string defaultMethodName,
                                                           ISet <string> unavailableMethodNames, IDictionary <string, string> methodNamesMap, string methodId)
        {
            // assign default method name (without parameters) to first duplicate method
            // the rest of the duplicate methods will have names with parameters in its name
            bool isFirstDuplicateMethod = parametersCount <= 1;

            if (!isFirstDuplicateMethod || unavailableMethodNames.Contains(defaultMethodName))
            {
                return(false);
            }

            unavailableMethodNames.Add(defaultMethodName);
            methodNamesMap.Add(methodId, defaultMethodName);

            // if current method has a parameter then the modified method name that includes it as part of the name
            // should no longer be available for later assignment
            var currentParameterName = parameterNames.SingleOrDefault();

            if (string.IsNullOrEmpty(currentParameterName))
            {
                return(true);
            }

            var modifiedName = MethodNamesMapper.AddParametersToDefaultMethodName(defaultMethodName, currentParameterName);

            unavailableMethodNames.Add(modifiedName);

            return(true);
        }