Exemplo n.º 1
0
        private static UpversionType AnalyzeMethods(IList <MethodSpec> oldMethods, IList <MethodSpec> newMethods)
        {
            UpversionType maxUpversionType = UpversionType.Patch;

            foreach (MethodSpec oldMethod in oldMethods)
            {
                MethodSpec newMethod = newMethods
                                       .FirstOrDefault(field => field.Name.Name.Equals(oldMethod.Name.Name, StringComparison.InvariantCulture));
                if (newMethod == null)
                {
                    return(UpversionType.Major);
                }

                if (!newMethod.ReturnType.Equals(oldMethod.ReturnType, StringComparison.InvariantCulture))
                {
                    return(UpversionType.Major);
                }

                // Check parameters
                bool isMajorChange = NapackAnalyst.AnayzeParameters(oldMethod.Parameters, newMethod.Parameters);
                if (isMajorChange)
                {
                    return(UpversionType.Major);
                }
            }

            if (maxUpversionType == UpversionType.Patch && newMethods.Count != oldMethods.Count)
            {
                return(UpversionType.Minor);
            }

            return(maxUpversionType);
        }
Exemplo n.º 2
0
        private static UpversionType AnalyzeConstructors(IList <ConstructorSpec> oldConstructors, IList <ConstructorSpec> newConstructors)
        {
            UpversionType maxUpversionType = UpversionType.Patch;

            foreach (ConstructorSpec oldConstructor in oldConstructors)
            {
                // Constructor matching is complicated as all constructors have the same name, but different parameters.
                // For now, perform an inefficient n^2 matching by comparing each old constructor against each new one.
                bool anyWithoutMajorChanges = false;
                foreach (ConstructorSpec newConstructor in newConstructors)
                {
                    if (!NapackAnalyst.AnayzeParameters(oldConstructor.Parameters, newConstructor.Parameters))
                    {
                        anyWithoutMajorChanges = true;
                        break;
                    }
                }

                if (!anyWithoutMajorChanges)
                {
                    return(UpversionType.Major);
                }
            }

            if (maxUpversionType == UpversionType.Patch && newConstructors.Count != oldConstructors.Count)
            {
                return(UpversionType.Minor);
            }

            return(maxUpversionType);
        }