Imported Upstream version 5.16.0.100

Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-08-07 15:19:03 +00:00
parent 0a9828183b
commit 7d7f676260
4419 changed files with 170950 additions and 90273 deletions

View File

@@ -31,6 +31,7 @@ using System.IO;
using System.Collections.Generic;
using System.Resources;
using System.ComponentModel.Design;
using System.Text.RegularExpressions;
using Mono.Options;
public class Program
@@ -41,13 +42,21 @@ public class Program
public string OutputFile { get; set; }
}
internal static List<string> InputFiles;
internal static Dictionary<string, object> ExistingKeys;
public static int Main (string[] args)
{
var options = new CmdOptions ();
InputFiles = new List<string> ();
ExistingKeys = new Dictionary<string, object> ();
var p = new OptionSet () {
{ "o|out=", "Specifies output file name",
v => options.OutputFile = v },
{ "i|in=", "Specifies input file name",
v => InputFiles.Add (v) },
{ "h|help", "Display available options",
v => options.ShowHelp = v != null },
};
@@ -71,6 +80,9 @@ public class Program
return 2;
}
if (!LoadInputFiles ())
return 4;
var resxStrings = new List<Tuple<string, string, string>> ();
if (!LoadStrings (resxStrings, extra))
return 3;
@@ -150,10 +162,41 @@ public class Program
while (dict.MoveNext ()) {
var node = (ResXDataNode)dict.Value;
if (ExistingKeys.ContainsKey (node.Name))
continue;
ExistingKeys.Add (node.Name, null);
resourcesStrings.Add (Tuple.Create (node.Name, (string) node.GetValue ((ITypeResolutionService)null), node.Comment));
}
}
return true;
}
static bool LoadInputFiles ()
{
var reg = new Regex (@"\s*public const string (\w+)\s+=\s+");
var keys = new Dictionary<string, string> ();
foreach (var fileName in InputFiles) {
if (!File.Exists (fileName)) {
Console.Error.WriteLine ($"Error reading input file '{fileName}'");
return false;
}
using (var reader = new StreamReader (fileName)) {
string line;
while ((line = reader.ReadLine ()) != null) {
var match = reg.Match (line);
if (!match.Success)
continue;
var key = match.Groups[1].Value;
if (!ExistingKeys.ContainsKey (key))
ExistingKeys.Add (key, null);
}
}
}
return true;
}
}