void WriteOut(TypeDiff typeDiff, StringBuilder sb) { var missingFields = typeDiff.GetMissingFields() .Select(t => FormatFields(t.Item1, t.Item2)) .ToList(); var missingMethods = typeDiff.GetMissingMethods() .Select(t => FormatMethods(t.Item1, t.Item2)) .ToList(); if (missingFields.Any() || missingMethods.Any()) { sb.AppendLine("- " + typeDiff.LeftType.GetName()); foreach (var missingField in missingFields) { sb.AppendLine(" - " + missingField); } foreach (var missingMethod in missingMethods) { sb.AppendLine(" - " + missingMethod); } sb.AppendLine(); } }
static IEnumerable<object> BuildMethodsRemoved(TypeDiff typeDiff) { foreach (var method in typeDiff.PublicMethodsRemoved()) { yield return new { name = method.GetName() }; } }
public static bool HasDifferences(this TypeDiff typeDiff) { return (typeDiff.PublicFieldsRemoved().Any() || typeDiff.PublicMethodsRemoved().Any() || typeDiff.FieldsChangedToNonPublic().Any() || typeDiff.MethodsChangedToNonPublic().Any() || typeDiff.PublicMethodsObsoleted().Any() || typeDiff.PublicFieldsObsoleted().Any() || typeDiff.EnumFieldsWithChangedValue().Any() || typeDiff.TypeObsoleted()); }
void WriteOut(TypeDiff typeDiff, TextWriter writer, FormattingInfo info) { var typeObsoleted = typeDiff.TypeObsoleted(); writer.WriteLine(); writer.Write("### {0}", HttpUtility.HtmlEncode(typeDiff.RightType.GetName())); if (typeObsoleted) { writer.Write("(Obsoleted)"); } writer.WriteLine(); if (typeObsoleted) { writer.WriteLine(typeDiff.RightType.GetObsoleteString()); } WriteFields(typeDiff, writer); WriteMethods(typeDiff, writer, info); writer.WriteLine(); }
void WriteFields(TypeDiff typeDiff, TextWriter writer) { var changedToNonPublic = typeDiff.FieldsChangedToNonPublic().ToList(); if (changedToNonPublic.Any()) { writer.WriteLine(); writer.WriteLine("#### Fields changed to non-public"); writer.WriteLine(); foreach (var field in changedToNonPublic) { writer.WriteLine(" - `{0}`", field.Right.GetName()); } } var removed = typeDiff.PublicFieldsRemoved().ToList(); if (removed.Any()) { writer.WriteLine(); writer.WriteLine("#### Fields Removed"); writer.WriteLine(); foreach (var field in removed) { writer.WriteLine(" - `{0}`", field.GetName()); } } var obsoleted = typeDiff.PublicFieldsObsoleted().ToList(); if (obsoleted.Any()) { writer.WriteLine(); writer.WriteLine("#### Fields Obsoleted"); writer.WriteLine(); foreach (var field in obsoleted) { writer.WriteLine(" - `{0}`: {1}", field.Right.GetName(), field.Right.GetObsoleteString()); } } }
void WriteMethods(TypeDiff typeDiff, TextWriter writer, FormattingInfo info) { var changedToNonPublic = typeDiff.MethodsChangedToNonPublic().ToList(); if (changedToNonPublic.Any()) { writer.WriteLine(); writer.WriteLine("#### Methods changed to non-public"); writer.WriteLine(); foreach (var method in changedToNonPublic) { writer.WriteLine(" - `{0}`", method.Left.GetName()); } } var removed = typeDiff.PublicMethodsRemoved().ToList(); if (removed.Any()) { writer.WriteLine(); writer.WriteLine("#### Methods Removed"); writer.WriteLine(); foreach (var method in removed) { writer.WriteLine(" - `{0}`", method.GetName()); } } var obsoleted = typeDiff.PublicMethodsObsoleted().ToList(); if (obsoleted.Any()) { writer.WriteLine(); writer.WriteLine("#### Methods Obsoleted"); writer.WriteLine(); foreach (var method in obsoleted) { writer.WriteLine(" - `{0}`: {1}", method.Right.GetName(), method.Right.GetObsoleteString()); } } }
void WriteOut(TypeDiff typeDiff, TextWriter writer, FormattingInfo info) { writer.WriteLine(); var links = CreateLinks(typeDiff.LeftType.GetValidSequencePoint(), typeDiff.RightType.GetValidSequencePoint(), info); writer.Write("### {0} {1}", HttpUtility.HtmlEncode(typeDiff.RightType.GetName()), links); writer.WriteLine(); WriteFields(typeDiff, writer); WriteMethods(typeDiff, writer, info); writer.WriteLine(); }
void WriteMethods(TypeDiff typeDiff, TextWriter writer, FormattingInfo info) { var changedToNonPublic = typeDiff.MethodsChangedToNonPublic().ToList(); if (changedToNonPublic.Any()) { writer.WriteLine(); writer.WriteLine("#### Methods changed to non-public"); writer.WriteLine(); foreach (var method in changedToNonPublic) { var leftSP = method.Left.GetValidSequencePoint(); var rightSP = method.Right.GetValidSequencePoint(); writer.WriteLine(" - `{0}` {1}", method.Left.GetName(), CreateLinks(leftSP, rightSP, info)); } } //var added = typeDiff.RightOrphanMethods.ToList(); //if (added.Any()) //{ // writer.WriteLine(); // writer.WriteLine("#### Methods Added"); // writer.WriteLine(); // foreach (var method in added) // { // var sequencePoint = method.GetValidSequencePoint(); // writer.WriteLine(string.Format(" - {0} {1}", method.HtmlEncodedName(), CreateLinks(null, sequencePoint, 2))); // } //} var removed = typeDiff.PublicMethodsRemoved().ToList(); if (removed.Any()) { writer.WriteLine(); writer.WriteLine("#### Methods Removed"); writer.WriteLine(); foreach (var method in removed) { var sequencePoint = method.GetValidSequencePoint(); writer.WriteLine(" - `{0}` {1}", method.GetName(), CreateLeftLink(sequencePoint, info)); } } }
void WriteFields(TypeDiff typeDiff, TextWriter writer) { var changedToNonPublic = typeDiff.FieldsChangedToNonPublic().ToList(); if (changedToNonPublic.Any()) { writer.WriteLine(); writer.WriteLine("#### Fields changed to non-public"); writer.WriteLine(); foreach (var field in changedToNonPublic) { writer.WriteLine(" - `{0}`", field.Right.GetName()); } } //var added = typeDiff.RightOrphanFields.ToList(); //if (added.Any()) //{ // writer.WriteLine(); // writer.WriteLine("#### Fields Added"); // writer.WriteLine(); // foreach (var field in added) // { // writer.WriteLine(" - " + field.HtmlEncodedName()); // } //} var removed = typeDiff.PublicFieldsRemoved().ToList(); if (removed.Any()) { writer.WriteLine(); writer.WriteLine("#### Fields Removed"); writer.WriteLine(); foreach (var field in removed) { writer.WriteLine(" - `{0}`", field.GetName()); } } }
static IEnumerable<object> BuildMethodsObsoleted(TypeDiff typeDiff) { foreach (var method in typeDiff.PublicMethodsObsoleted()) { yield return new { name = method.Right.GetName(), obsolete = method.Right.GetObsoleteString() }; } }
static IEnumerable<object> BuildFieldsChangedToNonPublic(TypeDiff typeDiff) { foreach (var field in typeDiff.FieldsChangedToNonPublic()) { yield return new { name = field.Right.GetName() }; } }
static IEnumerable<object> BuildFieldsRemoved(TypeDiff typeDiff) { foreach (var field in typeDiff.PublicFieldsRemoved()) { yield return new { name = field.GetName() }; } }
static IEnumerable<object> BuildMethodsChangedToNonPublic(TypeDiff typeDiff) { foreach (var method in typeDiff.MethodsChangedToNonPublic()) { yield return new { name = method.Left.GetName() }; } }