Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
        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")));

        }
Ejemplo 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);
        }
Ejemplo n.º 4
0
 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")));
 }
Ejemplo n.º 5
0
 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")));
 }
Ejemplo n.º 6
0
 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")));
 }
Ejemplo n.º 7
0
 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")));
 }
Ejemplo n.º 8
0
 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")));
 }
Ejemplo n.º 9
0
 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")));
 }
Ejemplo n.º 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")));
 }
Ejemplo n.º 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")));
 }
Ejemplo n.º 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")));
 }