Esempio n. 1
0
        public override void VisitMemberNode(MemberNode node)
        {
            if (node.DifferenceDecoration == DifferenceDecoration.NoDifferences)
            {
                return;
            }

            SourceText oldSourceText = null, newSourceText = null;

            if (IncludeSourceCode)
            {
                var oldSource = node.OldSource;
                if (oldSource != null)
                {
                    oldSourceText = new SourceText(oldSource, _shaUtility.ComputeHashAsString(oldSource));
                }

                var newSource = node.NewSource;
                if (newSource != null)
                {
                    newSourceText = new SourceText(newSource, _shaUtility.ComputeHashAsString(newSource));
                }
            }

            Change change = new MemberChange(
                node.Namespace,
                node.Name,
                node.DifferenceDecoration,
                oldSourceText,
                newSourceText);

            if (_ignoreChangeSet.Contains(change))
            {
                return;
            }

            _changeSetBuilder.AddChange(change);
        }
Esempio n. 2
0
        private void copyAsXmlButton_Click(object sender, EventArgs args)
        {
            Change[] changes;
            if (IgnoredChangesListBox.SelectedItems.Count > 0)
            {
                changes = IgnoredChangesListBox.SelectedItems
                          .Cast <ChangeEntry>()
                          .Select(e => e.Change)
                          .ToArray();
            }
            else
            {
                changes = IgnoredChangesListBox.Items
                          .Cast <ChangeEntry>()
                          .Select(e => e.Change)
                          .ToArray();
            }

            if (changes.Length == 0)
            {
                return;
            }

            var includeOld = includeOldSourceCheckbox.Checked;
            var includeNew = includeNewSourceCheckbox.Checked;

            if (!includeOld || !includeNew)
            {
                using (var shaUtility = new ShaUtility(SHA256.Create()))
                {
                    changes = changes.Select(
                        e =>
                    {
                        if (!(e is MemberChange))
                        {
                            return(e);
                        }

                        var memberChange = (MemberChange)e.Clone();

                        var oldSource = memberChange.OldSource;
                        if (!includeOld && oldSource != null)
                        {
                            if (oldSource.Hash == null)
                            {
                                oldSource.Hash = shaUtility.ComputeHashAsString(oldSource.Text);
                            }

                            oldSource.Text = null;
                        }

                        var newSource = memberChange.NewSource;
                        if (!includeNew && newSource != null)
                        {
                            if (newSource.Hash == null)
                            {
                                newSource.Hash = shaUtility.ComputeHashAsString(newSource.Text);
                            }

                            newSource.Text = null;
                        }

                        return(memberChange);
                    }).ToArray();
                }
            }

            var changeSet     = new ChangeSet(changes);
            var xmlSerializer = new XmlSerializer(typeof(ChangeSet));

            using (var stringWriter = new StringWriter())
            {
                xmlSerializer.Serialize(stringWriter, changeSet);

                var result = stringWriter.ToString();
                var parts  = result.Split(
                    new[]
                {
                    Environment.NewLine
                },
                    StringSplitOptions.None).ToArray();


                Clipboard.SetText(string.Join(Environment.NewLine, parts.Skip(3).Take(parts.Length - 5)));
            }
        }