void CreateScopes(MethodBody body, ScopeCollection scopes, SymbolToken localVarToken) { 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 = body.Instructions.IndexOf(s.Start); int end = s.End == body.Instructions.Outside ? body.Instructions.Count - 1 : body.Instructions.IndexOf(s.End); ArrayList instructions = CollectSequencePoints(body, start, end); DefineSequencePoints(instructions); CreateLocalVariable(s, startOffset, endOffset, localVarToken); CreateScopes(body, s.Scopes, localVarToken); m_writer.CloseNamespace(); m_writer.CloseScope(endOffset); } }