Exemplo n.º 1
0
        public IEnumerable <Change <string> > GetAllPublicContractChangesBetween(AssemblyDefinition oldAssembly, AssemblyDefinition newAssembly)
        {
            var ret = new List <Change <string> >();

            try
            {
                if (newAssembly.ContainsAttribute("InternalsVisibleToAttribute"))
                {
                    ret.Add(new Change <string>(ChangeType.Modify, "Internals Are Visible, rebuild!"));
                }
                ;
                var oldCache    = AssemblyPubliclyVisibleStuffMapBuilder.BuildPublicOnlyFor(oldAssembly);
                var newCache    = AssemblyPubliclyVisibleStuffMapBuilder.BuildPublicOnlyFor(newAssembly);
                var differences = MapKeyDifferenceFinder.GetChangesBetween(oldCache, newCache);
                foreach (var c in differences)
                {
                    ret.Add(new Change <string>(c.ChangeType, c.ItemChanged.FullName));
                }
            }
            catch (Exception ex)
            {
                ret.Add(new Change <string>(ChangeType.Modify, "An exception occured finding changes" + ex));
            }
            return(ret);
        }
        private static bool CheckProviderAttributes(IEnumerable <CustomAttribute> originalMethodDefinition, IEnumerable <CustomAttribute> newMethodDefinition)
        {
            var originalSet = GetParameterMap(originalMethodDefinition);
            var newSet      = GetParameterMap(newMethodDefinition);
            var changes     = MapKeyDifferenceFinder.GetChangesBetween(originalSet, newSet);

            return(changes.Count > 0);
        }
Exemplo n.º 3
0
        public IEnumerable <Change <MethodReference> > GetChangesBetween(AssemblyDefinition oldAssembly, AssemblyDefinition newAssembly)
        {
            var changeDetector = new MethodILChangeDetector();
            var oldCache       = AssemblyTypeMethodMapBuilder.BuildFor(oldAssembly);
            var newCache       = AssemblyTypeMethodMapBuilder.BuildFor(newAssembly);
            var differences    = MapKeyDifferenceFinder.GetChangesBetween(oldCache, newCache);

            foreach (var method in newAssembly.AllNonIgnoredMethods())
            {
                var current = oldAssembly.MainModule.GetType(method.DeclaringType.FullName);
                if (current == null)
                {
                    continue;
                }
                if (method.ContainsIgnoreAttribute())
                {
                    continue;
                }
                foreach (var oldMethod in current.Methods)
                {
                    if (oldMethod.GetChangeCacheName() == method.GetChangeCacheName())
                    {
                        if (changeDetector.AreDifferentIL(oldMethod,
                                                          method))
                        {
                            differences.Add(
                                new Change <MethodReference>(
                                    ChangeType.Modify, method.ThreadSafeResolve()));
                            break;
                        }
                    }
                }
            }
            differences = IEnumerableResolver.ResolveCompilerGeneratedCode(differences);
            return(differences);
        }