private void ReadMethods() { if (FullName.Contains("WithTemplate")) { Console.WriteLine(); } var methodBuilders = new List <StringBuilder>(); // Now start parsing the raw IL, line by line. using (var reader = new StringReader(RawIL)) { // Read each line string line; StringBuilder currentBuilder = null; string currentName = null; while ((line = reader.ReadLine()) != null) { // Is it a class start token? If so, we can start a new builder. if (ILParseHelper.IsLineMethodDeclaration(line)) { currentBuilder = new StringBuilder(); } else if (currentBuilder != null && currentName == null) { // We must now be on the name line. currentName = ILParseHelper.GetMethodNameFromDeclarationLine(line); } // If don't have a current class, skip. if (currentBuilder == null) { continue; } // Add the line to the class builder. currentBuilder.AppendLine(line); // Is it a class end token? If so, clear the current class identifier. if (ILParseHelper.IsLineMethodEndDeclaration(line, ShortName, currentName)) { methodBuilders.Add(currentBuilder); currentName = null; currentBuilder = null; } } } methodBuilders.ForEach(mb => { var method = new DisassembledMethod(); method.Parent = this; method.RawIL = mb.ToString(); method.InitialiseFromIL(); method.FullName = FullName + "." + method.ShortName; methods.Add(method); }); }
public override void InitialiseFromIL() { string line; using (var reader = new StringReader(RawIL)) { while ((line = reader.ReadLine()) != null) { var methodName = ILParseHelper.GetMethodNameFromDeclarationLine(line); if (methodName != null) { ShortName = methodName; FullName = methodName; break; } } } }