Exemplo n.º 1
0
        private void AddEfferentCoupling(MethodReference from, IEnumerable <MemberAccess> to, int complexity)
        {
            CouplingCacheNode node;
            var fromFullName = from.GetCacheName();

            if (!_efferentCache.TryGetValue(fromFullName, out node))
            {
                lock (_efferentCache)
                {
                    if (!_efferentCache.TryGetValue(fromFullName, out node))
                    {
                        node            = new CouplingCacheNode(fromFullName, from);
                        node.Complexity = complexity;
                        _efferentCache.Add(fromFullName, node);
                    }
                }
            }
            lock (node)
            {
                foreach (var current in to)
                {
                    node.AddCoupling(new Coupling(current.MemberReference.GetCacheName(), current.IsReadOnly, false,
                                                  current.IsSelfCall, current.OnField, current.ActualMethodDefinition));
                }
            }
        }
Exemplo n.º 2
0
        private AffectedGraphNode GetGraphNode(string fullName, CouplingCacheNode afferent, bool isRootNode, bool isChange)
        {
            if (afferent == null)
            {
                return(new AffectedGraphNode(fullName, false, false, false, "", fullName, "", "", new List <TestDescriptor>(), false, false, 0));
            }
            var r      = afferent.MemberReference;
            var type   = r.DeclaringType.ThreadSafeResolve();
            var isTest = false;
            List <TestDescriptor> descriptors = null;

            isTest = _testStrategies.IsTest(r);
            var shortName = r.DeclaringType.Name + "::" + r.Name;

            if (isTest)
            {
                var method = r as MethodReference;
                if (method != null)
                {
                    var tmp = _testStrategies.GetSpecificallyMangledName(method);
                    if (tmp != null)
                    {
                        fullName  = tmp;
                        shortName = HackName(fullName);
                    }
                }
                descriptors = new List <TestDescriptor>(_testStrategies.GetDescriptorsFor(r));
            }

            var inTestAssembly = _cache.AssemblyHasTests(type.Module.FullyQualifiedName);

            return(new AffectedGraphNode(shortName, type.IsInterface, isTest, isRootNode, r.Name, fullName, type.Module.FullyQualifiedName, type.FullName, descriptors, isChange, inTestAssembly, afferent.Complexity));
        }
Exemplo n.º 3
0
        public bool IsFixtureConstructor(CouplingCacheNode node)
        {
            var methodref = node.MemberReference as MethodReference;

            if (methodref == null)
            {
                return(false);
            }
            var methoddef = methodref.ThreadSafeResolve();

            if (!methoddef.IsConstructor)
            {
                return(false);
            }
            return(_testIdentifiers.IsInFixture(methoddef));
        }
Exemplo n.º 4
0
 private void AddAfferentCoupling(MemberReference from, IEnumerable<MemberAccess> to)
 {
     CouplingCacheNode node;
     var toFullName = from.GetCacheName();
     if (!_afferentCache.TryGetValue(toFullName, out node))
     {
         lock (_afferentCache)
         {
             if (!_afferentCache.TryGetValue(toFullName, out node))
             {
                 node = new CouplingCacheNode(toFullName, from);
                 _afferentCache.Add(toFullName, node);
             }
         }
     }
     lock (node)
     {
         foreach (var current in to)
         {
             node.AddCoupling(new Coupling(current.MemberReference.GetCacheName(), current.IsReadOnly, false,
                                           current.IsSelfCall, current.OnField, current.ActualMethodDefinition));
         }
     }
 }
Exemplo n.º 5
0
        private bool TryInterfacePrune(string fullName, int depth, List <string> breadCrumbs, CouplingCacheNode efferentEntry, TypeReference parentType, TypeDefinition definition)
        {
            var def = parentType.ThreadSafeResolve();

            if (parentType != null && !definition.IsInterface && def != null && def.IsInterface &&
                !_interfaceFollowingStrategy.ShouldContinueAfter(efferentEntry.MemberReference))
            {
                WriteWalkerDebug("I should not follow interface to here.", depth);
                breadCrumbs.Remove(fullName);
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
 private bool TryInterfacePrune(string fullName, int depth, List<string> breadCrumbs, CouplingCacheNode efferentEntry, TypeReference parentType, TypeDefinition definition)
 {
     var def = parentType.ThreadSafeResolve();
     if (parentType != null && !definition.IsInterface && def!=null && def.IsInterface &&
         !_interfaceFollowingStrategy.ShouldContinueAfter(efferentEntry.MemberReference))
     {
         WriteWalkerDebug("I should not follow interface to here.", depth);
         breadCrumbs.Remove(fullName);
         return true;
     }
     return false;
 }
Exemplo n.º 7
0
 private AffectedGraphNode GetGraphNode(string fullName, CouplingCacheNode afferent, bool isRootNode, bool isChange)
 {
     if (afferent == null) return new AffectedGraphNode(fullName, false, false, false, "", fullName, "", "", new List<TestDescriptor>(), false, false, 0);
     var r = afferent.MemberReference;
     var type = r.DeclaringType.ThreadSafeResolve();
     var isTest = false;
     List<TestDescriptor> descriptors = null;
     isTest = _testStrategies.IsTest(r);
     var shortName = r.DeclaringType.Name + "::" + r.Name;
     if (isTest)
     {
         var method = r as MethodReference;
         if (method != null)
         {
             var tmp = _testStrategies.GetSpecificallyMangledName(method);
             if (tmp != null)
             {
                 fullName = tmp;
                 shortName = HackName(fullName);
             }
         }
         descriptors = new List<TestDescriptor>(_testStrategies.GetDescriptorsFor(r));
     }
     
     var inTestAssembly = _cache.AssemblyHasTests(type.Module.FullyQualifiedName);
     return new AffectedGraphNode(shortName, type.IsInterface, isTest, isRootNode, r.Name, fullName, type.Module.FullyQualifiedName, type.FullName, descriptors, isChange, inTestAssembly, afferent.Complexity);
 }
Exemplo n.º 8
0
 public bool IsFixtureConstructor(CouplingCacheNode node)
 {
     var methodref = node.MemberReference as MethodReference;
     if (methodref == null) return false;
     var methoddef = methodref.ThreadSafeResolve();
     if (!methoddef.IsConstructor) return false;
     return _testIdentifiers.IsInFixture(methoddef);
 }