private bool CompareTags(string[] fileTags1, string[] fileTags2, ref TagDiffResult tagDiffResult, TagDiff.DiffSource source)
        {
            bool found = true;

            //are all tags in file1 found in file2
            foreach (string s1 in fileTags1)
            {
                if (!fileTags2.Contains(s1))
                {
                    found = false;
                    tagDiffResult.TagDiffList.Add(new TagDiff()
                    {
                        Tag = s1, Source = source
                    });
                }
            }

            return(found);
        }
        /// <summary>
        /// Main entry from CLI
        /// </summary>
        /// <returns></returns>
        public TagDiffResult GetResult()
        {
            WriteOnce.SafeLog("TagDiffCommand::Run", LogLevel.Trace);
            WriteOnce.Operation(MsgHelp.FormatString(MsgHelp.ID.CMD_RUNNING, "Tag Diff"));

            TagDiffResult tagDiffResult = new TagDiffResult()
            {
                AppVersion = Utils.GetVersionString()
            };

            //save to quiet analyze cmd and restore
            WriteOnce.ConsoleVerbosity saveVerbosity = WriteOnce.Verbosity;

            try
            {
                #region setup analyze calls

                AnalyzeCommand cmd1 = new AnalyzeCommand(new AnalyzeOptions
                {
                    SourcePath            = _options.SourcePath1,
                    CustomRulesPath       = _options.CustomRulesPath,
                    IgnoreDefaultRules    = _options.IgnoreDefaultRules,
                    FilePathExclusions    = _options.FilePathExclusions,
                    ConsoleVerbosityLevel = "none",
                    Log = _options.Log
                });
                AnalyzeCommand cmd2 = new AnalyzeCommand(new AnalyzeOptions
                {
                    SourcePath            = _options.SourcePath2,
                    CustomRulesPath       = _options.CustomRulesPath,
                    IgnoreDefaultRules    = _options.IgnoreDefaultRules,
                    FilePathExclusions    = _options.FilePathExclusions,
                    ConsoleVerbosityLevel = "none",
                    Log = _options.Log
                });

                AnalyzeResult analyze1 = cmd1.GetResult();
                AnalyzeResult analyze2 = cmd2.GetResult();

                //restore
                WriteOnce.Verbosity = saveVerbosity;

                #endregion setup analyze calls

                bool equalTagsCompare1 = true;
                bool equalTagsCompare2 = true;

                //process results for each analyze call before comparing results
                if (analyze1.ResultCode == AnalyzeResult.ExitCode.CriticalError)
                {
                    throw new OpException(MsgHelp.FormatString(MsgHelp.ID.CMD_CRITICAL_FILE_ERR, _options.SourcePath1));
                }
                else if (analyze2.ResultCode == AnalyzeResult.ExitCode.CriticalError)
                {
                    throw new OpException(MsgHelp.FormatString(MsgHelp.ID.CMD_CRITICAL_FILE_ERR, _options.SourcePath2));
                }
                else if (analyze1.ResultCode == AnalyzeResult.ExitCode.NoMatches || analyze2.ResultCode == AnalyzeResult.ExitCode.NoMatches)
                {
                    throw new OpException(MsgHelp.GetString(MsgHelp.ID.TAGDIFF_NO_TAGS_FOUND));
                }
                else //compare tag results; assumed (result1&2 == AnalyzeCommand.ExitCode.Success)
                {
                    int      count1    = 0;
                    int      sizeTags1 = analyze1.Metadata.UniqueTags.Count;
                    string[] file1Tags = new string[sizeTags1];

                    foreach (string tag in analyze1.Metadata.UniqueTags.Keys.ToList <string>())
                    {
                        file1Tags[count1++] = tag;
                    }

                    int      count2    = 0;
                    int      sizeTags2 = analyze2.Metadata.UniqueTags.Count;
                    string[] file2Tags = new string[sizeTags2];

                    foreach (string tag in analyze2.Metadata.UniqueTags.Keys.ToList <string>())
                    {
                        file2Tags[count2++] = tag;
                    }

                    //can't simply compare counts as content may differ; must compare both in directions in two passes a->b; b->a
                    equalTagsCompare1 = CompareTags(file1Tags, file2Tags, ref tagDiffResult, TagDiff.DiffSource.Source1);

                    //reverse order for second pass
                    equalTagsCompare2 = CompareTags(file2Tags, file1Tags, ref tagDiffResult, TagDiff.DiffSource.Source2);

                    //final results
                    bool resultsDiffer = !(equalTagsCompare1 && equalTagsCompare2);
                    if (_arg_tagTestType == TagTestType.Inequality && !resultsDiffer)
                    {
                        tagDiffResult.ResultCode = TagDiffResult.ExitCode.TestFailed;
                    }
                    else if (_arg_tagTestType == TagTestType.Equality && resultsDiffer)
                    {
                        tagDiffResult.ResultCode = TagDiffResult.ExitCode.TestFailed;
                    }
                    else
                    {
                        tagDiffResult.ResultCode = TagDiffResult.ExitCode.TestPassed;
                    }
                }
            }
            catch (OpException e)
            {
                WriteOnce.Verbosity = saveVerbosity;
                WriteOnce.Error(e.Message);
                //caught for CLI callers with final exit msg about checking log or throws for DLL callers
                throw;
            }

            return(tagDiffResult);
        }