diff options
author | Rolf Bjarne Kvinge <rolf@xamarin.com> | 2016-01-27 14:07:24 +0300 |
---|---|---|
committer | Rolf Bjarne Kvinge <rolf@xamarin.com> | 2016-01-28 15:19:16 +0300 |
commit | 6cf7b10c54c621f3f4b52f70c80c568badc6ae5d (patch) | |
tree | caf80c771ce97d73b3b0ae0ef771acbb1a67e0b6 | |
parent | 85490058c8335b60441ef02863f861aaabfa51dd (diff) |
[mono-api-info] Add support for writing output to a file specified using a command line argument.
-rw-r--r-- | mcs/tools/corcompare/mono-api-info.cs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/mcs/tools/corcompare/mono-api-info.cs b/mcs/tools/corcompare/mono-api-info.cs index c43437fe40d..0886d14b3bd 100644 --- a/mcs/tools/corcompare/mono-api-info.cs +++ b/mcs/tools/corcompare/mono-api-info.cs @@ -31,6 +31,7 @@ namespace CorCompare bool showHelp = false; AbiMode = false; FollowForwarders = false; + string output = null; var acoll = new AssemblyCollection (); @@ -52,6 +53,9 @@ namespace CorCompare { "r=", "Read and register the file {ASSEMBLY}, and add the directory containing ASSEMBLY to the search path.", v => TypeHelper.Resolver.ResolveFile (v) }, + { "o=", + "The output file. If not specified the output will be written to stdout.", + v => output = v }, { "h|?|help", "Show this message and exit.", v => showHelp = v != null }, @@ -93,10 +97,18 @@ namespace CorCompare acoll.Document = doc; acoll.DoOutput (); - var writer = new WellFormedXmlWriter (new XmlTextWriter (Console.Out) { Formatting = Formatting.Indented }); - XmlNode decl = doc.CreateXmlDeclaration ("1.0", "utf-8", null); - doc.InsertBefore (decl, doc.DocumentElement); - doc.WriteTo (writer); + TextWriter outputStream = null; + if (!string.IsNullOrEmpty (output)) + outputStream = new StreamWriter (output); + try { + var writer = new WellFormedXmlWriter (new XmlTextWriter (outputStream ?? Console.Out) { Formatting = Formatting.Indented }); + XmlNode decl = doc.CreateXmlDeclaration ("1.0", "utf-8", null); + doc.InsertBefore (decl, doc.DocumentElement); + doc.WriteTo (writer); + } finally { + if (outputStream != null) + outputStream.Dispose (); + } return 0; } |