internal void GenerateDebugInfo (ISymbolWriter symbolWriter) { symbolWriter.OpenNamespace (this.Namespace); if (methods != null) { for (int i = 0; i < num_methods; ++i) { MethodBuilder metb = (MethodBuilder) methods[i]; metb.GenerateDebugInfo (symbolWriter); } } if (ctors != null) { foreach (ConstructorBuilder ctor in ctors) ctor.GenerateDebugInfo (symbolWriter); } symbolWriter.CloseNamespace (); if (subtypes != null) { for (int i = 0; i < subtypes.Length; ++i) subtypes [i].GenerateDebugInfo (symbolWriter); } }
void CreateScopes(MethodBody body, ScopeCollection scopes) { foreach (Scope s in scopes) { int startOffset = s.Start.Offset; int endOffset = s.End == body.Instructions.Outside ? body.Instructions[body.Instructions.Count - 1].Offset + 1 : s.End.Offset; m_writer.OpenScope(startOffset); m_writer.UsingNamespace(body.Method.DeclaringType.Namespace); m_writer.OpenNamespace(body.Method.DeclaringType.Namespace); int start = Math.Max(0, body.Instructions.IndexOf(s.Start)); int end = s.End == body.Instructions.Outside ? body.Instructions.Count - 1 : body.Instructions.IndexOf(s.End); ArrayList instructions = new ArrayList(); for (int i = start; i <= end; i++) { if (body.Instructions[i] != null && body.Instructions[i].SequencePoint != null) { instructions.Add(body.Instructions [i]); } } Document doc = null; int [] offsets = new int [instructions.Count]; int [] startRows = new int [instructions.Count]; int [] startCols = new int [instructions.Count]; int [] endRows = new int [instructions.Count]; int [] endCols = new int [instructions.Count]; for (int i = 0; i < instructions.Count; i++) { Instruction instr = (Instruction)instructions [i]; offsets [i] = instr.Offset; if (doc == null) { doc = instr.SequencePoint.Document; } startRows [i] = instr.SequencePoint.StartLine; startCols [i] = instr.SequencePoint.StartColumn; endRows [i] = instr.SequencePoint.EndLine; endCols [i] = instr.SequencePoint.EndColumn; } if (doc != null) { m_writer.DefineSequencePoints(GetDocument(doc), offsets, startRows, startCols, endRows, endCols); } // Cecil PDB writer does not yet write the variable names. // This is not yet implemented. // TODO local variable support //CreateLocalVariable (s, startOffset, endOffset); //CreateScopes (body, s.Scopes); m_writer.CloseNamespace(); m_writer.CloseScope(endOffset); } }