示例#1
0
        public void TestAllSame()
        {
            var a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n');
            var b = a;

            ConvertToString(Diff.DiffText(a, b, false, false, false)).Should(Be.Empty);
        }
示例#2
0
        public void Test()
        {
            string a, b;

            // test all changes
            a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n');
            b = "0,1,2,3,4,5,6,7,8,9".Replace(',', '\n');
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo("12.10.0.0*"),
                        "all-changes test failed.");

            // test all same
            a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n');
            b = a;
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo(""),
                        "all-same test failed.");

            // test snake
            a = "a,b,c,d,e,f".Replace(',', '\n');
            b = "b,c,d,e,f,x".Replace(',', '\n');
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo("1.0.0.0*0.1.6.5*"),
                        "snake test failed.");

            // 2002.09.20 - repro
            a = "c1,a,c2,b,c,d,e,g,h,i,j,c3,k,l".Replace(',', '\n');
            b = "C1,a,C2,b,c,d,e,I1,e,g,h,i,j,C3,k,I2,l".Replace(',', '\n');
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo("1.1.0.0*1.1.2.2*0.2.7.7*1.1.11.13*0.1.13.15*"),
                        "repro20020920 test failed.");

            // 2003.02.07 - repro
            a = "F".Replace(',', '\n');
            b = "0,F,1,2,3,4,5,6,7".Replace(',', '\n');
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo("0.1.0.0*0.7.1.2*"),
                        "repro20030207 test failed.");

            // Muegel - repro
            a = "HELLO\nWORLD";
            b = "\n\nhello\n\n\n\nworld\n";
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo("2.8.0.0*"),
                        "repro20030409 test failed.");

            // test some differences
            a = "a,b,-,c,d,e,f,f".Replace(',', '\n');
            b = "a,b,x,c,e,f".Replace(',', '\n');
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo("1.1.2.2*1.0.4.4*1.0.7.6*"),
                        "some-changes test failed.");

            // test one change within long chain of repeats
            a = "a,a,a,a,a,a,a,a,a,a".Replace(',', '\n');
            b = "a,a,a,a,-,a,a,a,a,a".Replace(',', '\n');
            Assert.That(TestHelper(Diff.DiffText(a, b, false, false, false)),
                        Is.EqualTo("0.1.4.4*1.0.9.10*"),
                        "long chain of repeats test failed.");
        }
示例#3
0
        public void TestRepro20030207()
        {
            var a = "F".Replace(',', '\n');
            var b = "0,F,1,2,3,4,5,6,7".Replace(',', '\n');

            ConvertToString(Diff.DiffText(a, b, false, false, false)).Should(Be.EqualTo("0.1.0.0*0.7.1.2*"));
        }
示例#4
0
        public void TestRepro20030409()
        {
            var a = "HELLO\nWORLD";
            var b = "\n\nhello\n\n\n\nworld\n";

            ConvertToString(Diff.DiffText(a, b, false, false, false)).Should(Be.EqualTo("2.8.0.0*"));
        }
示例#5
0
        public void TestAllChanges()
        {
            var a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n');
            var b = "0,1,2,3,4,5,6,7,8,9".Replace(',', '\n');

            ConvertToString(Diff.DiffText(a, b, false, false, false)).Should(Be.EqualTo("12.10.0.0*"));
        }
示例#6
0
 public static void Test_01(string s1, string s2, bool trimSpace = false, bool ignoreSpace = false, bool ignoreCase = false)
 {
     Trace.WriteLine($"compare \"{s1}\" and \"{s2}\"");
     Diff.Item[] items = Diff.DiffText(s1, s2, trimSpace, ignoreSpace, ignoreCase);
     Trace.WriteLine($"items.Length \"{items.Length}\"");
     items.zTraceJson();
 }
        private void highlightDifferencesBetweenPreviewPanes()
        {
            string sOld = previewOldValue.Text;
            string sNew = previewNewValue.Text;

            var highlighter = new ScintillaLineHighlightingHelper();

            highlighter.ClearAll(previewNewValue);
            highlighter.ClearAll(previewOldValue);

            Diff diff = new Diff();

            foreach (Diff.Item item in diff.DiffText(sOld, sNew))
            {
                for (int i = item.StartA; i < item.StartA + item.deletedA; i++)
                {
                    highlighter.HighlightLine(previewOldValue, i, Color.Pink);
                }

                //if it is single line change
                for (int i = item.StartB; i < item.StartB + item.insertedB; i++)
                {
                    highlighter.HighlightLine(previewNewValue, i, Color.LawnGreen);
                }
            }
        }
示例#8
0
        public void TestSomeDifferences()
        {
            var a = "a,b,-,c,d,e,f,f".Replace(',', '\n');
            var b = "a,b,x,c,e,f".Replace(',', '\n');

            ConvertToString(Diff.DiffText(a, b, false, false, false)).Should(Be.EqualTo("1.1.2.2*1.0.4.4*1.0.6.5*"));
        }
示例#9
0
        private static void SetDiff()
        {
            TabItem    item1 = (TabItem)tabConstrol1.Items[tabConstrol1.SelectedIndex];
            SBDocument doc1  = (SBDocument)item1.Tag;
            TabItem    item2 = (TabItem)tabConstrol2.Items[tabConstrol2.SelectedIndex];
            SBDocument doc2  = (SBDocument)item2.Tag;

            Diff.Item[] items = Diff.DiffText(doc1.TextArea.Text, doc2.TextArea.Text, true, true, true);

            foreach (Diff.Item item in items)
            {
                Marker marker1 = doc1.TextArea.Markers[SBDocument.DELETED_MARKER];
                marker1.Symbol = MarkerSymbol.Background;
                marker1.SetBackColor(SBDocument.IntToColor(MainWindow.DELETED_HIGHLIGHT_COLOR));
                for (int i = item.StartA; i < item.StartA + item.deletedA; i++)
                {
                    doc1.TextArea.Lines[i].MarkerAdd(SBDocument.DELETED_MARKER);
                }
                Marker marker2 = doc2.TextArea.Markers[SBDocument.INSERTED_MARKER];
                marker2.Symbol = MarkerSymbol.Background;
                marker2.SetBackColor(SBDocument.IntToColor(MainWindow.INSERTED_HIGHLIGHT_COLOR));
                for (int i = item.StartB; i < item.StartB + item.insertedB; i++)
                {
                    doc2.TextArea.Lines[i].MarkerAdd(SBDocument.INSERTED_MARKER);
                }
            }
        }
示例#10
0
        public void TestRepro20020920()
        {
            var a = "c1,a,c2,b,c,d,e,g,h,i,j,c3,k,l".Replace(',', '\n');
            var b = "C1,a,C2,b,c,d,e,I1,e,g,h,i,j,C3,k,I2,l".Replace(',', '\n');

            ConvertToString(Diff.DiffText(a, b, false, false, false)).Should(Be.EqualTo("1.1.0.0*1.1.2.2*0.2.7.7*1.1.11.13*0.1.13.15*"));
        }
示例#11
0
        public void TestSnake()
        {
            var a = "a,b,c,d,e,f".Replace(',', '\n');
            var b = "b,c,d,e,f,x".Replace(',', '\n');

            ConvertToString(Diff.DiffText(a, b, false, false, false)).Should(Be.EqualTo("1.0.0.0*0.1.6.5*"));
        }
示例#12
0
        public DiffHtmlVisualizationResult CompareSource(CodeForCompare codeForCompare)
        {
            var diff   = new Diff();
            var items  = diff.DiffText(codeForCompare.Version1, codeForCompare.Version2);
            var parsed = LineParser.Parse(items, codeForCompare.Version1, codeForCompare.Version2);

            System.Threading.Thread.Sleep(1000);

            return(HtmlVisualizer.Visualize(parsed));
        }
示例#13
0
    static void Main(string[] args)
    {
        string fileA = File.ReadAllText("../../JavaInstall.cpp");
        string fileB = File.ReadAllText("../../JavaInstallList.cpp");

        Diff diff = new Diff();

        Diff.Item[] diffItems = diff.DiffText(fileA, fileB);

        int diffItemLength = diffItems.Length;
    }
示例#14
0
文件: Diff.cs 项目: viiinzzz/AuditSec
    static public string DiffTextString(string a, string b, bool unchanged)
    {
        Diff.Item[] f = Diff.DiffText(a, b, true, true, false);
        if (f == null || f.Length == 0)
        {
            return(null);
        }

        StringBuilder sb = new StringBuilder();

        string[] aLines = a.Split('\n');
        string[] bLines = b.Split('\n');
        int      n      = 0;

        for (int fdx = 0; fdx < f.Length; fdx++)
        {
            Diff.Item aItem = f[fdx];

            // write unchanged lines
            while ((n < aItem.StartB) && (n < bLines.Length))
            {
                if (unchanged)
                {
                    sb.Append(n + ": " + bLines[n]);
                }
                n++;
            }

            // write deleted lines
            for (int m = 0; m < aItem.deletedA; m++)
            {
                sb.Append((unchanged ? "DEL:" : "") + aLines[aItem.StartA + m]);
            }

            // write inserted lines
            while (n < aItem.StartB + aItem.insertedB)
            {
                sb.Append(n + (unchanged ? "INS:" : ":") + bLines[n]);
                n++;
            }
        }

        // write rest of unchanged lines
        while (n < bLines.Length)
        {
            if (unchanged)
            {
                sb.Append(n + ": " + bLines[n]);
            }
            n++;
        }
        return(sb.ToString());
    }
示例#15
0
        private static void TestTextDiff(string a, string b)
        {
            var a1 = a.Replace(',', '\n');
            var b1 = b.Replace(',', '\n');
            var f  = Diff.DiffText(a1, b1, false, false, false);

            string[] aLines = a1.Split('\n');
            string[] bLines = b1.Split('\n');

            void WriteLine(int nr, string typ, string aText)
            {
                Console.WriteLine($"{typ}({nr}) - {aText}");
            }

            int n = 0;

            for (int fdx = 0; fdx < f.Length; fdx++)
            {
                Diff.Item aItem = f[fdx];

                // write unchanged lines
                while ((n < aItem.StartB) && (n < bLines.Length))
                {
                    //WriteLine(n, "", bLines[n]);
                    n++;
                } // while

                // write deleted lines
                for (int m = 0; m < aItem.deletedA; m++)
                {
                    WriteLine(n, "delete", aLines[aItem.StartA + m]);
                } // for

                // write inserted lines
                while (n < aItem.StartB + aItem.insertedB)
                {
                    WriteLine(n, "add", bLines[n]);
                    n++;
                } // while
            }     // while

            // write rest of unchanged lines
            while (n < bLines.Length)
            {
                WriteLine(n, null, bLines[n]);
                n++;
            } // while
        }
示例#16
0
        public void CreateScintillaComponents(string textBefore, string textAfter, string language = "mssql")
        {
            QueryEditorBefore          = new ScintillaTextEditorFactory().Create();
            QueryEditorBefore.Text     = textBefore;
            QueryEditorBefore.ReadOnly = true;

            splitContainer1.Panel1.Controls.Add(QueryEditorBefore);

            QueryEditorAfter          = new ScintillaTextEditorFactory().Create();
            QueryEditorAfter.Text     = textAfter;
            QueryEditorAfter.ReadOnly = true;

            splitContainer1.Panel2.Controls.Add(QueryEditorAfter);

            //compute difference
            if (textBefore == null)
            {
                textBefore = "";
            }
            if (textAfter == null)
            {
                textAfter = "";
            }

            Diff diff = new Diff();

            var highlighter = new ScintillaLineHighlightingHelper();

            highlighter.ClearAll(QueryEditorAfter);
            highlighter.ClearAll(QueryEditorBefore);

            foreach (Diff.Item item in diff.DiffText(textBefore, textAfter))
            {
                for (int i = item.StartA; i < item.StartA + item.deletedA; i++)
                {
                    highlighter.HighlightLine(QueryEditorBefore, i, Color.Pink);
                }

                for (int i = item.StartB; i < item.StartB + item.insertedB; i++)
                {
                    highlighter.HighlightLine(QueryEditorAfter, i, Color.LawnGreen);
                }
            }
        }
示例#17
0
        public void MirroredProfileDefTest()
        {
            using (var model = IfcStore.Open(@"Ifc4TestFiles\IfcMirroredProfileDef.ifc"))
            {
                var derived  = model.Instances[50] as IIfcDerivedProfileDef;   //derived profile, mirrored by transform
                var mirrored = model.Instances[177] as IIfcMirroredProfileDef; //mirrored versio of above
                Assert.IsNotNull(derived);
                Assert.IsNotNull(mirrored);

                var dFace  = _xbimGeometryCreator.CreateFace(derived);
                var mFace  = _xbimGeometryCreator.CreateFace(mirrored);
                var brepD  = dFace.ToBRep;
                var brepM  = mFace.ToBRep;
                var differ = new Diff();
                var diffs  = differ.DiffText(brepM, brepD);
                Assert.IsTrue(mFace.Normal == dFace.Normal);
                Assert.IsTrue(diffs.Length == 3);
            }
        }
示例#18
0
        /// <summary>
        /// start a self- / box-test for some diff cases and report to the debug output.
        /// </summary>
        /// <param name="args">not used</param>
        /// <returns>always 0</returns>
        public static int Main(string[] args)
        {
            StringBuilder ret = new StringBuilder();
            string        a, b;

            System.Diagnostics.ConsoleTraceListener ctl = new System.Diagnostics.ConsoleTraceListener(false);
            System.Diagnostics.Debug.Listeners.Add(ctl);

            System.Console.WriteLine("Diff Self Test...");

            // test all changes
            a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n');
            b = "0,1,2,3,4,5,6,7,8,9".Replace(',', '\n');
            System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false))
                                            == "12.10.0.0*",
                                            "all-changes test failed.");
            System.Diagnostics.Debug.WriteLine("all-changes test passed.");
            // test all same
            a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n');
            b = a;
            System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false))
                                            == "",
                                            "all-same test failed.");
            System.Diagnostics.Debug.WriteLine("all-same test passed.");

            // test snake
            a = "a,b,c,d,e,f".Replace(',', '\n');
            b = "b,c,d,e,f,x".Replace(',', '\n');
            System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false))
                                            == "1.0.0.0*0.1.6.5*",
                                            "snake test failed.");
            System.Diagnostics.Debug.WriteLine("snake test passed.");

            // 2002.09.20 - repro
            a = "c1,a,c2,b,c,d,e,g,h,i,j,c3,k,l".Replace(',', '\n');
            b = "C1,a,C2,b,c,d,e,I1,e,g,h,i,j,C3,k,I2,l".Replace(',', '\n');
            System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false))
                                            == "1.1.0.0*1.1.2.2*0.2.7.7*1.1.11.13*0.1.13.15*",
                                            "repro20020920 test failed.");
            System.Diagnostics.Debug.WriteLine("repro20020920 test passed.");

            // 2003.02.07 - repro
            a = "F".Replace(',', '\n');
            b = "0,F,1,2,3,4,5,6,7".Replace(',', '\n');
            System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false))
                                            == "0.1.0.0*0.7.1.2*",
                                            "repro20030207 test failed.");
            System.Diagnostics.Debug.WriteLine("repro20030207 test passed.");

            // Muegel - repro
            a = "HELLO\nWORLD";
            b = "\n\nhello\n\n\n\nworld\n";
            System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false))
                                            == "2.8.0.0*",
                                            "repro20030409 test failed.");
            System.Diagnostics.Debug.WriteLine("repro20030409 test passed.");

            // test some differences
            a = "a,b,-,c,d,e,f,f".Replace(',', '\n');
            b = "a,b,x,c,e,f".Replace(',', '\n');
            System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false))
                                            == "1.1.2.2*1.0.4.4*1.0.6.5*",
                                            "some-changes test failed.");
            System.Diagnostics.Debug.WriteLine("some-changes test passed.");

            System.Diagnostics.Debug.WriteLine("End.");
            System.Diagnostics.Debug.Flush();

            return(0);
        }
示例#19
0
        public SQLBeforeAndAfterViewer(string sqlBefore, string sqlAfter, string headerTextForBefore, string headerTextForAfter, string caption, MessageBoxButtons buttons, string language = "mssql")
        {
            InitializeComponent();

            bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);

            if (designMode) //dont add the QueryEditor if we are in design time (visual studio) because it breaks
            {
                return;
            }

            QueryEditorBefore          = new ScintillaTextEditorFactory().Create();
            QueryEditorBefore.Text     = sqlBefore;
            QueryEditorBefore.ReadOnly = true;

            splitContainer1.Panel1.Controls.Add(QueryEditorBefore);


            QueryEditorAfter          = new ScintillaTextEditorFactory().Create();
            QueryEditorAfter.Text     = sqlAfter;
            QueryEditorAfter.ReadOnly = true;

            splitContainer1.Panel2.Controls.Add(QueryEditorAfter);


            //compute difference
            var highlighter = new ScintillaLineHighlightingHelper();

            highlighter.ClearAll(QueryEditorAfter);
            highlighter.ClearAll(QueryEditorBefore);

            if (sqlBefore == null)
            {
                sqlBefore = "";
            }
            if (sqlAfter == null)
            {
                sqlAfter = "";
            }

            Diff diff = new Diff();

            foreach (Diff.Item item in diff.DiffText(sqlBefore, sqlAfter))
            {
                for (int i = item.StartA; i < item.StartA + item.deletedA; i++)
                {
                    highlighter.HighlightLine(QueryEditorBefore, i, Color.Pink);
                }

                for (int i = item.StartB; i < item.StartB + item.insertedB; i++)
                {
                    highlighter.HighlightLine(QueryEditorAfter, i, Color.LawnGreen);
                }
            }

            switch (buttons)
            {
            case MessageBoxButtons.OK:
                btnYes.Visible = true;
                btnYes.Text    = "Ok";
                btnNo.Visible  = false;
                break;

            case MessageBoxButtons.YesNo:
                btnYes.Visible = true;
                btnNo.Visible  = true;
                break;

            default:
                throw new NotSupportedException("buttons");
            }

            lblBefore.Text = headerTextForBefore;
            lblAfter.Text  = headerTextForAfter;

            this.Text = caption;
        }
示例#20
0
        private bool AreEqual(
            IEnumerable <TSqlParserToken> entity1Tokens,
            IEnumerable <TSqlParserToken> entity2Tokens,
            HashSet <int> lineNumbersLeft,
            HashSet <int> lineNumbersRight,
            CompareOptions compareOptions)
        {
            var entity1TokensGroupedByLine = entity1Tokens.GroupBy(x => x.Line).ToList();
            var entity2TokensGroupedByLine = entity2Tokens.GroupBy(x => x.Line).ToList();

            // Get lines
            var entity1Lines   = new List <string>(entity1TokensGroupedByLine.Count);
            var entity2Lines   = new List <string>(entity2TokensGroupedByLine.Count);
            var entity1LineMap = new Dictionary <int, int>(entity1TokensGroupedByLine.Count);
            var entity2LineMap = new Dictionary <int, int>(entity2TokensGroupedByLine.Count);

            var index = 0;

            foreach (var group in entity1TokensGroupedByLine.OrderBy(g => g.Key))
            {
                entity1Lines.Add(string.Join(string.Empty, group.Select(x => x.Text)).Replace(Environment.NewLine, string.Empty));
                entity1LineMap.Add(index, group.Key);
                index++;
            }
            index = 0;
            foreach (var group in entity2TokensGroupedByLine.OrderBy(g => g.Key))
            {
                entity2Lines.Add(string.Join(string.Empty, group.Select(x => x.Text)).Replace(Environment.NewLine, string.Empty));
                entity2LineMap.Add(index, group.Key);
                index++;
            }

            var results = Diff.DiffText(string.Join(Environment.NewLine, entity1Lines.ToArray()), string.Join(Environment.NewLine, entity2Lines.ToArray()), true, true, true);

            if (results.Count() == 0)
            {
                // The same
                return(true);
            }

            if (entity1Lines.Count == 0 || entity2Lines.Count == 0)
            {
                // Missing
                return(false);
            }

            // Build line number diffs
            foreach (var diffResult in results)
            {
                for (var i = diffResult.StartA; i < diffResult.StartA + diffResult.deletedA; i++)
                {
                    lineNumbersLeft.Add(entity1LineMap[i]);
                }
                for (var i = diffResult.StartB; i < diffResult.StartB + diffResult.insertedB; i++)
                {
                    lineNumbersRight.Add(entity2LineMap[i]);
                }
            }

            return(false);
        }
        // diffLocation - desired output location. Filename will NOT be appended
        public void diffReports(string firstReportLocation, string secondReportLocation, string diffLocation)
        {
            // create reader & open file
            TextReader tr1 = new StreamReader(firstReportLocation);
            TextReader tr2 = new StreamReader(secondReportLocation);

            // read a files
            string file1 = tr1.ReadToEnd();
            string file2 = tr2.ReadToEnd();
            string[] file1Lines = Regex.Split(file1, "\r|\n|(\r\n)");
            string[] file2Lines = Regex.Split(file2, "\r|\n|(\r\n)");

            // close the stream
            tr1.Close();
            tr2.Close();

            // get diffs
            //string reportString = "";
            Diff diffUtil = new Diff();
            Diff.Item[] diffs = diffUtil.DiffText(file1, file2);

            // initialize the list that we will use to insert new lines and build diff IFQ
            List<string> mergeList = new List<string>();
            int pos = 0;
            for (int n = 0; n < diffs.Length; n++)
            {
                Diff.Item it = diffs[n];

                // write unchanged lines
                while ((pos < it.StartB) && (pos < file2Lines.Length))
                {
                    mergeList.Add(file2Lines[pos]);
                    pos++;
                } // while
                if (it.deletedA != it.insertedB)
                {
                    // write deleted chars
                    if (it.deletedA > 0)
                    {
                        mergeList.Add("<div style='color: #ff0000; text-decoration: line-through';>");
                        for (int m = 0; m < it.deletedA; m++)
                        {
                            mergeList.Add(file1Lines[it.StartA + m]);
                        } // for
                        mergeList.Add("</div>");
                    }
                }

                // write inserted chars
                if (pos < it.StartB + it.insertedB)
                {
                    mergeList.Add("<div style='color: #008E00'>");
                    while (pos < it.StartB + it.insertedB)
                    {
                        mergeList.Add(file2Lines[pos]);
                        pos++;
                    } // while
                    mergeList.Add("</div>");
                } // if
            } // while

            // write rest of unchanged chars
            while (pos < file2Lines.Length)
            {
                mergeList.Add(file2Lines[pos]);
                pos++;
            }

            /*  Saving Output */
            FileStream fStream = new FileStream(
                diffLocation,
                FileMode.Create,
                FileAccess.Write,
                FileShare.Read);
            StreamWriter sw = new StreamWriter(fStream);
            string[] reportStrings = mergeList.ToArray();
            sw.Write(string.Join("\n", reportStrings));
            sw.Close();     // Close the Stream
            fStream.Close();     // Close the File
        }
        // diffLocation - desired output location. Filename will NOT be appended
        public void diffReports(string firstReportLocation, string secondReportLocation, string diffLocation)
        {
            // create reader & open file
            TextReader tr1 = new StreamReader(firstReportLocation);
            TextReader tr2 = new StreamReader(secondReportLocation);

            // read a files
            string file1 = tr1.ReadToEnd();
            string file2 = tr2.ReadToEnd();

            string[] file1Lines = Regex.Split(file1, "\r|\n|(\r\n)");
            string[] file2Lines = Regex.Split(file2, "\r|\n|(\r\n)");

            // close the stream
            tr1.Close();
            tr2.Close();

            // get diffs
            //string reportString = "";
            Diff diffUtil = new Diff();

            Diff.Item[] diffs = diffUtil.DiffText(file1, file2);

            // initialize the list that we will use to insert new lines and build diff IFQ
            List <string> mergeList = new List <string>();
            int           pos       = 0;

            for (int n = 0; n < diffs.Length; n++)
            {
                Diff.Item it = diffs[n];

                // write unchanged lines
                while ((pos < it.StartB) && (pos < file2Lines.Length))
                {
                    mergeList.Add(file2Lines[pos]);
                    pos++;
                } // while
                if (it.deletedA != it.insertedB)
                {
                    // write deleted chars
                    if (it.deletedA > 0)
                    {
                        mergeList.Add("<div style='color: #ff0000; text-decoration: line-through';>");
                        for (int m = 0; m < it.deletedA; m++)
                        {
                            mergeList.Add(file1Lines[it.StartA + m]);
                        } // for
                        mergeList.Add("</div>");
                    }
                }

                // write inserted chars
                if (pos < it.StartB + it.insertedB)
                {
                    mergeList.Add("<div style='color: #008E00'>");
                    while (pos < it.StartB + it.insertedB)
                    {
                        mergeList.Add(file2Lines[pos]);
                        pos++;
                    } // while
                    mergeList.Add("</div>");
                }     // if
            }         // while

            // write rest of unchanged chars
            while (pos < file2Lines.Length)
            {
                mergeList.Add(file2Lines[pos]);
                pos++;
            }

            /*  Saving Output */
            FileStream fStream = new FileStream(
                diffLocation,
                FileMode.Create,
                FileAccess.Write,
                FileShare.Read);
            StreamWriter sw = new StreamWriter(fStream);

            string[] reportStrings = mergeList.ToArray();
            sw.Write(string.Join("\n", reportStrings));
            sw.Close();      // Close the Stream
            fStream.Close(); // Close the File
        }