Пример #1
0
 static IEnumerable<object> BuildTypeDifferences(Diff diff)
 {
     return from typeDiff in diff.MatchingTypeDiffs
            where typeDiff.LeftType.IsPublic
            where typeDiff.RightType.IsPublic
            where typeDiff.HasDifferences()
            let fieldsChangedToNonPublic = BuildFieldsChangedToNonPublic(typeDiff)
            let fieldsRemoved = BuildFieldsRemoved(typeDiff)
            let fieldsObsoleted = BuildFieldsObsoleted(typeDiff)
            let methodsChangedToNonPublic = BuildMethodsChangedToNonPublic(typeDiff)
            let methodsRemoved = BuildMethodsRemoved(typeDiff)
            let methodsObsoleted = BuildMethodsObsoleted(typeDiff)
            let hasBeenObsoleted = !typeDiff.LeftType.HasObsoleteAttribute() && typeDiff.RightType.HasObsoleteAttribute() 
            select new
            {
                name = typeDiff.RightType.GetName(),
                hasBeenObsoleted,
                obsoleteMessage = hasBeenObsoleted ? typeDiff.RightType.GetObsoleteString() : "",
                hasFieldsChangedToNonPublic = fieldsChangedToNonPublic.Any(),
                fieldsChangedToNonPublic,
                hasFieldsObsoleted = fieldsObsoleted.Any(),
                fieldsObsoleted,
                hasFieldsRemoved = fieldsRemoved.Any(),
                fieldsRemoved,
                hasMethodsChangedToNonPublic = methodsChangedToNonPublic.Any(),
                methodsChangedToNonPublic,
                hasMethodsRemoved = methodsRemoved.Any(),
                methodsRemoved,
                hasMethodsObsoleted = methodsObsoleted.Any(),
                methodsObsoleted,
            };
 }
        public void WriteOut(Diff diff, TextWriter writer, FormattingInfo info)
        {
            if (diff is EmptyDiff)
            {
                writer.WriteLine("No longer supported");
                return;
            }

            var removePublicTypes = diff.RemovedPublicTypes().ToList();
            if (removePublicTypes.Any())
            {
                writer.WriteLine();
                writer.WriteLine("## The following public types have been removed.");
                writer.WriteLine();
                foreach (var type in removePublicTypes)
                {
                    writer.WriteLine("- `{0}`", type.GetName());
                }
                writer.WriteLine();
            }
            var typesChangedToNonPublic = diff.TypesChangedToNonPublic().ToList();
            if (typesChangedToNonPublic.Any())
            {
                writer.WriteLine();
                writer.WriteLine("## The following public types have been made internal.");
                writer.WriteLine();
                foreach (var type in typesChangedToNonPublic)
                {
                    writer.WriteLine("- `{0}`", type.RightType.GetName());
                }
                writer.WriteLine();
            }

            var matchingTypeDiffs = diff.MatchingTypeDiffs.ToList();
            if (matchingTypeDiffs.Any())
            {
                writer.WriteLine();
                writer.WriteLine("## The following types have differences.");
                writer.WriteLine();
                foreach (var typeDiff in diff.MatchingTypeDiffs)
                {
                    if (!typeDiff.LeftType.IsPublic)
                    {
                        continue;
                    }
                    if (!typeDiff.RightType.IsPublic)
                    {
                        continue;
                    }
                    if (typeDiff.HasDifferences())
                    {
                        WriteOut(typeDiff, writer, info);
                    }
                }
            }
        }
Пример #3
0
 static IEnumerable<object> BuildRemovedPublicTypes(Diff diff)
 {
     foreach (var definition in diff.RemovedPublicTypes())
     {
         yield return new
         {
             name = definition.GetName()
         };
     }
 }
Пример #4
0
 static IEnumerable<object> BuildTypesMadeInternal(Diff diff)
 {
     foreach (var typeDiff in diff.TypesChangedToNonPublic())
     {
         yield return new
         {
             name = typeDiff.RightType.GetName()
         };
     }
 }
Пример #5
0
        public void WriteOut(Diff diff)
        {
            stringBuilder.Clear();

            WriteOut(diff, stringBuilder);
        }