예제 #1
0
        private static IStyleSyntaxWriter GetExportWriter(DiffFormat format, TextWriter textWriter, bool strikeOutRemoved)
        {
            switch (format)
            {
            case DiffFormat.Csv:
                return(null);

            case DiffFormat.Html:
                return(new HtmlSyntaxWriter(textWriter)
                {
                    StrikeOutRemoved = strikeOutRemoved
                });

            case DiffFormat.WordXml:
                return(new OpenXmlSyntaxWriter(textWriter));

            case DiffFormat.Text:
                return(new TextSyntaxWriter(textWriter));

            case DiffFormat.UnifiedDiff:
                return(new UnifiedDiffSyntaxWriter(textWriter));

            default:
                throw new ArgumentOutOfRangeException("format");
            }
        }
예제 #2
0
        private static ICciDifferenceWriter CreateExportWriter(DiffFormat format, TextWriter textWriter, DiffConfiguration configuration, IStyleSyntaxWriter writer, IEnumerable <DiffComment> diffComments)
        {
            var mappingSettings   = GetMappingSettings(configuration);
            var includeAttributes = configuration.IsOptionSet(DiffConfigurationOptions.DiffAttributes);

            switch (format)
            {
            case DiffFormat.Csv:
                var diffColumns   = DiffCsvColumn.CreateStandardColumns(configuration).Where(c => c.IsVisible).ToArray();
                var csvTextWriter = new CsvTextWriter(textWriter);
                csvTextWriter.WriteLine(diffColumns.Select(c => c.Name));
                return(new DiffCsvWriter(csvTextWriter, mappingSettings, diffColumns, CancellationToken.None));

            case DiffFormat.Html:
                return(new DiffCSharpWriter(writer, mappingSettings, diffComments, includeAttributes)
                {
                    IncludeAssemblyProperties = configuration.IsOptionSet(DiffConfigurationOptions.DiffAssemblyInfo),
                    HighlightBaseMembers = configuration.IsOptionSet(DiffConfigurationOptions.HighlightBaseMembers)
                });

            case DiffFormat.WordXml:
            case DiffFormat.Text:
            case DiffFormat.UnifiedDiff:
                return(new DiffCSharpWriter(writer, mappingSettings, diffComments, includeAttributes)
                {
                    IncludeAssemblyProperties = configuration.IsOptionSet(DiffConfigurationOptions.DiffAssemblyInfo),
                    HighlightBaseMembers = configuration.IsOptionSet(DiffConfigurationOptions.HighlightBaseMembers)
                });

            default:
                throw new ArgumentOutOfRangeException("format");
            }
        }
예제 #3
0
        public void OnExecute()
        {
            if (string.IsNullOrEmpty(NewSet))
            {
                // Reset the filter to be unchanged if we only have a single set so that it will
                // simply output the contents of the set.
                Removed   = Added = false;
                Unchanged = true;
            }

            if (!Added && !Removed && !Changed && !Unchanged)
            {
                // If the user didn't explicitly specify what to include we default to changes only.
                Added = Removed = Changed = true;
            }

            DiffConfigurationOptions options = GetDiffOptions();
            DiffFormat diffFormat            = GetDiffFormat();

            AssemblySet oldAssemblies = AssemblySet.FromPaths(OldSet);
            AssemblySet newAssemblies = AssemblySet.FromPaths(NewSet);

            DiffConfiguration diffConfiguration = new DiffConfiguration(oldAssemblies, newAssemblies, options);

            using (TextWriter output = GetOutput())
                DiffEngine.Export(diffConfiguration, null, diffFormat, output);
        }
예제 #4
0
        public void OnExecute()
        {
            if (string.IsNullOrEmpty(NewSet))
            {
                // Reset the filter to be unchanged if we only have a single set so that it will
                // simply output the contents of the set.
                Removed   = Added = false;
                Unchanged = true;
            }

            if (!Added && !Removed && !Changed && !Unchanged)
            {
                // If the user didn't explicitly specify what to include we default to changes only.
                Added = Removed = Changed = true;
            }

            if (!string.IsNullOrEmpty(Language))
            {
                var cultureInfo = System.Globalization.CultureInfo.GetCultureInfo(Language);
                Thread.CurrentThread.CurrentCulture   = cultureInfo;
                Thread.CurrentThread.CurrentUICulture = cultureInfo;
            }

            DiffConfigurationOptions options = GetDiffOptions();
            DiffFormat diffFormat            = GetDiffFormat();

            AssemblySet oldAssemblies = AssemblySet.FromPaths(OldSetName, OldSet);
            AssemblySet newAssemblies = AssemblySet.FromPaths(NewSetName, NewSet);

            DiffConfiguration diffConfiguration = new DiffConfiguration(oldAssemblies, newAssemblies, options);

            if (diffFormat == DiffFormat.Md)
            {
                DiffDocument diffDocument         = DiffEngine.BuildDiffDocument(diffConfiguration);
                var          markdownDiffExporter = new MarkdownDiffExporter(diffDocument, OutFile, IncludeTableOfContents, CreateFilePerNamespace);
                markdownDiffExporter.Export();
            }
            else
            {
                using (TextWriter output = GetOutput())
                    DiffEngine.Export(diffConfiguration, null, diffFormat, output);
            }
        }
예제 #5
0
        public static void Export(DiffConfiguration configuration, IEnumerable <DiffComment> diffComments, DiffFormat format, TextWriter streamWriter)
        {
            var strikeOutRemoved = configuration.IsOptionSet(DiffConfigurationOptions.StrikeRemoved);

            using (var syntaxWriter = GetExportWriter(format, streamWriter, strikeOutRemoved))
            {
                var writer = CreateExportWriter(format, streamWriter, configuration, syntaxWriter, diffComments);
                WriteDiff(configuration, writer);
            }
        }