2 // namespace.cs: Tracks namespaces
5 // Miguel de Icaza (miguel@ximian.com)
6 // Marek Safar (marek.safar@seznam.cz)
8 // Copyright 2001 Ximian, Inc.
9 // Copyright 2003-2008 Novell, Inc.
12 using System.Collections;
13 using System.Collections.Specialized;
14 using System.Reflection;
16 namespace Mono.CSharp {
18 public class RootNamespace : Namespace {
19 static MethodInfo get_namespaces_method;
22 Assembly referenced_assembly;
24 Hashtable all_namespaces;
26 static Hashtable root_namespaces;
27 public static GlobalRootNamespace Global;
29 static RootNamespace ()
31 get_namespaces_method = typeof (Assembly).GetMethod ("GetNamespaces", BindingFlags.Instance | BindingFlags.NonPublic);
36 public static void Reset ()
38 root_namespaces = new Hashtable ();
39 Global = new GlobalRootNamespace ();
40 root_namespaces ["global"] = Global;
43 protected RootNamespace (string alias_name, Assembly assembly)
44 : base (null, String.Empty)
46 this.alias_name = alias_name;
47 referenced_assembly = assembly;
49 all_namespaces = new Hashtable ();
50 all_namespaces.Add ("", this);
52 if (referenced_assembly != null)
53 ComputeNamespaces (this.referenced_assembly);
56 public static void DefineRootNamespace (string name, Assembly assembly)
58 if (name == "global") {
59 NamespaceEntry.Error_GlobalNamespaceRedefined (Location.Null);
62 RootNamespace retval = GetRootNamespace (name);
63 if (retval == null || retval.referenced_assembly != assembly)
64 root_namespaces [name] = new RootNamespace (name, assembly);
67 public static RootNamespace GetRootNamespace (string name)
69 return (RootNamespace) root_namespaces [name];
72 public virtual Type LookupTypeReflection (string name, Location loc)
74 return GetTypeInAssembly (referenced_assembly, name);
77 public void RegisterNamespace (Namespace child)
80 all_namespaces.Add (child.Name, child);
83 public bool IsNamespace (string name)
85 return all_namespaces.Contains (name);
88 protected void RegisterNamespace (string dotted_name)
90 if (dotted_name != null && dotted_name.Length != 0 && ! IsNamespace (dotted_name))
91 GetNamespace (dotted_name, true);
94 void RegisterExtensionMethodClass (Type t)
96 string n = t.Namespace;
97 Namespace ns = n == null ? Global : (Namespace)all_namespaces [n];
99 ns = GetNamespace (n, true);
101 ns.RegisterExternalExtensionMethodClass (t);
104 protected void ComputeNamespaces (Assembly assembly)
106 // How to test whether attribute exists without loading the assembly :-(
108 const string SystemCore = "System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e";
110 const string SystemCore = "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
112 if (TypeManager.extension_attribute_type == null &&
113 assembly.FullName == SystemCore) {
114 TypeManager.extension_attribute_type = assembly.GetType("System.Runtime.CompilerServices.ExtensionAttribute");
117 bool contains_extension_methods = TypeManager.extension_attribute_type != null &&
118 assembly.IsDefined(TypeManager.extension_attribute_type, false);
120 if (get_namespaces_method != null && !contains_extension_methods) {
121 string [] namespaces = (string []) get_namespaces_method.Invoke (assembly, null);
122 foreach (string ns in namespaces)
123 RegisterNamespace (ns);
127 foreach (Type t in assembly.GetExportedTypes ()) {
128 if ((t.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute &&
129 contains_extension_methods && t.IsDefined (TypeManager.extension_attribute_type, false))
130 RegisterExtensionMethodClass (t);
132 RegisterNamespace (t.Namespace);
136 protected static Type GetTypeInAssembly (Assembly assembly, string name)
138 Type t = assembly.GetType (name);
143 throw new InternalErrorException ("Use GetPointerType() to get a pointer");
145 TypeAttributes ta = t.Attributes & TypeAttributes.VisibilityMask;
146 if (ta == TypeAttributes.NestedPrivate)
149 if ((ta == TypeAttributes.NotPublic ||
150 ta == TypeAttributes.NestedAssembly ||
151 ta == TypeAttributes.NestedFamANDAssem) &&
152 !TypeManager.IsThisOrFriendAssembly (t.Assembly))
158 public override string ToString ()
160 return String.Format ("RootNamespace ({0}::)", alias_name);
163 public override string GetSignatureForError ()
165 return alias_name + "::";
169 public class GlobalRootNamespace : RootNamespace {
170 Assembly [] assemblies;
173 public GlobalRootNamespace ()
174 : base ("global", null)
176 assemblies = new Assembly [0];
179 public Assembly [] Assemblies {
180 get { return assemblies; }
183 public Module [] Modules {
184 get { return modules; }
187 public void AddAssemblyReference (Assembly a)
189 foreach (Assembly assembly in assemblies) {
194 int top = assemblies.Length;
195 Assembly [] n = new Assembly [top + 1];
196 assemblies.CopyTo (n, 0);
200 ComputeNamespaces (a);
203 public void AddModuleReference (Module m)
205 int top = modules != null ? modules.Length : 0;
206 Module [] n = new Module [top + 1];
208 modules.CopyTo (n, 0);
212 if (m == CodeGen.Module.Builder)
215 foreach (Type t in m.GetTypes ())
216 RegisterNamespace (t.Namespace);
219 public override void Error_NamespaceDoesNotExist(DeclSpace ds, Location loc, string name)
221 Report.Error (400, loc, "The type or namespace name `{0}' could not be found in the global namespace (are you missing an assembly reference?)",
225 public override Type LookupTypeReflection (string name, Location loc)
227 Type found_type = null;
229 foreach (Assembly a in assemblies) {
230 Type t = GetTypeInAssembly (a, name);
234 if (found_type == null) {
239 Report.SymbolRelatedToPreviousError (found_type);
240 Report.SymbolRelatedToPreviousError (t);
241 Report.Error (433, loc, "The imported type `{0}' is defined multiple times", name);
246 if (modules != null) {
247 foreach (Module module in modules) {
248 Type t = module.GetType (name);
252 if (found_type == null) {
257 Report.SymbolRelatedToPreviousError (found_type);
259 DeclSpace ds = TypeManager.LookupDeclSpace (t);
260 Report.Warning (1685, 1, ds.Location, "The type `{0}' conflicts with the predefined type `{1}' and will be ignored",
261 ds.GetSignatureForError (), TypeManager.CSharpName (found_type));
264 Report.SymbolRelatedToPreviousError (t);
265 Report.Warning (436, 2, loc, "The type `{0}' conflicts with the imported type `{1}'. Ignoring the imported type definition",
266 TypeManager.CSharpName (t), TypeManager.CSharpName (found_type));
276 /// Keeps track of the namespaces defined in the C# code.
278 /// This is an Expression to allow it to be referenced in the
279 /// compiler parse/intermediate tree during name resolution.
281 public class Namespace : FullNamedExpression {
285 IDictionary namespaces;
286 IDictionary declspaces;
287 Hashtable cached_types;
289 ArrayList external_exmethod_classes;
291 public readonly MemberName MemberName;
294 /// Constructor Takes the current namespace and the
295 /// name. This is bootstrapped with parent == null
298 public Namespace (Namespace parent, string name)
300 // Expression members.
301 this.eclass = ExprClass.Namespace;
302 this.Type = typeof (Namespace);
303 this.loc = Location.Null;
305 this.parent = parent;
308 this.root = parent.root;
310 this.root = this as RootNamespace;
312 if (this.root == null)
313 throw new InternalErrorException ("Root namespaces must be created using RootNamespace");
315 string pname = parent != null ? parent.fullname : "";
320 fullname = parent.fullname + "." + name;
322 if (fullname == null)
323 throw new InternalErrorException ("Namespace has a null fullname");
325 if (parent != null && parent.MemberName != MemberName.Null)
326 MemberName = new MemberName (parent.MemberName, name);
327 else if (name.Length == 0)
328 MemberName = MemberName.Null;
330 MemberName = new MemberName (name);
332 namespaces = new HybridDictionary ();
333 cached_types = new Hashtable ();
335 root.RegisterNamespace (this);
338 public override Expression DoResolve (EmitContext ec)
343 public virtual void Error_NamespaceDoesNotExist (DeclSpace ds, Location loc, string name)
345 if (name.IndexOf ('`') > 0) {
346 FullNamedExpression retval = Lookup (ds, SimpleName.RemoveGenericArity (name), loc);
347 if (retval != null) {
348 Error_TypeArgumentsCannotBeUsed (retval.Type, loc);
352 Type t = LookForAnyGenericType (name);
354 Error_InvalidNumberOfTypeArguments (t, loc);
359 Report.Error (234, loc, "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing an assembly reference?",
360 name, GetSignatureForError ());
363 public static void Error_InvalidNumberOfTypeArguments (Type t, Location loc)
365 Report.SymbolRelatedToPreviousError (t);
366 Report.Error (305, loc, "Using the generic type `{0}' requires `{1}' type argument(s)",
367 TypeManager.CSharpName(t), TypeManager.GetNumberOfTypeArguments(t).ToString());
370 public static void Error_TypeArgumentsCannotBeUsed (Type t, Location loc)
372 Report.SymbolRelatedToPreviousError (t);
373 Error_TypeArgumentsCannotBeUsed (loc, "type", TypeManager.CSharpName (t));
376 public static void Error_TypeArgumentsCannotBeUsed (MethodBase mi, Location loc)
378 Report.SymbolRelatedToPreviousError (mi);
379 Error_TypeArgumentsCannotBeUsed (loc, "method", TypeManager.CSharpSignature (mi));
382 static void Error_TypeArgumentsCannotBeUsed (Location loc, string type, string name)
384 Report.Error(308, loc, "The non-generic {0} `{1}' cannot be used with the type arguments",
388 public override string GetSignatureForError ()
393 public Namespace GetNamespace (string name, bool create)
395 int pos = name.IndexOf ('.');
400 first = name.Substring (0, pos);
404 ns = (Namespace) namespaces [first];
409 ns = new Namespace (this, first);
410 namespaces.Add (first, ns);
414 ns = ns.GetNamespace (name.Substring (pos + 1), create);
419 TypeExpr LookupType (string name, Location loc)
421 if (cached_types.Contains (name))
422 return cached_types [name] as TypeExpr;
425 if (declspaces != null) {
426 DeclSpace tdecl = declspaces [name] as DeclSpace;
429 // Note that this is not:
431 // t = tdecl.DefineType ()
433 // This is to make it somewhat more useful when a DefineType
434 // fails due to problems in nested types (more useful in the sense
435 // of fewer misleading error messages)
438 t = tdecl.TypeBuilder;
441 string lookup = t != null ? t.FullName : (fullname.Length == 0 ? name : fullname + "." + name);
442 Type rt = root.LookupTypeReflection (lookup, loc);
444 // HACK: loc.IsNull when the type is core type
445 if (t == null || (rt != null && loc.IsNull))
448 TypeExpr te = t == null ? null : new TypeExpression (t, Location.Null);
449 cached_types [name] = te;
454 /// Used for better error reporting only
456 public Type LookForAnyGenericType (string typeName)
458 if (declspaces == null)
461 typeName = SimpleName.RemoveGenericArity (typeName);
463 foreach (DictionaryEntry de in declspaces) {
464 string type_item = (string) de.Key;
465 int pos = type_item.LastIndexOf ('`');
466 if (pos == typeName.Length && String.Compare (typeName, 0, type_item, 0, pos) == 0)
467 return ((DeclSpace) de.Value).TypeBuilder;
472 public FullNamedExpression Lookup (DeclSpace ds, string name, Location loc)
474 if (namespaces.Contains (name))
475 return (Namespace) namespaces [name];
477 return LookupType (name, loc);
480 public void RegisterExternalExtensionMethodClass (Type type)
482 if (external_exmethod_classes == null)
483 external_exmethod_classes = new ArrayList ();
485 external_exmethod_classes.Add (type);
489 /// Looks for extension method in this namespace
491 public ArrayList LookupExtensionMethod (Type extensionType, ClassOrStruct currentClass, string name, NamespaceEntry ns)
493 ArrayList found = null;
495 if (declspaces != null) {
496 IEnumerator e = declspaces.Values.GetEnumerator ();
498 while (e.MoveNext ()) {
499 Class c = e.Current as Class;
503 if (!c.IsStaticClass)
506 ArrayList res = c.MemberCache.FindExtensionMethods (extensionType, name, c != currentClass);
513 found.AddRange (res);
517 if (external_exmethod_classes == null)
520 foreach (Type t in external_exmethod_classes) {
521 MemberCache m = TypeHandle.GetMemberCache (t);
522 ArrayList res = m.FindExtensionMethods (extensionType, name, true);
529 found.AddRange (res);
535 public void AddDeclSpace (string name, DeclSpace ds)
537 if (declspaces == null)
538 declspaces = new HybridDictionary ();
539 declspaces.Add (name, ds);
543 /// The qualified name of the current namespace
546 get { return fullname; }
550 /// The parent of this namespace, used by the parser to "Pop"
551 /// the current namespace declaration
553 public Namespace Parent {
554 get { return parent; }
559 // Namespace container as created by the parser
561 public class NamespaceEntry : IResolveContext {
564 readonly MemberName name;
567 public UsingEntry (MemberName name)
572 public string GetSignatureForError ()
574 return name.GetSignatureForError ();
577 public Location Location {
578 get { return name.Location; }
581 public MemberName MemberName {
586 get { return GetSignatureForError (); }
589 public Namespace Resolve (IResolveContext rc)
591 if (resolved != null)
594 FullNamedExpression fne = name.GetTypeExpression ().ResolveAsTypeStep (rc, false);
598 resolved = fne as Namespace;
599 if (resolved == null) {
600 Report.SymbolRelatedToPreviousError (fne.Type);
601 Report.Error (138, Location,
602 "`{0}' is a type not a namespace. A using namespace directive can only be applied to namespaces",
603 GetSignatureForError ());
609 class UsingAliasEntry {
610 public readonly string Alias;
611 public Location Location;
613 public UsingAliasEntry (string alias, Location loc)
619 public virtual FullNamedExpression Resolve (IResolveContext rc)
621 FullNamedExpression fne = RootNamespace.GetRootNamespace (Alias);
623 Report.Error (430, Location,
624 "The extern alias `{0}' was not specified in -reference option",
632 class LocalUsingAliasEntry : UsingAliasEntry {
636 public LocalUsingAliasEntry (string alias, MemberName name, Location loc)
642 public override FullNamedExpression Resolve (IResolveContext rc)
644 if (resolved != null)
645 return (FullNamedExpression)resolved;
647 resolved = value.GetTypeExpression ().ResolveAsTypeStep (rc, false);
648 if (resolved == null)
651 // FIXME: This is quite wrong, the accessibility is not global
652 if (resolved.Type != null) {
653 TypeAttributes attr = resolved.Type.Attributes & TypeAttributes.VisibilityMask;
654 if (attr == TypeAttributes.NestedPrivate || attr == TypeAttributes.NestedFamily ||
655 ((attr == TypeAttributes.NestedFamORAssem || attr == TypeAttributes.NestedAssembly) &&
656 TypeManager.LookupDeclSpace (resolved.Type) == null)) {
657 Expression.ErrorIsInaccesible (resolved.Location, resolved.GetSignatureForError ());
662 return (FullNamedExpression)resolved;
667 NamespaceEntry parent, implicit_parent;
668 CompilationUnit file;
671 // Namespace using import block
672 ArrayList using_aliases;
673 ArrayList using_clauses;
674 public bool DeclarationFound = false;
677 public readonly bool IsImplicit;
678 public readonly DeclSpace SlaveDeclSpace;
679 static readonly Namespace [] empty_namespaces = new Namespace [0];
680 Namespace [] namespace_using_table;
682 static ArrayList entries = new ArrayList ();
684 public static void Reset ()
686 entries = new ArrayList ();
689 public NamespaceEntry (NamespaceEntry parent, CompilationUnit file, string name)
691 this.parent = parent;
696 ns = parent.NS.GetNamespace (name, true);
697 else if (name != null)
698 ns = RootNamespace.Global.GetNamespace (name, true);
700 ns = RootNamespace.Global;
701 SlaveDeclSpace = new RootDeclSpace (this);
704 private NamespaceEntry (NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave)
706 this.parent = parent;
708 this.IsImplicit = true;
710 this.SlaveDeclSpace = slave ? new RootDeclSpace (this) : null;
714 // According to section 16.3.1 (using-alias-directive), the namespace-or-type-name is
715 // resolved as if the immediately containing namespace body has no using-directives.
717 // Section 16.3.2 says that the same rule is applied when resolving the namespace-name
718 // in the using-namespace-directive.
720 // To implement these rules, the expressions in the using directives are resolved using
721 // the "doppelganger" (ghostly bodiless duplicate).
723 NamespaceEntry doppelganger;
724 NamespaceEntry Doppelganger {
726 if (!IsImplicit && doppelganger == null) {
727 doppelganger = new NamespaceEntry (ImplicitParent, file, ns, true);
728 doppelganger.using_aliases = using_aliases;
734 public Namespace NS {
738 public NamespaceEntry Parent {
739 get { return parent; }
742 public NamespaceEntry ImplicitParent {
746 if (implicit_parent == null) {
747 implicit_parent = (parent.NS == ns.Parent)
749 : new NamespaceEntry (parent, file, ns.Parent, false);
751 return implicit_parent;
756 /// Records a new namespace for resolving name references
758 public void AddUsing (MemberName name, Location loc)
760 if (DeclarationFound){
761 Report.Error (1529, loc, "A using clause must precede all other namespace elements except extern alias declarations");
764 if (using_clauses == null) {
765 using_clauses = new ArrayList ();
767 foreach (UsingEntry old_entry in using_clauses) {
768 if (name.Equals (old_entry.MemberName)) {
769 Report.SymbolRelatedToPreviousError (old_entry.Location, old_entry.GetSignatureForError ());
770 Report.Warning (105, 3, loc, "The using directive for `{0}' appeared previously in this namespace", name.GetSignatureForError ());
776 using_clauses.Add (new UsingEntry (name));
779 public void AddUsingAlias (string alias, MemberName name, Location loc)
781 // TODO: This is parser bussines
782 if (DeclarationFound){
783 Report.Error (1529, loc, "A using clause must precede all other namespace elements except extern alias declarations");
786 if (RootContext.Version != LanguageVersion.ISO_1 && alias == "global")
787 Report.Warning (440, 2, loc, "An alias named `global' will not be used when resolving 'global::';" +
788 " the global namespace will be used instead");
790 AddUsingAlias (new LocalUsingAliasEntry (alias, name, loc));
793 public void AddUsingExternalAlias (string alias, Location loc)
795 // TODO: Do this in parser
796 bool not_first = using_clauses != null || DeclarationFound;
797 if (using_aliases != null && !not_first) {
798 foreach (UsingAliasEntry uae in using_aliases) {
799 if (uae is LocalUsingAliasEntry) {
807 Report.Error (439, loc, "An extern alias declaration must precede all other elements");
809 if (alias == "global") {
810 Error_GlobalNamespaceRedefined (loc);
814 AddUsingAlias (new UsingAliasEntry (alias, loc));
817 void AddUsingAlias (UsingAliasEntry uae)
819 if (using_aliases == null) {
820 using_aliases = new ArrayList ();
822 foreach (UsingAliasEntry entry in using_aliases) {
823 if (uae.Alias == entry.Alias) {
824 Report.SymbolRelatedToPreviousError (uae.Location, uae.Alias);
825 Report.Error (1537, entry.Location, "The using alias `{0}' appeared previously in this namespace",
832 using_aliases.Add (uae);
836 /// Does extension methods look up to find a method which matches name and extensionType.
837 /// Search starts from this namespace and continues hierarchically up to top level.
839 public ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, ClassOrStruct currentClass, string name, Location loc)
841 ArrayList candidates = null;
842 if (currentClass != null) {
843 candidates = ns.LookupExtensionMethod (extensionType, currentClass, name, this);
844 if (candidates != null)
845 return new ExtensionMethodGroupExpr (candidates, this, extensionType, loc);
848 foreach (Namespace n in GetUsingTable ()) {
849 ArrayList a = n.LookupExtensionMethod (extensionType, null, name, this);
853 if (candidates == null)
856 candidates.AddRange (a);
859 if (candidates != null)
860 return new ExtensionMethodGroupExpr (candidates, parent, extensionType, loc);
866 // Inspect parent namespaces in namespace expression
868 Namespace parent_ns = ns.Parent;
870 candidates = parent_ns.LookupExtensionMethod (extensionType, null, name, parent);
871 if (candidates != null)
872 return new ExtensionMethodGroupExpr (candidates, parent, extensionType, loc);
874 parent_ns = parent_ns.Parent;
875 } while (parent_ns != null);
878 // Continue in parent scope
880 return parent.LookupExtensionMethod (extensionType, currentClass, name, loc);
883 public FullNamedExpression LookupNamespaceOrType (DeclSpace ds, string name, Location loc, bool ignore_cs0104)
885 // Precondition: Only simple names (no dots) will be looked up with this function.
886 FullNamedExpression resolved = null;
887 for (NamespaceEntry curr_ns = this; curr_ns != null; curr_ns = curr_ns.ImplicitParent) {
888 if ((resolved = curr_ns.Lookup (ds, name, loc, ignore_cs0104)) != null)
894 static void Error_AmbiguousTypeReference (Location loc, string name, FullNamedExpression t1, FullNamedExpression t2)
896 Report.SymbolRelatedToPreviousError (t1.Type);
897 Report.SymbolRelatedToPreviousError (t2.Type);
898 Report.Error (104, loc, "`{0}' is an ambiguous reference between `{1}' and `{2}'",
899 name, t1.GetSignatureForError (), t2.GetSignatureForError ());
902 // Looks-up a alias named @name in this and surrounding namespace declarations
903 public FullNamedExpression LookupAlias (string name)
905 for (NamespaceEntry n = this; n != null; n = n.ImplicitParent) {
906 if (n.using_aliases == null)
909 foreach (UsingAliasEntry ue in n.using_aliases) {
910 if (ue.Alias == name)
911 return ue.Resolve (Doppelganger);
918 private FullNamedExpression Lookup (DeclSpace ds, string name, Location loc, bool ignore_cs0104)
921 // Check whether it's in the namespace.
923 FullNamedExpression fne = ns.Lookup (ds, name, loc);
930 if (using_aliases != null) {
931 foreach (UsingAliasEntry ue in using_aliases) {
932 if (ue.Alias == name)
933 return ue.Resolve (Doppelganger);
941 // Check using entries.
943 FullNamedExpression match = null;
944 foreach (Namespace using_ns in GetUsingTable ()) {
945 match = using_ns.Lookup (ds, name, loc);
946 if (match == null || !(match is TypeExpr))
950 Error_AmbiguousTypeReference (loc, name, fne, match);
959 Namespace [] GetUsingTable ()
961 if (namespace_using_table != null)
962 return namespace_using_table;
964 if (using_clauses == null) {
965 namespace_using_table = empty_namespaces;
966 return namespace_using_table;
969 ArrayList list = new ArrayList (using_clauses.Count);
971 foreach (UsingEntry ue in using_clauses) {
972 Namespace using_ns = ue.Resolve (Doppelganger);
973 if (using_ns == null)
979 namespace_using_table = (Namespace[])list.ToArray (typeof (Namespace));
980 return namespace_using_table;
983 static readonly string [] empty_using_list = new string [0];
985 public int SymbolFileID {
987 if (symfile_id == 0 && file.SourceFileEntry != null) {
988 int parent_id = parent == null ? 0 : parent.SymbolFileID;
990 string [] using_list = empty_using_list;
991 if (using_clauses != null) {
992 using_list = new string [using_clauses.Count];
993 for (int i = 0; i < using_clauses.Count; i++)
994 using_list [i] = ((UsingEntry) using_clauses [i]).MemberName.GetTypeName ();
997 symfile_id = SymbolWriter.DefineNamespace (ns.Name, file.CompileUnitEntry, using_list, parent_id);
1003 static void MsgtryRef (string s)
1005 Console.WriteLine (" Try using -r:" + s);
1008 static void MsgtryPkg (string s)
1010 Console.WriteLine (" Try using -pkg:" + s);
1013 public static void Error_GlobalNamespaceRedefined (Location loc)
1015 Report.Error (1681, loc, "You cannot redefine the global extern alias");
1018 public static void Error_NamespaceNotFound (Location loc, string name)
1020 Report.Error (246, loc, "The type or namespace name `{0}' could not be found. Are you missing a using directive or an assembly reference?",
1024 case "Gtk": case "GtkSharp":
1025 MsgtryPkg ("gtk-sharp");
1028 case "Gdk": case "GdkSharp":
1029 MsgtryPkg ("gdk-sharp");
1032 case "Glade": case "GladeSharp":
1033 MsgtryPkg ("glade-sharp");
1036 case "System.Drawing":
1037 case "System.Web.Services":
1040 case "System.Windows.Forms":
1047 /// Used to validate that all the using clauses are correct
1048 /// after we are finished parsing all the files.
1052 if (using_aliases != null) {
1053 foreach (UsingAliasEntry ue in using_aliases)
1054 ue.Resolve (Doppelganger);
1057 if (using_clauses != null) {
1058 foreach (UsingEntry ue in using_clauses)
1059 ue.Resolve (Doppelganger);
1064 /// Used to validate that all the using clauses are correct
1065 /// after we are finished parsing all the files.
1067 static public void VerifyAllUsing ()
1069 foreach (NamespaceEntry entry in entries)
1070 entry.VerifyUsing ();
1073 public string GetSignatureForError ()
1075 return ns.GetSignatureForError ();
1078 public override string ToString ()
1080 return ns.ToString ();
1083 #region IResolveContext Members
1085 public DeclSpace DeclContainer {
1086 get { return SlaveDeclSpace; }
1089 public bool IsInObsoleteScope {
1090 get { return SlaveDeclSpace.IsInObsoleteScope; }
1093 public bool IsInUnsafeScope {
1094 get { return SlaveDeclSpace.IsInUnsafeScope; }
1097 public DeclSpace GenericDeclContainer {
1098 get { return SlaveDeclSpace; }