Пример #1
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;
 }
        public void method_level_attribute_on_both_results_in_not_marked_as_modified()
        {
            var dectector = new MethodILChangeDetector();
            Assert.IsFalse(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestMethods>("SameAsInstance2WithAttribute"),
                                                   assembly.GetMethodDefinition<TestMethods>("SameAsInstance2WithAttribute")));

        }
Пример #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);
        }
 public void parameter_level_attribute_remove_results_in_marked_as_modified()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsTrue(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestMethods>("HasParameterAttribute"),
                                            assembly.GetMethodDefinition<TestMethods>("HasNoParameterAttribute")));
 }
 public void method_level_attribute_without_different_data_results_in_not_marked_as_modified()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsFalse(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestMethods>("HasMethodAttributeWithData"),
                                            assembly.GetMethodDefinition<TestMethods>("HasMethodAttributeWithData")));
 }
 public void methods_that_only_have_different_string_data_are_different()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsTrue(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestMethods>("Instance2"),
                                            assembly.GetMethodDefinition<TestMethods>("StringDifferentAsInstance2")));
 }
 public void noninherited_return_level_attribute_compare_results_in_not_marked_as_modified()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsFalse(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestingDerived>("HasNonInhertibleReturnAttribute"),
                                            assembly.GetMethodDefinition<TestingDerived>("HasNoAttribute")));
 }
 public void inherited_param_level_attribute_add_results_in_marked_as_modified()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsTrue(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestingDerived>("HasInheritedParamAttribute"),
                                            assembly.GetMethodDefinition<TestingDerived>("HasNoAttribute")));
 }
 public void methods_that_are_the_same_are_not_different()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsFalse(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestMethods>("Instance2"),
                                            assembly.GetMethodDefinition<TestMethods>("SameAsInstance2")));
 }
Пример #10
0
 public void inherited_type_level_attribute_remove_results_in_marked_as_modified()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsTrue(dectector.AreDifferentIL(assembly.GetMethodDefinition<Type1Derived>("Foo"),
                                            assembly.GetMethodDefinition<Type1>("Foo")));
 }
Пример #11
0
 public void return_level_attribute_with_different_data_results_in_marked_as_modified()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsTrue(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestMethods>("HasReturnAttributeWithData"),
                                            assembly.GetMethodDefinition<TestMethods>("HasReturnAttributeWithDifferentData")));
 }
Пример #12
0
 public void methods_that_are_different_show_up_as_different()
 {
     var dectector = new MethodILChangeDetector();
     Assert.IsTrue(dectector.AreDifferentIL(assembly.GetMethodDefinition<TestMethods>("Instance1"),
                                            assembly.GetMethodDefinition<TestMethods>("Instance2")));
 }