[mono/mono] [2 commits] 93399696: [mono-api-html] Do not produce (near-)empty files when no (public) changes are detected

"Sebastien Pouliot ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141a24921f4-005e5260-9c39-45fd-aee7-98190271e6f9-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/mono
  Compare: https://github.com/mono/mono/compare/66d4b82a8716...8113f9b2379f

   Commit: 93399696e02775cb17c635e95782602377cb367b
   Author: Sebastien Pouliot <[email protected]> (spouliot)
     Date: 2013-10-10 12:12:13 GMT
      URL: https://github.com/mono/mono/commit/93399696e02775cb17c635e95782602377cb367b

[mono-api-html] Do not produce (near-)empty files when no (public) changes are detected

Changed paths:
  M mcs/tools/corcompare/mono-api-html/ApiDiff.cs
  M mcs/tools/corcompare/mono-api-html/AssemblyComparer.cs

Modified: mcs/tools/corcompare/mono-api-html/ApiDiff.cs
===================================================================
@@ -69,9 +69,27 @@ public static int Main (string[] args)
 				string input = args [0];
 				string output = args [1];
 				var ac = new AssemblyComparer (input, output);
-				if (args.Length > 2)
-					State.Output = new StreamWriter (args [2]); 
-				ac.Compare ();
+				if (args.Length > 2) {
+					string diff = String.Empty;
+					using (var writer = new StringWriter ()) {
+						State.Output = writer;
+						ac.Compare ();
+						diff = State.Output.ToString ();
+					}
+					if (diff.Length > 0) {
+						using (var file = new StreamWriter (args [2])) {
+							if (ac.SourceAssembly == ac.TargetAssembly) {
+								file.WriteLine ("<h1>{0}.dll</h1>", ac.SourceAssembly);
+							} else {
+								file.WriteLine ("<h1>{0}.dll vs {1}.dll</h1>", ac.SourceAssembly, ac.TargetAssembly);
+							}
+							file.Write (diff);
+						}
+					}
+				} else {
+					State.Output = Console.Out;
+					ac.Compare ();
+				}
 			}
 			catch (Exception e) {
 				Console.WriteLine (e);

Modified: mcs/tools/corcompare/mono-api-html/AssemblyComparer.cs
===================================================================
@@ -42,16 +42,18 @@ public AssemblyComparer (string sourceFile, string targetFile)
 			comparer =  new NamespaceComparer ();
 		}
 
+		public string SourceAssembly { get; private set; }
+		public string TargetAssembly { get; private set; }
+
 		public void Compare ()
 		{
 			Compare (source.Element ("assemblies").Elements ("assembly"), 
 			         target.Element ("assemblies").Elements ("assembly"));
-			Output.Flush ();
 		}
 
 		public override void SetContext (XElement current)
 		{
-			State.Assembly = current.Attribute ("name").Value;
+			State.Assembly = current.GetAttribute ("name");
 		}
 
 		public override void Added (XElement target)
@@ -61,7 +63,8 @@ public override void Added (XElement target)
 
 		public override void Modified (XElement source, XElement target)
 		{
-			Output.WriteLine ("<h1>{0}.dll</h1>", source.Attribute ("name").Value);
+			SourceAssembly = source.GetAttribute ("name");
+			TargetAssembly = target.GetAttribute ("name");
 			// TODO: version
 			// ? custom attributes ?
 			comparer.Compare (source, target);

   Commit: 8113f9b2379f2d2b3e153247006f64c249d00166
   Author: Sebastien Pouliot <[email protected]> (spouliot)
     Date: 2013-10-10 12:12:13 GMT
      URL: https://github.com/mono/mono/commit/8113f9b2379f2d2b3e153247006f64c249d00166

[mono-api-html] Output C# 'char' instead of 'System.Char'

Changed paths:
  M mcs/tools/corcompare/mono-api-html/Helpers.cs

Modified: mcs/tools/corcompare/mono-api-html/Helpers.cs
===================================================================
@@ -118,6 +118,8 @@ static string GetTypeName (string type)
 				return "short";
 			case "System.UInt16":
 				return "ushort";
+			case "System.Char":
+				return "char";
 			default:
 				if (type.StartsWith (State.Namespace, StringComparison.Ordinal))
 					type = type.Substring (State.Namespace.Length + 1);


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.