示例#1
0
        public void SetCoupling(ScanResult result)
        {
            IEnumerable <MemberAccess> to = result.MemberAccesses;
            var from = result.Definition;
            IEnumerable <MemberAccess> all = _testIdentifiers.Aggregate(to, (current, ider) => current.Concat(ider.GetHiddenDependenciesForTest(from)));
            var isTest          = _testIdentifiers.IsTest(from);
            var isSetup         = _testIdentifiers.IsSetup(from);
            var isTeardown      = _testIdentifiers.IsTeardown(from);
            var isRelatedToTest = isTeardown || isSetup || isTest;

            if (isRelatedToTest)
            {
                var asmName = from.DeclaringType.Module.Assembly.FullName;
                if (!_testAssemblies.ContainsKey(asmName))
                {
                    lock (_testAssemblies)
                    {
                        if (!_testAssemblies.ContainsKey(asmName))
                        {
                            _testAssemblies.Add(asmName, true);
                        }
                    }
                }
            }
            var allSynonyms = SynonymFinder.FindSynonymsFor(from);

            allSynonyms.Add(from);
            AddEfferentCoupling(from, all, result.Complexity);
            foreach (var entry in all)
            {
                AddAfferentCoupling(entry.MemberReference, new [] { new MemberAccess(from, entry.IsReadOnly, entry.IsSelfCall, entry.OnField, entry.ActualMethodDefinition, entry.IsLocalVariable) });
            }
        }
示例#2
0
        private void RecurseSynonyms(int depth, Dictionary <string, bool> history, TypeDefinition inheritedTypeContext, MethodDefinition currentDefinition, AffectedGraph graph, List <string> breadCrumbs, GenericContext genericContext)
        {
            var synonyms = SynonymFinder.FindSynonymsFor(currentDefinition);

            foreach (var current in synonyms)
            {
                var c = current as MethodDefinition;
                if (c == null)
                {
                    continue;            //shouldn't happen
                }
                if (!c.DeclaringType.IsInterface)
                {
                    FillAfferentGraph(current.GetCacheName(), history, graph, currentDefinition, depth + 1,
                                      inheritedTypeContext, true, breadCrumbs, genericContext, true); //always a base
                }
                else
                {
                    FillAfferentGraph(current.GetCacheName(), history, graph, currentDefinition, depth + 1,
                                      inheritedTypeContext, false, breadCrumbs, genericContext, false);
                }
            }
        }