Exemple #1
0
        public static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("mono-api-html reference.xml assembly.xml [diff.html]");
                return(1);
            }

            try {
                string input  = args [0];
                string output = args [1];
                var    ac     = new AssemblyComparer(input, output);
                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);
                return(1);
            }
            return(0);
        }
Exemple #2
0
		public static int Main (string[] args)
		{
			if (args.Length < 2) {
				Console.WriteLine ("mono-api-html reference.xml assembly.xml [diff.html]");
				return 1;
			}

			try {
				string input = args [0];
				string output = args [1];
				var ac = new AssemblyComparer (input, output);
				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);
				return 1;
			}
			return 0;
		}
Exemple #3
0
        public static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("mono-api-html reference.xml assembly.xml [diff.html]");
                return(1);
            }

            try {
                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();
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(1);
            }
            return(0);
        }
Exemple #4
0
		public static int Main (string[] args)
		{
			var showHelp = false;
			string diff = null;
			List<string> extra = null;

			var options = new OptionSet {
				{ "h|help", "Show this help", v => showHelp = true },
				{ "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
				{ "i|ignore=", "Ignore new, added, and removed members whose description matches a given C# regular expression (see below).",
					v => {
						var r = new Regex (v);
						State.IgnoreAdded.Add (r);
						State.IgnoreRemoved.Add (r);
						State.IgnoreNew.Add (r);
					}
				},
				{ "a|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
					v => State.IgnoreAdded.Add (new Regex (v))
				},
				{ "r|ignore-removed=", "Ignore removed members whose description matches a given C# regular expression (see below).",
					v => State.IgnoreRemoved.Add (new Regex (v))
				},
				{ "n|ignore-new=", "Ignore new namespaces and types whose description matches a given C# regular expression (see below).",
					v => State.IgnoreNew.Add (new Regex (v))
				},
				{ "ignore-changes-parameter-names", "Ignore changes to parameter names for identically prototyped methods.",
					v => State.IgnoreParameterNameChanges   = v != null
				},
				{ "ignore-changes-property-setters", "Ignore adding setters to properties.",
					v => State.IgnoreAddedPropertySetters = v != null
				},
				{ "ignore-changes-virtual", "Ignore changing non-`virtual` to `virtual` or adding `override`.",
					v => State.IgnoreVirtualChanges = v != null
				},
				{ "c|colorize:", "Colorize HTML output", v => State.Colorize = string.IsNullOrEmpty (v) ? true : bool.Parse (v) },
				{ "x|lax", "Ignore duplicate XML entries", v => State.Lax = true },
				{ "ignore-nonbreaking", "Ignore all nonbreaking changes", v => State.IgnoreNonbreaking = true }
			};

			try {
				extra = options.Parse (args);
			} catch (OptionException e) {
				Console.WriteLine ("Option error: {0}", e.Message);
				showHelp = true;
			}

			if (State.IgnoreNonbreaking) {
				State.IgnoreAddedPropertySetters = true;
				State.IgnoreVirtualChanges = true;
				State.IgnoreNew.Add (new Regex (".*"));
				State.IgnoreAdded.Add (new Regex (".*"));
			}

			if (showHelp || extra == null || extra.Count < 2 || extra.Count > 3) {
				Console.WriteLine (@"Usage: mono-api-html [options] <reference.xml> <assembly.xml> [diff.html]");
				Console.WriteLine ();
				Console.WriteLine ("Available options:");
				options.WriteOptionDescriptions (Console.Out);
				Console.WriteLine ();
				Console.WriteLine ("Ignoring Members:");
				Console.WriteLine ();
				Console.WriteLine ("  Members that were added can be filtered out of the diff by using the");
				Console.WriteLine ("  -i, --ignore-added option. The option takes a C# regular expression");
				Console.WriteLine ("  to match against member descriptions. For example, to ignore the");
				Console.WriteLine ("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
				Console.WriteLine ("  pass the following to mono-api-html:");
				Console.WriteLine ();
				Console.WriteLine ("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
				Console.WriteLine ();
				Console.WriteLine ("  The regular expressions will match any member description ending with");
				Console.WriteLine ("  'INSCopying' or 'INSCoding'.");
				Console.WriteLine ();
				return 1;
			}

			var input = extra [0];
			var output = extra [1];
			if (extra.Count == 3 && diff == null)
				diff = extra [2];

			try {
				var ac = new AssemblyComparer (input, output);
				if (diff != null) {
					string diffHtml = String.Empty;
					using (var writer = new StringWriter ()) {
						State.Output = writer;
						ac.Compare ();
						diffHtml = State.Output.ToString ();
					}
					if (diffHtml.Length > 0) {
						using (var file = new StreamWriter (diff)) {
							file.WriteLine ("<div>");
							if (State.Colorize) {
								file.WriteLine ("<style scoped>");
								file.WriteLine ("\t.obsolete { color: gray; }");
								file.WriteLine ("\t.added { color: green; }");
								file.WriteLine ("\t.removed-inline { text-decoration: line-through; }");
								file.WriteLine ("\t.removed-breaking-inline { color: red;}");
								file.WriteLine ("\t.added-breaking-inline { text-decoration: underline; }");
								file.WriteLine ("\t.nonbreaking { color: black; }");
								file.WriteLine ("\t.breaking { color: red; }");
								file.WriteLine ("</style>");
							}
							file.WriteLine (
@"<script type=""text/javascript"">
	// Only some elements have 'data-is-[non-]breaking' attributes. Here we
	// iterate over all descendents elements, and set 'data-is-[non-]breaking'
	// depending on whether there are any descendents with that attribute.
	function propagateDataAttribute (element)
	{
		if (element.hasAttribute ('data-is-propagated'))
			return;

		var i;
		var any_breaking = element.hasAttribute ('data-is-breaking');
		var any_non_breaking = element.hasAttribute ('data-is-non-breaking');
		for (i = 0; i < element.children.length; i++) {
			var el = element.children [i];
			propagateDataAttribute (el);
			any_breaking |= el.hasAttribute ('data-is-breaking');
			any_non_breaking |= el.hasAttribute ('data-is-non-breaking');
		}
		
		if (any_breaking)
			element.setAttribute ('data-is-breaking', null);
		else if (any_non_breaking)
			element.setAttribute ('data-is-non-breaking', null);
		element.setAttribute ('data-is-propagated', null);
	}

	function hideNonBreakingChanges ()
	{
		var topNodes = document.querySelectorAll ('[data-is-topmost]');
		var n;
		var i;
		for (n = 0; n < topNodes.length; n++) {
			propagateDataAttribute (topNodes [n]);
			var elements = topNodes [n].querySelectorAll ('[data-is-non-breaking]');
			for (i = 0; i < elements.length; i++) {
				var el = elements [i];
				if (!el.hasAttribute ('data-original-display'))
					el.setAttribute ('data-original-display', el.style.display);
				el.style.display = 'none';
			}
		}
		
		var links = document.getElementsByClassName ('hide-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = 'none';
		links = document.getElementsByClassName ('restore-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = '';
	}

	function showNonBreakingChanges ()
	{
		var elements = document.querySelectorAll ('[data-original-display]');
		var i;
		for (i = 0; i < elements.length; i++) {
			var el = elements [i];
			el.style.display = el.getAttribute ('data-original-display');
		}

		var links = document.getElementsByClassName ('hide-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = '';
		links = document.getElementsByClassName ('restore-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = 'none';
	}
</script>");
							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);
							}
							if (!State.IgnoreNonbreaking) {
								file.WriteLine ("<a href='javascript: hideNonBreakingChanges (); ' class='hide-nonbreaking'>Hide non-breaking changes</a>");
								file.WriteLine ("<a href='javascript: showNonBreakingChanges (); ' class='restore-nonbreaking' style='display: none;'>Show non-breaking changes</a>");
								file.WriteLine ("<br/>");
							}
							file.WriteLine ("<div data-is-topmost>");
							file.Write (diffHtml);
							file.WriteLine ("</div> <!-- end topmost div -->");
							file.WriteLine ("</div>");
						}
					}
				} else {
					State.Output = Console.Out;
					ac.Compare ();
				}
			}
			catch (Exception e) {
				Console.WriteLine (e);
				return 1;
			}
			return 0;
		}
Exemple #5
0
		public static int Main (string[] args)
		{
			var showHelp = false;
			string diff = null;
			List<string> extra = null;

			var options = new OptionSet {
				{ "h|help", "Show this help", v => showHelp = true },
				{ "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
				{ "i|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
					v => State.IgnoreAdded.Add (new Regex (v))
				}
			};

			try {
				extra = options.Parse (args);
			} catch (OptionException e) {
				Console.WriteLine ("Option error: {0}", e.Message);
				showHelp = true;
			}

			if (showHelp || extra == null || extra.Count < 2 || extra.Count > 3) {
				Console.WriteLine (@"Usage: mono-api-html [options] <reference.xml> <assembly.xml> [diff.html]");
				Console.WriteLine ();
				Console.WriteLine ("Available options:");
				options.WriteOptionDescriptions (Console.Out);
				Console.WriteLine ();
				Console.WriteLine ("Ignoring Members:");
				Console.WriteLine ();
				Console.WriteLine ("  Members that were added can be filtered out of the diff by using the");
				Console.WriteLine ("  -i, --ignore-added option. The option takes a C# regular expression");
				Console.WriteLine ("  to match against member descriptions. For example, to ignore the");
				Console.WriteLine ("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
				Console.WriteLine ("  pass the following to mono-api-html:");
				Console.WriteLine ();
				Console.WriteLine ("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
				Console.WriteLine ();
				Console.WriteLine ("  The regular expressions will match any member description ending with");
				Console.WriteLine ("  'INSCopying' or 'INSCoding'.");
				Console.WriteLine ();
				return 1;
			}

			var input = extra [0];
			var output = extra [1];
			if (extra.Count == 3 && diff == null)
				diff = extra [2];

			try {
				var ac = new AssemblyComparer (input, output);
				if (diff != null) {
					string diffHtml = String.Empty;
					using (var writer = new StringWriter ()) {
						State.Output = writer;
						ac.Compare ();
						diffHtml = State.Output.ToString ();
					}
					if (diffHtml.Length > 0) {
						using (var file = new StreamWriter (diff)) {
							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 (diffHtml);
						}
					}
				} else {
					State.Output = Console.Out;
					ac.Compare ();
				}
			}
			catch (Exception e) {
				Console.WriteLine (e);
				return 1;
			}
			return 0;
		}
        public static int Main(string[] args)
        {
            var           showHelp = false;
            string        diff     = null;
            List <string> extra    = null;

            var options = new OptionSet {
                { "h|help", "Show this help", v => showHelp = true },
                { "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
                { "i|ignore=", "Ignore new, added, and removed members whose description matches a given C# regular expression (see below).",
                  v => {
                      var r = new Regex(v);
                      State.IgnoreAdded.Add(r);
                      State.IgnoreRemoved.Add(r);
                      State.IgnoreNew.Add(r);
                  } },
                { "a|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreAdded.Add(new Regex(v)) },
                { "r|ignore-removed=", "Ignore removed members whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreRemoved.Add(new Regex(v)) },
                { "n|ignore-new=", "Ignore new namespaces and types whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreNew.Add(new Regex(v)) },
                { "ignore-changes-parameter-names", "Ignore changes to parameter names for identically prototyped methods.",
                  v => State.IgnoreParameterNameChanges = v != null },
                { "ignore-changes-property-setters", "Ignore adding setters to properties.",
                  v => State.IgnoreAddedPropertySetters = v != null },
                { "ignore-changes-virtual", "Ignore changing non-`virtual` to `virtual` or adding `override`.",
                  v => State.IgnoreVirtualChanges = v != null },
                { "c|colorize:", "Colorize HTML output", v => State.Colorize = string.IsNullOrEmpty(v) ? true : bool.Parse(v) },
                { "x|lax", "Ignore duplicate XML entries", v => State.Lax = true },
                { "ignore-nonbreaking", "Ignore all nonbreaking changes", v => State.IgnoreNonbreaking = true },
                { "v|verbose:", "Verbosity level; when set, will print debug messages",
                  (int?v) => State.Verbosity = v ?? (State.Verbosity + 1) },
                new ResponseFileSource(),
            };

            try {
                extra = options.Parse(args);
            } catch (OptionException e) {
                Console.WriteLine("Option error: {0}", e.Message);
                showHelp = true;
            }

            if (State.IgnoreNonbreaking)
            {
                State.IgnoreAddedPropertySetters = true;
                State.IgnoreVirtualChanges       = true;
                State.IgnoreNew.Add(new Regex(".*"));
                State.IgnoreAdded.Add(new Regex(".*"));
            }

            if (showHelp || extra == null || extra.Count < 2 || extra.Count > 3)
            {
                Console.WriteLine(@"Usage: mono-api-html [options] <reference.xml> <assembly.xml> [diff.html]");
                Console.WriteLine();
                Console.WriteLine("Available options:");
                options.WriteOptionDescriptions(Console.Out);
                Console.WriteLine();
                Console.WriteLine("Ignoring Members:");
                Console.WriteLine();
                Console.WriteLine("  Members that were added can be filtered out of the diff by using the");
                Console.WriteLine("  -i, --ignore-added option. The option takes a C# regular expression");
                Console.WriteLine("  to match against member descriptions. For example, to ignore the");
                Console.WriteLine("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
                Console.WriteLine("  pass the following to mono-api-html:");
                Console.WriteLine();
                Console.WriteLine("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
                Console.WriteLine();
                Console.WriteLine("  The regular expressions will match any member description ending with");
                Console.WriteLine("  'INSCopying' or 'INSCoding'.");
                Console.WriteLine();
                return(1);
            }

            var input  = extra [0];
            var output = extra [1];

            if (extra.Count == 3 && diff == null)
            {
                diff = extra [2];
            }

            try {
                var ac = new AssemblyComparer(input, output);
                if (diff != null)
                {
                    string diffHtml = String.Empty;
                    using (var writer = new StringWriter()) {
                        State.Output = writer;
                        ac.Compare();
                        diffHtml = State.Output.ToString();
                    }
                    if (diffHtml.Length > 0)
                    {
                        using (var file = new StreamWriter(diff)) {
                            file.WriteLine("<div>");
                            if (State.Colorize)
                            {
                                file.WriteLine("<style scoped>");
                                file.WriteLine("\t.obsolete { color: gray; }");
                                file.WriteLine("\t.added { color: green; }");
                                file.WriteLine("\t.removed-inline { text-decoration: line-through; }");
                                file.WriteLine("\t.removed-breaking-inline { color: red;}");
                                file.WriteLine("\t.added-breaking-inline { text-decoration: underline; }");
                                file.WriteLine("\t.nonbreaking { color: black; }");
                                file.WriteLine("\t.breaking { color: red; }");
                                file.WriteLine("</style>");
                            }
                            file.WriteLine(
                                @"<script type=""text/javascript"">
	// Only some elements have 'data-is-[non-]breaking' attributes. Here we
	// iterate over all descendents elements, and set 'data-is-[non-]breaking'
	// depending on whether there are any descendents with that attribute.
	function propagateDataAttribute (element)
	{
		if (element.hasAttribute ('data-is-propagated'))
			return;

		var i;
		var any_breaking = element.hasAttribute ('data-is-breaking');
		var any_non_breaking = element.hasAttribute ('data-is-non-breaking');
		for (i = 0; i < element.children.length; i++) {
			var el = element.children [i];
			propagateDataAttribute (el);
			any_breaking |= el.hasAttribute ('data-is-breaking');
			any_non_breaking |= el.hasAttribute ('data-is-non-breaking');
		}
		
		if (any_breaking)
			element.setAttribute ('data-is-breaking', null);
		else if (any_non_breaking)
			element.setAttribute ('data-is-non-breaking', null);
		element.setAttribute ('data-is-propagated', null);
	}

	function hideNonBreakingChanges ()
	{
		var topNodes = document.querySelectorAll ('[data-is-topmost]');
		var n;
		var i;
		for (n = 0; n < topNodes.length; n++) {
			propagateDataAttribute (topNodes [n]);
			var elements = topNodes [n].querySelectorAll ('[data-is-non-breaking]');
			for (i = 0; i < elements.length; i++) {
				var el = elements [i];
				if (!el.hasAttribute ('data-original-display'))
					el.setAttribute ('data-original-display', el.style.display);
				el.style.display = 'none';
			}
		}
		
		var links = document.getElementsByClassName ('hide-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = 'none';
		links = document.getElementsByClassName ('restore-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = '';
	}

	function showNonBreakingChanges ()
	{
		var elements = document.querySelectorAll ('[data-original-display]');
		var i;
		for (i = 0; i < elements.length; i++) {
			var el = elements [i];
			el.style.display = el.getAttribute ('data-original-display');
		}

		var links = document.getElementsByClassName ('hide-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = '';
		links = document.getElementsByClassName ('restore-nonbreaking');
		for (i = 0; i < links.length; i++)
			links [i].style.display = 'none';
	}
</script>");
                            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);
                            }
                            if (!State.IgnoreNonbreaking)
                            {
                                file.WriteLine("<a href='javascript: hideNonBreakingChanges (); ' class='hide-nonbreaking'>Hide non-breaking changes</a>");
                                file.WriteLine("<a href='javascript: showNonBreakingChanges (); ' class='restore-nonbreaking' style='display: none;'>Show non-breaking changes</a>");
                                file.WriteLine("<br/>");
                            }
                            file.WriteLine("<div data-is-topmost>");
                            file.Write(diffHtml);
                            file.WriteLine("</div> <!-- end topmost div -->");
                            file.WriteLine("</div>");
                        }
                    }
                }
                else
                {
                    State.Output = Console.Out;
                    ac.Compare();
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(1);
            }
            return(0);
        }
Exemple #7
0
        public static int Main(string[] args)
        {
            var           showHelp = false;
            string        diff     = null;
            List <string> extra    = null;

            var options = new OptionSet {
                { "h|help", "Show this help", v => showHelp = true },
                { "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
                { "i|ignore=", "Ignore new, added, and removed members whose description matches a given C# regular expression (see below).",
                  v => {
                      var r = new Regex(v);
                      State.IgnoreAdded.Add(r);
                      State.IgnoreRemoved.Add(r);
                      State.IgnoreNew.Add(r);
                  } },
                { "a|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreAdded.Add(new Regex(v)) },
                { "r|ignore-removed=", "Ignore removed members whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreRemoved.Add(new Regex(v)) },
                { "n|ignore-new=", "Ignore new namespaces and types whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreNew.Add(new Regex(v)) },
                { "ignore-changes-parameter-names", "Ignore changes to parameter names for identically prototyped methods.",
                  v => State.IgnoreParameterNameChanges = v != null },
                { "ignore-changes-property-setters", "Ignore adding setters to properties.",
                  v => State.IgnoreAddedPropertySetters = v != null },
                { "ignore-changes-virtual", "Ignore changing non-`virtual` to `virtual` or adding `override`.",
                  v => State.IgnoreVirtualChanges = v != null },
                { "c|colorize:", "Colorize HTML output", v => State.Colorize = string.IsNullOrEmpty(v) ? true : bool.Parse(v) },
                { "x|lax", "Ignore duplicate XML entries", v => State.Lax = true },
                { "ignore-nonbreaking", "Ignore all nonbreaking changes", v => State.IgnoreNonbreaking = true },
                { "v|verbose:", "Verbosity level; when set, will print debug messages",
                  (int?v) => State.Verbosity = v ?? (State.Verbosity + 1) },
                { "md|markdown", "Output markdown instead of HTML", v => Formatter.Current = new MarkdownFormatter() },
                new ResponseFileSource(),
            };

            try {
                extra = options.Parse(args);
            } catch (OptionException e) {
                Console.WriteLine("Option error: {0}", e.Message);
                showHelp = true;
            }

            // unless specified default to HTML
            if (Formatter.Current == null)
            {
                Formatter.Current = new HtmlFormatter();
            }

            if (State.IgnoreNonbreaking)
            {
                State.IgnoreAddedPropertySetters = true;
                State.IgnoreVirtualChanges       = true;
                State.IgnoreNew.Add(new Regex(".*"));
                State.IgnoreAdded.Add(new Regex(".*"));
            }

            if (showHelp || extra == null || extra.Count < 2 || extra.Count > 3)
            {
                Console.WriteLine(@"Usage: mono-api-html [options] <reference.xml> <assembly.xml> [diff.html]");
                Console.WriteLine();
                Console.WriteLine("Available options:");
                options.WriteOptionDescriptions(Console.Out);
                Console.WriteLine();
                Console.WriteLine("Ignoring Members:");
                Console.WriteLine();
                Console.WriteLine("  Members that were added can be filtered out of the diff by using the");
                Console.WriteLine("  -i, --ignore-added option. The option takes a C# regular expression");
                Console.WriteLine("  to match against member descriptions. For example, to ignore the");
                Console.WriteLine("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
                Console.WriteLine("  pass the following to mono-api-html:");
                Console.WriteLine();
                Console.WriteLine("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
                Console.WriteLine();
                Console.WriteLine("  The regular expressions will match any member description ending with");
                Console.WriteLine("  'INSCopying' or 'INSCoding'.");
                Console.WriteLine();
                return(1);
            }

            var input  = extra [0];
            var output = extra [1];

            if (extra.Count == 3 && diff == null)
            {
                diff = extra [2];
            }

            try {
                var ac = new AssemblyComparer(input, output);
                if (diff != null)
                {
                    string diffHtml = String.Empty;
                    using (var writer = new StringWriter()) {
                        State.Output = writer;
                        ac.Compare();
                        diffHtml = State.Output.ToString();
                    }
                    if (diffHtml.Length > 0)
                    {
                        using (var file = new StreamWriter(diff)) {
                            var title = $"{ac.SourceAssembly}.dll";
                            if (ac.SourceAssembly != ac.TargetAssembly)
                            {
                                title += $" vs {ac.TargetAssembly}.dll";
                            }
                            Formatter.Current.BeginDocument(file, $"API diff: {title}");
                            Formatter.Current.BeginAssembly(file);
                            file.Write(diffHtml);
                            Formatter.Current.EndAssembly(file);
                            Formatter.Current.EndDocument(file);
                        }
                    }
                }
                else
                {
                    State.Output = Console.Out;
                    ac.Compare();
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(1);
            }
            return(0);
        }
Exemple #8
0
        public static int Main(string[] args)
        {
            var           showHelp = false;
            string        diff     = null;
            List <string> extra    = null;

            var options = new OptionSet {
                { "h|help", "Show this help", v => showHelp = true },
                { "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
                { "i|ignore=", "Ignore new, added, and removed members whose description matches a given C# regular expression (see below).",
                  v => {
                      var r = new Regex(v);
                      State.IgnoreAdded.Add(r);
                      State.IgnoreRemoved.Add(r);
                      State.IgnoreNew.Add(r);
                  } },
                { "a|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreAdded.Add(new Regex(v)) },
                { "r|ignore-removed=", "Ignore removed members whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreRemoved.Add(new Regex(v)) },
                { "n|ignore-new=", "Ignore new namespaces and types whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreNew.Add(new Regex(v)) },
                { "ignore-changes-parameter-names", "Ignore changes to parameter names for identically prototyped methods.",
                  v => State.IgnoreParameterNameChanges = v != null },
                { "ignore-changes-property-setters", "Ignore adding setters to properties.",
                  v => State.IgnoreAddedPropertySetters = v != null },
                { "ignore-changes-virtual", "Ignore changing non-`virtual` to `virtual` or adding `override`.",
                  v => State.IgnoreVirtualChanges = v != null },
                { "c|colorize:", "Colorize HTML output", v => State.Colorize = string.IsNullOrEmpty(v) ? true : bool.Parse(v) },
                { "x|lax", "Ignore duplicate XML entries", v => State.Lax = true }
            };

            try {
                extra = options.Parse(args);
            } catch (OptionException e) {
                Console.WriteLine("Option error: {0}", e.Message);
                showHelp = true;
            }

            if (showHelp || extra == null || extra.Count < 2 || extra.Count > 3)
            {
                Console.WriteLine(@"Usage: mono-api-html [options] <reference.xml> <assembly.xml> [diff.html]");
                Console.WriteLine();
                Console.WriteLine("Available options:");
                options.WriteOptionDescriptions(Console.Out);
                Console.WriteLine();
                Console.WriteLine("Ignoring Members:");
                Console.WriteLine();
                Console.WriteLine("  Members that were added can be filtered out of the diff by using the");
                Console.WriteLine("  -i, --ignore-added option. The option takes a C# regular expression");
                Console.WriteLine("  to match against member descriptions. For example, to ignore the");
                Console.WriteLine("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
                Console.WriteLine("  pass the following to mono-api-html:");
                Console.WriteLine();
                Console.WriteLine("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
                Console.WriteLine();
                Console.WriteLine("  The regular expressions will match any member description ending with");
                Console.WriteLine("  'INSCopying' or 'INSCoding'.");
                Console.WriteLine();
                return(1);
            }

            var input  = extra [0];
            var output = extra [1];

            if (extra.Count == 3 && diff == null)
            {
                diff = extra [2];
            }

            try {
                var ac = new AssemblyComparer(input, output);
                if (diff != null)
                {
                    string diffHtml = String.Empty;
                    using (var writer = new StringWriter()) {
                        State.Output = writer;
                        ac.Compare();
                        diffHtml = State.Output.ToString();
                    }
                    if (diffHtml.Length > 0)
                    {
                        using (var file = new StreamWriter(diff)) {
                            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(diffHtml);
                        }
                    }
                }
                else
                {
                    State.Output = Console.Out;
                    ac.Compare();
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(1);
            }
            return(0);
        }
Exemple #9
0
        public static int Main(string[] args)
        {
            var           showHelp = false;
            string        diff     = null;
            List <string> extra    = null;

            var options = new OptionSet {
                { "h|help", "Show this help", v => showHelp = true },
                { "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
                { "i|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
                  v => State.IgnoreAdded.Add(new Regex(v)) }
            };

            try {
                extra = options.Parse(args);
            } catch (OptionException e) {
                Console.WriteLine("Option error: {0}", e.Message);
                showHelp = true;
            }

            if (showHelp || extra == null || extra.Count < 2 || extra.Count > 3)
            {
                Console.WriteLine(@"Usage: mono-api-html [options] <reference.xml> <assembly.xml> [diff.html]");
                Console.WriteLine();
                Console.WriteLine("Available options:");
                options.WriteOptionDescriptions(Console.Out);
                Console.WriteLine();
                Console.WriteLine("Ignoring Members:");
                Console.WriteLine();
                Console.WriteLine("  Members that were added can be filtered out of the diff by using the");
                Console.WriteLine("  -i, --ignore-added option. The option takes a C# regular expression");
                Console.WriteLine("  to match against member descriptions. For example, to ignore the");
                Console.WriteLine("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
                Console.WriteLine("  pass the following to mono-api-html:");
                Console.WriteLine();
                Console.WriteLine("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
                Console.WriteLine();
                Console.WriteLine("  The regular expressions will match any member description ending with");
                Console.WriteLine("  'INSCopying' or 'INSCoding'.");
                Console.WriteLine();
                return(1);
            }

            var input  = extra [0];
            var output = extra [1];

            if (extra.Count == 3 && diff == null)
            {
                diff = extra [2];
            }

            try {
                var ac = new AssemblyComparer(input, output);
                if (diff != null)
                {
                    string diffHtml = String.Empty;
                    using (var writer = new StringWriter()) {
                        State.Output = writer;
                        ac.Compare();
                        diffHtml = State.Output.ToString();
                    }
                    if (diffHtml.Length > 0)
                    {
                        using (var file = new StreamWriter(diff)) {
                            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(diffHtml);
                        }
                    }
                }
                else
                {
                    State.Output = Console.Out;
                    ac.Compare();
                }
            }
            catch (Exception e) {
                Console.WriteLine(e);
                return(1);
            }
            return(0);
        }
Exemple #10
0
		public static int Main (string[] args)
		{
			var showHelp = false;
			string diff = null;
			List<string> extra = null;

			var options = new OptionSet {
				{ "h|help", "Show this help", v => showHelp = true },
				{ "d|diff=", "HTML diff file out output (omit for stdout)", v => diff = v },
				{ "i|ignore=", "Ignore new, added, and removed members whose description matches a given C# regular expression (see below).",
					v => {
						var r = new Regex (v);
						State.IgnoreAdded.Add (r);
						State.IgnoreRemoved.Add (r);
						State.IgnoreNew.Add (r);
					}
				},
				{ "a|ignore-added=", "Ignore added members whose description matches a given C# regular expression (see below).",
					v => State.IgnoreAdded.Add (new Regex (v))
				},
				{ "r|ignore-removed=", "Ignore removed members whose description matches a given C# regular expression (see below).",
					v => State.IgnoreRemoved.Add (new Regex (v))
				},
				{ "n|ignore-new=", "Ignore new namespaces and types whose description matches a given C# regular expression (see below).",
					v => State.IgnoreNew.Add (new Regex (v))
				},
				{ "ignore-changes-parameter-names", "Ignore changes to parameter names for identically prototyped methods.",
					v => State.IgnoreParameterNameChanges   = v != null
				},
				{ "ignore-changes-property-setters", "Ignore adding setters to properties.",
					v => State.IgnoreAddedPropertySetters = v != null
				},
				{ "ignore-changes-virtual", "Ignore changing non-`virtual` to `virtual` or adding `override`.",
					v => State.IgnoreVirtualChanges = v != null
				},
				{ "c|colorize:", "Colorize HTML output", v => State.Colorize = string.IsNullOrEmpty (v) ? true : bool.Parse (v) },
				{ "x|lax", "Ignore duplicate XML entries", v => State.Lax = true }
			};

			try {
				extra = options.Parse (args);
			} catch (OptionException e) {
				Console.WriteLine ("Option error: {0}", e.Message);
				showHelp = true;
			}

			if (showHelp || extra == null || extra.Count < 2 || extra.Count > 3) {
				Console.WriteLine (@"Usage: mono-api-html [options] <reference.xml> <assembly.xml> [diff.html]");
				Console.WriteLine ();
				Console.WriteLine ("Available options:");
				options.WriteOptionDescriptions (Console.Out);
				Console.WriteLine ();
				Console.WriteLine ("Ignoring Members:");
				Console.WriteLine ();
				Console.WriteLine ("  Members that were added can be filtered out of the diff by using the");
				Console.WriteLine ("  -i, --ignore-added option. The option takes a C# regular expression");
				Console.WriteLine ("  to match against member descriptions. For example, to ignore the");
				Console.WriteLine ("  introduction of the interfaces 'INSCopying' and 'INSCoding' on types");
				Console.WriteLine ("  pass the following to mono-api-html:");
				Console.WriteLine ();
				Console.WriteLine ("    mono-api-html ... -i 'INSCopying$' -i 'INSCoding$'");
				Console.WriteLine ();
				Console.WriteLine ("  The regular expressions will match any member description ending with");
				Console.WriteLine ("  'INSCopying' or 'INSCoding'.");
				Console.WriteLine ();
				return 1;
			}

			var input = extra [0];
			var output = extra [1];
			if (extra.Count == 3 && diff == null)
				diff = extra [2];

			try {
				var ac = new AssemblyComparer (input, output);
				if (diff != null) {
					string diffHtml = String.Empty;
					using (var writer = new StringWriter ()) {
						State.Output = writer;
						ac.Compare ();
						diffHtml = State.Output.ToString ();
					}
					if (diffHtml.Length > 0) {
						using (var file = new StreamWriter (diff)) {
							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 (diffHtml);
						}
					}
				} else {
					State.Output = Console.Out;
					ac.Compare ();
				}
			}
			catch (Exception e) {
				Console.WriteLine (e);
				return 1;
			}
			return 0;
		}