UsingNamespace() public method

public UsingNamespace ( string fullName ) : void
fullName string
return void
Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 private void DefineUsedNamespaces(PdbMethodSymbols pdbSymbols)
 {
     // Used namespaces
     if (pdbSymbols != null && pdbSymbols.UsedNamespaces != null)
     {
         foreach (var @namespace in pdbSymbols.UsedNamespaces)
         {
             writer.UsingNamespace(@namespace);
         }
     }
 }
Esempio n. 3
0
        void DefineScope(ScopeDebugInformation scope, MethodDebugInformation info, out MetadataToken import_parent)
        {
            var start_offset = scope.Start.Offset;
            var end_offset   = scope.End.IsEndOfMethod
                                ? info.code_size
                                : scope.End.Offset;

            import_parent = new MetadataToken(0u);

            writer.OpenScope(start_offset);

            if (scope.Import != null && scope.Import.HasTargets && !import_info_to_parent.TryGetValue(info.scope.Import, out import_parent))
            {
                foreach (var target in scope.Import.Targets)
                {
                    switch (target.Kind)
                    {
                    case ImportTargetKind.ImportNamespace:
                        writer.UsingNamespace("U" + target.@namespace);
                        break;

                    case ImportTargetKind.ImportType:
                        writer.UsingNamespace("T" + TypeParser.ToParseable(target.type));
                        break;

                    case ImportTargetKind.DefineNamespaceAlias:
                        writer.UsingNamespace("A" + target.Alias + " U" + target.@namespace);
                        break;

                    case ImportTargetKind.DefineTypeAlias:
                        writer.UsingNamespace("A" + target.Alias + " T" + TypeParser.ToParseable(target.type));
                        break;
                    }
                }

                import_info_to_parent.Add(info.scope.Import, info.method.MetadataToken);
            }

            var sym_token = info.local_var_token.ToInt32();

            if (!scope.variables.IsNullOrEmpty())
            {
                for (int i = 0; i < scope.variables.Count; i++)
                {
                    var variable = scope.variables [i];
                    DefineLocalVariable(variable, sym_token, start_offset, end_offset);
                }
            }

            if (!scope.constants.IsNullOrEmpty())
            {
                for (int i = 0; i < scope.constants.Count; i++)
                {
                    var constant = scope.constants [i];
                    DefineConstant(constant);
                }
            }

            if (!scope.scopes.IsNullOrEmpty())
            {
                for (int i = 0; i < scope.scopes.Count; i++)
                {
                    MetadataToken _;
                    DefineScope(scope.scopes [i], info, out _);
                }
            }

            writer.CloseScope(end_offset);
        }