private List <ComPatchClass> ProcessMapFile(VariantConfig variant) { var classModell = new List <ComPatchClass>(); ComPatchClass last = null; foreach (var line in File.ReadAllLines(variant.MappingFile)) { if (line.StartsWith('#')) { Log.Info("Comment: " + line); continue; } if (!line.StartsWith(" ")) //Class { last = GetComPatchClassFromLine(line); classModell.Add(last); } else if (last == null) { throw new ArgumentException("Didn't find a class for line: " + line); } else //Sub { ProcessPayloadOfLine(line, last); } } return(classModell); }
private ComPatchClass GetComPatchClassFromLine(string line) { var comClass = new ComPatchClass(); var tmps = line.Split(" -> "); comClass.Name = tmps[0]; //Remove : comClass.ObfName = tmps[1].Remove(tmps[1].Length - 1); return(comClass); }
private void ProcessPayloadOfLine(string line, ComPatchClass last) { var tmp1 = line.Split(" -> "); Contract.Requires(tmp1.Length == 2); string obfName = tmp1[1]; //Method with LineNumbers if (tmp1[0].Contains(':')) { var method = new ComPatchMethod() { ObfName = obfName }; var tmp2 = tmp1[0].Split(':'); Contract.Requires(tmp2.Length == 3); var tmp3 = tmp2[2].Split(' '); Contract.Requires(tmp3.Length == 2); method.ReturnType = tmp3[0]; var(name, parameters) = GetNameAndComPatchParameters(tmp3[1]); method.Name = name; method.Parameters = parameters; last.Methods.Add(method); } else //Field or Method with no line numbers (rare) { var tmp2 = tmp1[0].Split(' ', StringSplitOptions.RemoveEmptyEntries); Contract.Requires(tmp2.Length == 2); //Method with no line numbers if (tmp2[1].Contains('(') && tmp2[1].Contains(')')) { var method = new ComPatchMethod() { ObfName = obfName, ReturnType = tmp2[0] }; var(name, parameters) = GetNameAndComPatchParameters(tmp2[1]); method.Name = name; method.Parameters = parameters; last.Methods.Add(method); } else //Field { var field = new ComPatchField() { ObfName = obfName, Type = tmp2[0], Name = tmp2[1] }; last.Fields.Add(field); } } }