Exemplo n.º 1
0
        /// <summary>
        /// Checks if the type has changes
        /// On type level
        /// Base Types, implemented interfaces, generic parameters
        /// On method level
        /// Method modifiers, return type, generic parameters, parameter count, parameter types (also generics)
        /// On field level
        /// Field types
        /// </summary>
        /// <param name="typeV1">The type v1.</param>
        /// <param name="typeV2">The type v2.</param>
        /// <param name="diffQueries">The diff queries.</param>
        /// <returns></returns>
        public static TypeDiff GenerateDiff(TypeDefinition typeV1, TypeDefinition typeV2, QueryAggregator diffQueries)
        {
            if (typeV1 == null)
            {
                throw new ArgumentNullException("typeV1");
            }
            if (typeV2 == null)
            {
                throw new ArgumentNullException("typeV2");
            }
            if (diffQueries == null || diffQueries.FieldQueries.Count == 0 ||
                diffQueries.MethodQueries.Count == 0)
            {
                throw new ArgumentException("diffQueries was null or the method or field query list was emtpy. This will not result in a meaningful diff result");
            }

            TypeDiff diff = new TypeDiff(typeV1, typeV2);

            diff.DoDiff(diffQueries);

            if (!diff.HasChangedBaseType &&
                diff.Events.Count == 0 &&
                diff.Fields.Count == 0 &&
                diff.Interfaces.Count == 0 &&
                diff.Methods.Count == 0)
            {
                return(TypeDiff.None);
            }

            return(diff);
        }
Exemplo n.º 2
0
        public static TypeDiff GetTypeByName(this HashSet <TypeDiff> set, string typeName)
        {
            TypeDiff lret = null;

            foreach (TypeDiff type in set)
            {
                if (String.CompareOrdinal(type.ToString(), typeName) == 0)
                {
                    lret = type;
                    break;
                }
            }

            return(lret);
        }
Exemplo n.º 3
0
        private void DiffTypes(List <TypeDefinition> typesV1, List <TypeDefinition> typesV2, QueryAggregator queries)
        {
            TypeDefinition typeV2;

            foreach (var typeV1 in typesV1)
            {
                typeV2 = GetTypeByDefinition(typeV1, typesV2);
                if (typeV2 != null)
                {
                    TypeDiff diffed = TypeDiff.GenerateDiff(typeV1, typeV2, queries);
                    if (TypeDiff.None != diffed)
                    {
                        myDiff.ChangedTypes.Add(diffed);
                    }
                }
            }
        }