[mono-api-html] Prettier output using singular and plural forms in sections
authorSebastien Pouliot <sebastien@xamarin.com>
Tue, 6 May 2014 15:32:05 +0000 (11:32 -0400)
committerSebastien Pouliot <sebastien@xamarin.com>
Wed, 7 May 2014 00:20:25 +0000 (20:20 -0400)
mcs/tools/corcompare/mono-api-html/FieldComparer.cs
mcs/tools/corcompare/mono-api-html/MemberComparer.cs

index e727181e587defb6f89c10469cc3b0e136e5c7ec..3f34c4e859d561e6d0ef21a6eb67bb78011dcfbb 100644 (file)
@@ -2,7 +2,7 @@
 // Authors
 //    Sebastien Pouliot  <sebastien@xamarin.com>
 //
-// Copyright 2013 Xamarin Inc. http://www.xamarin.com
+// Copyright 2013-2014 Xamarin Inc. http://www.xamarin.com
 // 
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -25,6 +25,8 @@
 //
 
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using System.Reflection;
 using System.Text;
 using System.Xml.Linq;
@@ -82,20 +84,20 @@ namespace Xamarin.ApiDiff {
                        return sb.ToString ();
                }
 
-               public override void BeforeAdding ()
+               public override void BeforeAdding (IEnumerable<XElement> list)
                {
                        if (State.BaseType == "System.Enum")
-                               Output.WriteLine ("<p>Added values:</p><pre>");
+                               Output.WriteLine ("<p>Added value{0}:</p><pre>", list.Count () > 1 ? "s" : String.Empty);
                        else
-                               base.BeforeAdding ();
+                               base.BeforeAdding (list);
                }
 
-               public override void BeforeRemoving ()
+               public override void BeforeRemoving (IEnumerable<XElement> list)
                {
                        if (State.BaseType == "System.Enum")
-                               Output.WriteLine ("<p>Removed values:</p><pre>");
+                               Output.WriteLine ("<p>Removed value{0}:</p><pre>", list.Count () > 1 ? "s" : String.Empty);
                        else
-                               base.BeforeRemoving ();
+                               base.BeforeRemoving (list);
                }
        }
 }
\ No newline at end of file
index 5784c17f89ed36767c4831d489da76f5f206c47e..ac19741c1d9e78af3def116f63c26d01bc483871 100644 (file)
@@ -2,7 +2,7 @@
 // Authors
 //    Sebastien Pouliot  <sebastien@xamarin.com>
 //
-// Copyright 2013 Xamarin Inc. http://www.xamarin.com
+// Copyright 2013-2014 Xamarin Inc. http://www.xamarin.com
 // 
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -45,13 +45,15 @@ namespace Xamarin.ApiDiff {
                                return;
 
                        if (s == null) {
-                               BeforeAdding ();
-                               foreach (var item in t.Elements (ElementName))
+                               var items = t.Elements (ElementName);
+                               BeforeAdding (items);
+                               foreach (var item in items)
                                        Added (item);
                                AfterAdding ();
                        } else if (t == null) {
-                               BeforeRemoving ();
-                               foreach (var item in s.Elements (ElementName))
+                               var items = s.Elements (ElementName);
+                               BeforeRemoving (items);
+                               foreach (var item in items)
                                        Removed (item);
                                AfterRemoving ();
                        } else {
@@ -102,7 +104,7 @@ namespace Xamarin.ApiDiff {
                        foreach (var item in removed) {
                                SetContext (item);
                                if (!r) {
-                                       BeforeRemoving ();
+                                       BeforeRemoving (removed);
                                        r = true;
                                }
                                Removed (item);
@@ -116,7 +118,7 @@ namespace Xamarin.ApiDiff {
                                if (State.IgnoreAdded.Any (re => re.IsMatch (GetDescription (item))))
                                        continue;
                                if (!a) {
-                                       BeforeAdding ();
+                                       BeforeAdding (target);
                                        a = true;
                                }
                                Added (item);
@@ -131,7 +133,7 @@ namespace Xamarin.ApiDiff {
                                if (State.IgnoreAdded.Any (re => re.IsMatch (GetDescription (item))))
                                        continue;
                                if (!o) {
-                                       BeforeObsoleting ();
+                                       BeforeObsoleting (obsoleted);
                                        o = true;
                                }
                                Obsoleted (item);
@@ -149,7 +151,7 @@ namespace Xamarin.ApiDiff {
                        if (o != null) {
                                sb.Append ("[Obsolete");
                                if (o.Length > 0)
-                                       sb.Append (" \"").Append (o).Append ("\")");
+                                       sb.Append (" (\"").Append (o).Append ("\")");
                                sb.AppendLine ("]");
                                for (int i = 0; i < State.Indent + 1; i++)
                                        sb.Append ('\t');
@@ -173,9 +175,9 @@ namespace Xamarin.ApiDiff {
                        return (s.Length == 0 && t.Length > 0);
                }
 
-               public virtual void BeforeAdding ()
+               public virtual void BeforeAdding (IEnumerable<XElement> list)
                {
-                       Output.WriteLine ("<p>Added {0}:</p><pre>", GroupName);
+                       Output.WriteLine ("<p>Added {0}:</p><pre>", list.Count () > 1 ? GroupName : ElementName);
                }
 
                public override void Added (XElement target)
@@ -188,9 +190,9 @@ namespace Xamarin.ApiDiff {
                        Output.WriteLine ("</pre>");
                }
 
-               public virtual void BeforeObsoleting ()
+               public virtual void BeforeObsoleting (IEnumerable<XElement> list)
                {
-                       Output.WriteLine ("<p>Obsoleted {0}:</p><pre>", GroupName);
+                       Output.WriteLine ("<p>Obsoleted {0}:</p><pre>", list.Count () > 1 ? GroupName : ElementName);
                }
 
                public void Obsoleted (XElement target)
@@ -207,9 +209,9 @@ namespace Xamarin.ApiDiff {
                {
                }
 
-               public virtual void BeforeRemoving ()
+               public virtual void BeforeRemoving (IEnumerable<XElement> list)
                {
-                       Output.WriteLine ("<p>Removed {0}:</p><pre>", GroupName);
+                       Output.WriteLine ("<p>Removed {0}:</p><pre>", list.Count () > 1 ? GroupName : ElementName);
                }
 
                public override void Removed (XElement source)