Exemple #1
0
        public IReadOnlyList <IEnumerable <CompatDifference> > Run <T>(ElementMapper <T> mapper)
        {
            int rightLength = mapper.Right.Length;

            List <CompatDifference>[] result = new List <CompatDifference> [rightLength];

            if (rightLength == 1)
            {
                RunOnMapper(0);
            }
            else
            {
                for (int j = 0; j < rightLength; j++)
                {
                    RunOnMapper(j);
                }
            }

            void RunOnMapper(int rightIndex)
            {
                string leftName  = _leftName;
                string rightName = rightIndex < _rightNames.Length ? _rightNames[rightIndex] : DEFAULT_RIGHT_NAME;
                List <CompatDifference> differences = new();
                T right = mapper.Right[rightIndex];

                if (mapper is AssemblyMapper am)
                {
                    _context.RunOnAssemblySymbolActions(am.Left, (IAssemblySymbol)right, leftName, rightName, differences);
                }
                else if (mapper is TypeMapper tm)
                {
                    if (tm.ShouldDiffElement(rightIndex))
                    {
                        _context.RunOnTypeSymbolActions(tm.Left, (ITypeSymbol)right, leftName, rightName, differences);
                    }
                }
                else if (mapper is MemberMapper mm)
                {
                    if (mm.ShouldDiffElement(rightIndex))
                    {
                        _context.RunOnMemberSymbolActions(
                            mm.Left,
                            (ISymbol)right,
                            mm.ContainingType.Left,
                            mm.ContainingType.Right[rightIndex],
                            leftName,
                            rightName,
                            differences);
                    }
                }
                result[rightIndex] = differences;
            }

            return(result);
        }
Exemple #2
0
        public IReadOnlyList <IEnumerable <CompatDifference> > Run <T>(ElementMapper <T> mapper)
        {
            List <List <CompatDifference> > result = new();

            if (mapper.Right.Length == 1)
            {
                RunOnMapper(0);
            }
            else
            {
                for (int j = 0; j < mapper.Right.Length; j++)
                {
                    RunOnMapper(j);
                }
            }

            void RunOnMapper(int rightIndex)
            {
                List <CompatDifference> differences = new();
                T right = mapper.Right[rightIndex];

                if (mapper is AssemblyMapper)
                {
                    _context.RunOnAssemblySymbolActions((IAssemblySymbol)mapper.Left, (IAssemblySymbol)right, differences);
                }
                else if (mapper is TypeMapper tm)
                {
                    if (tm.ShouldDiffElement(rightIndex))
                    {
                        _context.RunOnTypeSymbolActions((ITypeSymbol)mapper.Left, (ITypeSymbol)right, differences);
                    }
                }
                else if (mapper is MemberMapper mm)
                {
                    if (mm.ShouldDiffElement(rightIndex))
                    {
                        _context.RunOnMemberSymbolActions((ISymbol)mapper.Left, (ISymbol)right, differences);
                    }
                }
                result.Add(differences);
            }

            return(result);
        }