2 // decl.cs: Declaration base class for structs, classes, enums and interfaces.
4 // Author: Miguel de Icaza (miguel@gnu.org)
5 // Marek Safar (marek.safar@seznam.cz)
7 // Licensed under the terms of the GNU GPL
9 // (C) 2001 Ximian, Inc (http://www.ximian.com)
11 // TODO: Move the method verification stuff from the class.cs and interface.cs here
15 using System.Collections;
16 using System.Globalization;
17 using System.Reflection.Emit;
18 using System.Reflection;
20 namespace Mono.CSharp {
22 public class MemberName {
24 public readonly MemberName Left;
26 public static readonly MemberName Null = new MemberName ("");
28 public MemberName (string name)
33 public MemberName (MemberName left, string name)
39 public MemberName (MemberName left, MemberName right)
40 : this (left, right.Name)
44 public string GetName ()
46 return GetName (false);
49 public string GetName (bool is_generic)
51 string name = is_generic ? Basename : Name;
53 return Left.GetName (is_generic) + "." + name;
59 /// This returns exclusively the name as seen on the source code
60 /// it is not the fully qualifed type after resolution
62 public string GetPartialName ()
65 return Left.GetPartialName () + "." + Name;
70 public string GetTypeName ()
73 return Left.GetTypeName () + "." + Name;
78 public Expression GetTypeExpression (Location loc)
81 Expression lexpr = Left.GetTypeExpression (loc);
83 return new MemberAccess (lexpr, Name, loc);
85 return new SimpleName (Name, loc);
89 public MemberName Clone ()
92 return new MemberName (Left.Clone (), Name);
94 return new MemberName (Name);
97 public string Basename {
103 public override string ToString ()
105 Console.WriteLine ("INTERNAL-WARNING: someone is miss-using MemberName.ToString in the compiler. Please report this bug");
106 Console.WriteLine ("From: " + Environment.StackTrace);
112 /// Base representation for members. This is used to keep track
113 /// of Name, Location and Modifier flags, and handling Attributes.
115 public abstract class MemberCore : Attributable {
121 // !(this is GenericMethod) && !(this is Method)
122 return MemberName.GetName (false);
126 // Is not readonly because of IndexerName attribute
127 public MemberName MemberName;
130 /// Modifier flags that the user specified in the source code
134 public readonly TypeContainer Parent;
137 /// Location where this declaration happens
139 public readonly Location Location;
143 Obsolete_Undetected = 1, // Obsolete attribute has not been detected yet
144 Obsolete = 1 << 1, // Type has obsolete attribute
145 ClsCompliance_Undetected = 1 << 2, // CLS Compliance has not been detected yet
146 ClsCompliant = 1 << 3, // Type is CLS Compliant
147 CloseTypeCreated = 1 << 4, // Tracks whether we have Closed the type
148 HasCompliantAttribute_Undetected = 1 << 5, // Presence of CLSCompliantAttribute has not been detected
149 HasClsCompliantAttribute = 1 << 6, // Type has CLSCompliantAttribute
150 ClsCompliantAttributeTrue = 1 << 7, // Type has CLSCompliant (true)
151 Excluded_Undetected = 1 << 8, // Conditional attribute has not been detected yet
152 Excluded = 1 << 9, // Method is conditional
153 TestMethodDuplication = 1 << 10 // Test for duplication must be performed
157 /// MemberCore flags at first detected then cached
159 internal Flags caching_flags;
161 public MemberCore (TypeContainer parent, MemberName name, Attributes attrs,
168 caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
172 /// Tests presence of ObsoleteAttribute and report proper error
174 protected void CheckUsageOfObsoleteAttribute (Type type)
179 ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
180 if (obsolete_attr == null)
183 AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, Location);
186 public abstract bool Define ();
189 // Returns full member name for error message
191 public virtual string GetSignatureForError ()
197 /// Use this method when MethodBuilder is null
199 public virtual string GetSignatureForError (TypeContainer tc)
205 /// Base Emit method. This is also entry point for CLS-Compliant verification.
207 public virtual void Emit ()
209 // Hack with Parent == null is for EnumMember
210 if (Parent == null || (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent) == null))
211 VerifyObsoleteAttribute ();
213 if (!RootContext.VerifyClsCompliance)
216 VerifyClsCompliance (Parent);
219 public bool InUnsafe {
221 return ((ModFlags & Modifiers.UNSAFE) != 0) || Parent.UnsafeContext;
226 // Whehter is it ok to use an unsafe pointer in this type container
228 public bool UnsafeOK (DeclSpace parent)
231 // First check if this MemberCore modifier flags has unsafe set
233 if ((ModFlags & Modifiers.UNSAFE) != 0)
236 if (parent.UnsafeContext)
239 Expression.UnsafeError (Location);
244 /// Returns instance of ObsoleteAttribute for this MemberCore
246 public ObsoleteAttribute GetObsoleteAttribute (DeclSpace ds)
248 // ((flags & (Flags.Obsolete_Undetected | Flags.Obsolete)) == 0) is slower, but why ?
249 if ((caching_flags & Flags.Obsolete_Undetected) == 0 && (caching_flags & Flags.Obsolete) == 0) {
253 caching_flags &= ~Flags.Obsolete_Undetected;
255 if (OptAttributes == null)
258 // TODO: remove this allocation
259 EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
260 null, null, ds.ModFlags, false);
262 Attribute obsolete_attr = OptAttributes.Search (TypeManager.obsolete_attribute_type, ec);
263 if (obsolete_attr == null)
266 ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ds);
267 if (obsolete == null)
270 caching_flags |= Flags.Obsolete;
275 /// Analyze whether CLS-Compliant verification must be execute for this MemberCore.
277 public override bool IsClsCompliaceRequired (DeclSpace container)
279 if ((caching_flags & Flags.ClsCompliance_Undetected) == 0)
280 return (caching_flags & Flags.ClsCompliant) != 0;
282 if (GetClsCompliantAttributeValue (container) && IsExposedFromAssembly (container)) {
283 caching_flags &= ~Flags.ClsCompliance_Undetected;
284 caching_flags |= Flags.ClsCompliant;
288 caching_flags &= ~Flags.ClsCompliance_Undetected;
293 /// Returns true when MemberCore is exposed from assembly.
295 protected bool IsExposedFromAssembly (DeclSpace ds)
297 if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
300 DeclSpace parentContainer = ds;
301 while (parentContainer != null && parentContainer.ModFlags != 0) {
302 if ((parentContainer.ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
304 parentContainer = parentContainer.Parent;
310 /// Resolve CLSCompliantAttribute value or gets cached value.
312 bool GetClsCompliantAttributeValue (DeclSpace ds)
314 if (OptAttributes != null) {
315 EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
316 null, null, ds.ModFlags, false);
317 Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ec);
318 if (cls_attribute != null) {
319 caching_flags |= Flags.HasClsCompliantAttribute;
320 return cls_attribute.GetClsCompliantAttributeValue (ds);
323 return ds.GetClsCompliantAttributeValue ();
327 /// Returns true if MemberCore is explicitly marked with CLSCompliantAttribute
329 protected bool HasClsCompliantAttribute {
331 return (caching_flags & Flags.HasClsCompliantAttribute) != 0;
337 /// The main virtual method for CLS-Compliant verifications.
338 /// The method returns true if member is CLS-Compliant and false if member is not
339 /// CLS-Compliant which means that CLS-Compliant tests are not necessary. A descendants override it
340 /// and add their extra verifications.
342 protected virtual bool VerifyClsCompliance (DeclSpace ds)
344 if (!IsClsCompliaceRequired (ds)) {
345 if ((RootContext.WarningLevel >= 2) && HasClsCompliantAttribute && !IsExposedFromAssembly (ds)) {
346 Report.Warning (3019, Location, "CLS compliance checking will not be performed on '{0}' because it is private or internal", GetSignatureForError ());
351 if (!CodeGen.Assembly.IsClsCompliant) {
352 if (HasClsCompliantAttribute) {
353 Report.Error (3014, Location, "'{0}' cannot be marked as CLS-compliant because the assembly does not have a CLSCompliant attribute", GetSignatureForError ());
358 int index = Name.LastIndexOf ('.');
359 if (Name [index > 0 ? index + 1 : 0] == '_') {
360 Report.Error (3008, Location, "Identifier '{0}' is not CLS-compliant", GetSignatureForError () );
365 protected abstract void VerifyObsoleteAttribute ();
370 /// Base class for structs, classes, enumerations and interfaces.
373 /// They all create new declaration spaces. This
374 /// provides the common foundation for managing those name
377 public abstract class DeclSpace : MemberCore {
379 /// this points to the actual definition that is being
380 /// created with System.Reflection.Emit
382 public TypeBuilder TypeBuilder;
385 // This is the namespace in which this typecontainer
386 // was declared. We use this to resolve names.
388 public NamespaceEntry NamespaceEntry;
390 public Hashtable Cache = new Hashtable ();
392 public string Basename;
394 protected Hashtable defined_names;
396 static string[] attribute_targets = new string [] { "type" };
398 public DeclSpace (NamespaceEntry ns, TypeContainer parent, MemberName name,
399 Attributes attrs, Location l)
400 : base (parent, name, attrs, l)
403 Basename = name.Name;
404 defined_names = new Hashtable ();
408 /// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
410 protected bool AddToContainer (MemberCore symbol, bool is_method, string fullname, string basename)
412 if (basename == Basename && !(this is Interface)) {
413 Report.SymbolRelatedToPreviousError (this);
414 Report.Error (542, "'{0}': member names cannot be the same as their enclosing type", symbol.Location, symbol.GetSignatureForError ());
418 MemberCore mc = (MemberCore)defined_names [fullname];
420 if (is_method && (mc is MethodCore || mc is IMethodData)) {
421 symbol.caching_flags |= Flags.TestMethodDuplication;
422 mc.caching_flags |= Flags.TestMethodDuplication;
427 Report.SymbolRelatedToPreviousError (mc);
428 Report.Error (102, symbol.Location, "The type '{0}' already contains a definition for '{1}'", GetSignatureForError (), basename);
432 defined_names.Add (fullname, symbol);
436 public void RecordDecl ()
438 if ((NamespaceEntry != null) && (Parent == RootContext.Tree.Types))
439 NamespaceEntry.DefineName (MemberName.Basename, this);
443 /// Returns the MemberCore associated with a given name in the declaration
444 /// space. It doesn't return method based symbols !!
447 public MemberCore GetDefinition (string name)
449 return (MemberCore)defined_names [name];
452 bool in_transit = false;
455 /// This function is used to catch recursive definitions
458 public bool InTransit {
469 /// Looks up the alias for the name
471 public string LookupAlias (string name)
473 if (NamespaceEntry != null)
474 return NamespaceEntry.LookupAlias (name);
480 // root_types contains all the types. All TopLevel types
481 // hence have a parent that points to `root_types', that is
482 // why there is a non-obvious test down here.
484 public bool IsTopLevel {
487 if (Parent.Parent == null)
494 public virtual void CloseType ()
496 if ((caching_flags & Flags.CloseTypeCreated) == 0){
498 TypeBuilder.CreateType ();
501 // The try/catch is needed because
502 // nested enumerations fail to load when they
505 // Even if this is the right order (enumerations
506 // declared after types).
508 // Note that this still creates the type and
509 // it is possible to save it
511 caching_flags |= Flags.CloseTypeCreated;
516 /// Should be overriten by the appropriate declaration space
518 public abstract TypeBuilder DefineType ();
521 /// Define all members, but don't apply any attributes or do anything which may
522 /// access not-yet-defined classes. This method also creates the MemberCache.
524 public abstract bool DefineMembers (TypeContainer parent);
527 // Whether this is an `unsafe context'
529 public bool UnsafeContext {
531 if ((ModFlags & Modifiers.UNSAFE) != 0)
534 return Parent.UnsafeContext;
539 public static string MakeFQN (string nsn, string name)
543 return String.Concat (nsn, ".", name);
546 EmitContext type_resolve_ec;
547 EmitContext GetTypeResolveEmitContext (TypeContainer parent, Location loc)
549 type_resolve_ec = new EmitContext (parent, this, loc, null, null, ModFlags, false);
550 type_resolve_ec.ResolvingTypeTree = true;
552 return type_resolve_ec;
556 // Looks up the type, as parsed into the expression `e'.
558 //[Obsolete ("This method is going away soon")]
559 public Type ResolveType (Expression e, bool silent, Location loc)
561 TypeExpr d = ResolveTypeExpr (e, silent, loc);
562 return d == null ? null : d.Type;
566 // Resolves the expression `e' for a type, and will recursively define
567 // types. This should only be used for resolving base types.
569 public TypeExpr ResolveTypeExpr (Expression e, bool silent, Location loc)
571 if (type_resolve_ec == null)
572 type_resolve_ec = GetTypeResolveEmitContext (Parent, loc);
573 type_resolve_ec.loc = loc;
574 type_resolve_ec.ContainerType = TypeBuilder;
576 return e.ResolveAsTypeTerminal (type_resolve_ec, silent);
579 public bool CheckAccessLevel (Type check_type)
581 if (check_type == TypeBuilder)
584 TypeAttributes check_attr = check_type.Attributes & TypeAttributes.VisibilityMask;
587 // Broken Microsoft runtime, return public for arrays, no matter what
588 // the accessibility is for their underlying class, and they return
589 // NonPublic visibility for pointers
591 if (check_type.IsArray || check_type.IsPointer)
592 return CheckAccessLevel (TypeManager.GetElementType (check_type));
594 if (TypeBuilder == null)
595 // FIXME: TypeBuilder will be null when invoked by Class.GetNormalBases().
596 // However, this is invoked again later -- so safe to return true.
597 // May also be null when resolving top-level attributes.
601 case TypeAttributes.Public:
604 case TypeAttributes.NotPublic:
606 // This test should probably use the declaringtype.
608 return check_type.Assembly == TypeBuilder.Assembly;
610 case TypeAttributes.NestedPublic:
613 case TypeAttributes.NestedPrivate:
614 return NestedAccessible (check_type);
616 case TypeAttributes.NestedFamily:
617 return FamilyAccessible (check_type);
619 case TypeAttributes.NestedFamANDAssem:
620 return (check_type.Assembly == TypeBuilder.Assembly) &&
621 FamilyAccessible (check_type);
623 case TypeAttributes.NestedFamORAssem:
624 return (check_type.Assembly == TypeBuilder.Assembly) ||
625 FamilyAccessible (check_type);
627 case TypeAttributes.NestedAssembly:
628 return check_type.Assembly == TypeBuilder.Assembly;
631 Console.WriteLine ("HERE: " + check_attr);
636 protected bool NestedAccessible (Type check_type)
638 string check_type_name = check_type.FullName;
640 // At this point, we already know check_type is a nested class.
641 int cio = check_type_name.LastIndexOf ('+');
643 // Ensure that the string 'container' has a '+' in it to avoid false matches
644 string container = check_type_name.Substring (0, cio + 1);
646 // Ensure that type_name ends with a '+' so that it can match 'container', if necessary
647 string type_name = TypeBuilder.FullName + "+";
649 // If the current class is nested inside the container of check_type,
650 // we can access check_type even if it is private or protected.
651 return type_name.StartsWith (container);
654 protected bool FamilyAccessible (Type check_type)
656 Type declaring = check_type.DeclaringType;
657 if (TypeBuilder == declaring ||
658 TypeBuilder.IsSubclassOf (declaring))
661 return NestedAccessible (check_type);
664 // Access level of a type.
666 enum AccessLevel { // Each column represents `is this scope larger or equal to Blah scope'
667 // Public Assembly Protected
668 Protected = (0 << 0) | (0 << 1) | (X << 2),
669 Public = (X << 0) | (X << 1) | (X << 2),
670 Private = (0 << 0) | (0 << 1) | (0 << 2),
671 Internal = (0 << 0) | (X << 1) | (0 << 2),
672 ProtectedOrInternal = (0 << 0) | (X << 1) | (X << 2),
675 static AccessLevel GetAccessLevelFromModifiers (int flags)
677 if ((flags & Modifiers.INTERNAL) != 0) {
679 if ((flags & Modifiers.PROTECTED) != 0)
680 return AccessLevel.ProtectedOrInternal;
682 return AccessLevel.Internal;
684 } else if ((flags & Modifiers.PROTECTED) != 0)
685 return AccessLevel.Protected;
687 else if ((flags & Modifiers.PRIVATE) != 0)
688 return AccessLevel.Private;
691 return AccessLevel.Public;
694 // What is the effective access level of this?
696 AccessLevel EffectiveAccessLevel {
698 AccessLevel myAccess = GetAccessLevelFromModifiers (ModFlags);
699 if (!IsTopLevel && (Parent != null))
700 return myAccess & Parent.EffectiveAccessLevel;
706 // Return the access level for type `t'
707 static AccessLevel TypeEffectiveAccessLevel (Type t)
710 return AccessLevel.Public;
711 if (t.IsNestedPrivate)
712 return AccessLevel.Private;
714 return AccessLevel.Internal;
716 // By now, it must be nested
717 AccessLevel parentLevel = TypeEffectiveAccessLevel (t.DeclaringType);
719 if (t.IsNestedPublic)
721 if (t.IsNestedAssembly)
722 return parentLevel & AccessLevel.Internal;
723 if (t.IsNestedFamily)
724 return parentLevel & AccessLevel.Protected;
725 if (t.IsNestedFamORAssem)
726 return parentLevel & AccessLevel.ProtectedOrInternal;
727 if (t.IsNestedFamANDAssem)
728 throw new NotImplementedException ("NestedFamANDAssem not implemented, cant make this kind of type from c# anyways");
730 // nested private is taken care of
732 throw new Exception ("I give up, what are you?");
736 // This answers `is the type P, as accessible as a member M which has the
737 // accessability @flags which is declared as a nested member of the type T, this declspace'
739 public bool AsAccessible (Type p, int flags)
742 // 1) if M is private, its accessability is the same as this declspace.
743 // we already know that P is accessible to T before this method, so we
747 if ((flags & Modifiers.PRIVATE) != 0)
750 while (p.IsArray || p.IsPointer || p.IsByRef)
751 p = TypeManager.GetElementType (p);
753 AccessLevel pAccess = TypeEffectiveAccessLevel (p);
754 AccessLevel mAccess = this.EffectiveAccessLevel &
755 GetAccessLevelFromModifiers (flags);
757 // for every place from which we can access M, we must
758 // be able to access P as well. So, we want
759 // For every bit in M and P, M_i -> P_1 == true
760 // or, ~ (M -> P) == 0 <-> ~ ( ~M | P) == 0
762 return ~ (~ mAccess | pAccess) == 0;
765 static DoubleHash dh = new DoubleHash (1000);
767 Type DefineTypeAndParents (DeclSpace tc)
769 DeclSpace container = tc.Parent;
771 if (container.TypeBuilder == null && container.Name != "")
772 DefineTypeAndParents (container);
774 return tc.DefineType ();
777 Type LookupInterfaceOrClass (string ns, string name, out bool error)
784 int p = name.LastIndexOf ('.');
786 if (dh.Lookup (ns, name, out r))
790 // If the type is not a nested type, we do not need `LookupType's processing.
791 // If the @name does not have a `.' in it, this cant be a nested type.
794 if (Namespace.IsNamespace (ns)) {
796 t = TypeManager.LookupType (ns + "." + name);
798 t = TypeManager.LookupTypeDirect (ns + "." + name);
802 t = TypeManager.LookupType (name);
804 t = TypeManager.LookupTypeDirect (name);
808 dh.Insert (ns, name, t);
813 // In case we are fed a composite name, normalize it.
817 ns = MakeFQN (ns, name.Substring (0, p));
818 name = name.Substring (p+1);
821 parent = RootContext.Tree.LookupByNamespace (ns, name);
822 if (parent == null) {
823 dh.Insert (ns, name, null);
827 t = DefineTypeAndParents (parent);
833 dh.Insert (ns, name, t);
837 public static void Error_AmbiguousTypeReference (Location loc, string name, Type t1, Type t2)
839 Report.Error (104, loc,
840 String.Format ("`{0}' is an ambiguous reference ({1} or {2}) ", name,
841 t1.FullName, t2.FullName));
845 /// GetType is used to resolve type names at the DeclSpace level.
846 /// Use this to lookup class/struct bases, interface bases or
847 /// delegate type references
851 /// Contrast this to LookupType which is used inside method bodies to
852 /// lookup types that have already been defined. GetType is used
853 /// during the tree resolution process and potentially define
854 /// recursively the type
856 public Type FindType (Location loc, string name)
862 // For the case the type we are looking for is nested within this one
863 // or is in any base class
865 DeclSpace containing_ds = this;
867 while (containing_ds != null){
868 Type container_type = containing_ds.TypeBuilder;
869 Type current_type = container_type;
871 while (current_type != null && current_type != TypeManager.object_type) {
872 string pre = current_type.FullName;
874 t = LookupInterfaceOrClass (pre, name, out error);
878 if ((t != null) && containing_ds.CheckAccessLevel (t))
881 current_type = current_type.BaseType;
883 containing_ds = containing_ds.Parent;
887 // Attempt to lookup the class on our namespace and all it's implicit parents
889 for (NamespaceEntry ns = NamespaceEntry; ns != null; ns = ns.ImplicitParent) {
890 t = LookupInterfaceOrClass (ns.FullName, name, out error);
899 // Attempt to do a direct unqualified lookup
901 t = LookupInterfaceOrClass ("", name, out error);
909 // Attempt to lookup the class on any of the `using'
913 for (NamespaceEntry ns = NamespaceEntry; ns != null; ns = ns.Parent){
915 t = LookupInterfaceOrClass (ns.FullName, name, out error);
922 if (name.IndexOf ('.') > 0)
925 string alias_value = ns.LookupAlias (name);
926 if (alias_value != null) {
927 t = LookupInterfaceOrClass ("", alias_value, out error);
936 // Now check the using clause list
939 foreach (Namespace using_ns in ns.GetUsingTable ()) {
940 match = LookupInterfaceOrClass (using_ns.Name, name, out error);
946 if (CheckAccessLevel (match)) {
947 Error_AmbiguousTypeReference (loc, name, t, match);
960 //Report.Error (246, Location, "Can not find type `"+name+"'");
965 /// This function is broken and not what you're looking for. It should only
966 /// be used while the type is still being created since it doesn't use the cache
967 /// and relies on the filter doing the member name check.
969 public abstract MemberList FindMembers (MemberTypes mt, BindingFlags bf,
970 MemberFilter filter, object criteria);
973 /// If we have a MemberCache, return it. This property may return null if the
974 /// class doesn't have a member cache or while it's still being created.
976 public abstract MemberCache MemberCache {
980 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
983 TypeBuilder.SetCustomAttribute (cb);
984 } catch (System.ArgumentException e) {
985 Report.Warning (-21, a.Location,
986 "The CharSet named property on StructLayout\n"+
987 "\tdoes not work correctly on Microsoft.NET\n"+
988 "\tYou might want to remove the CharSet declaration\n"+
989 "\tor compile using the Mono runtime instead of the\n"+
990 "\tMicrosoft .NET runtime\n"+
991 "\tThe runtime gave the error: " + e);
996 /// Goes through class hierarchy and get value of first CLSCompliantAttribute that found.
997 /// If no is attribute exists then return assembly CLSCompliantAttribute.
999 public bool GetClsCompliantAttributeValue ()
1001 if ((caching_flags & Flags.HasCompliantAttribute_Undetected) == 0)
1002 return (caching_flags & Flags.ClsCompliantAttributeTrue) != 0;
1004 caching_flags &= ~Flags.HasCompliantAttribute_Undetected;
1006 if (OptAttributes != null) {
1007 EmitContext ec = new EmitContext (Parent, this, Location,
1008 null, null, ModFlags, false);
1009 Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ec);
1010 if (cls_attribute != null) {
1011 caching_flags |= Flags.HasClsCompliantAttribute;
1012 if (cls_attribute.GetClsCompliantAttributeValue (this)) {
1013 caching_flags |= Flags.ClsCompliantAttributeTrue;
1020 if (Parent == null) {
1021 if (CodeGen.Assembly.IsClsCompliant) {
1022 caching_flags |= Flags.ClsCompliantAttributeTrue;
1028 if (Parent.GetClsCompliantAttributeValue ()) {
1029 caching_flags |= Flags.ClsCompliantAttributeTrue;
1035 public override string[] ValidAttributeTargets {
1037 return attribute_targets;
1043 /// This is a readonly list of MemberInfo's.
1045 public class MemberList : IList {
1046 public readonly IList List;
1050 /// Create a new MemberList from the given IList.
1052 public MemberList (IList list)
1057 this.List = new ArrayList ();
1062 /// Concatenate the ILists `first' and `second' to a new MemberList.
1064 public MemberList (IList first, IList second)
1066 ArrayList list = new ArrayList ();
1067 list.AddRange (first);
1068 list.AddRange (second);
1073 public static readonly MemberList Empty = new MemberList (new ArrayList ());
1076 /// Cast the MemberList into a MemberInfo[] array.
1079 /// This is an expensive operation, only use it if it's really necessary.
1081 public static explicit operator MemberInfo [] (MemberList list)
1083 Timer.StartTimer (TimerType.MiscTimer);
1084 MemberInfo [] result = new MemberInfo [list.Count];
1085 list.CopyTo (result, 0);
1086 Timer.StopTimer (TimerType.MiscTimer);
1098 public bool IsSynchronized {
1100 return List.IsSynchronized;
1104 public object SyncRoot {
1106 return List.SyncRoot;
1110 public void CopyTo (Array array, int index)
1112 List.CopyTo (array, index);
1117 public IEnumerator GetEnumerator ()
1119 return List.GetEnumerator ();
1124 public bool IsFixedSize {
1130 public bool IsReadOnly {
1136 object IList.this [int index] {
1138 return List [index];
1142 throw new NotSupportedException ();
1146 // FIXME: try to find out whether we can avoid the cast in this indexer.
1147 public MemberInfo this [int index] {
1149 return (MemberInfo) List [index];
1153 public int Add (object value)
1155 throw new NotSupportedException ();
1158 public void Clear ()
1160 throw new NotSupportedException ();
1163 public bool Contains (object value)
1165 return List.Contains (value);
1168 public int IndexOf (object value)
1170 return List.IndexOf (value);
1173 public void Insert (int index, object value)
1175 throw new NotSupportedException ();
1178 public void Remove (object value)
1180 throw new NotSupportedException ();
1183 public void RemoveAt (int index)
1185 throw new NotSupportedException ();
1190 /// This interface is used to get all members of a class when creating the
1191 /// member cache. It must be implemented by all DeclSpace derivatives which
1192 /// want to support the member cache and by TypeHandle to get caching of
1193 /// non-dynamic types.
1195 public interface IMemberContainer {
1197 /// The name of the IMemberContainer. This is only used for
1198 /// debugging purposes.
1205 /// The type of this IMemberContainer.
1212 /// Returns the IMemberContainer of the parent class or null if this
1213 /// is an interface or TypeManger.object_type.
1214 /// This is used when creating the member cache for a class to get all
1215 /// members from the parent class.
1217 MemberCache ParentCache {
1222 /// Whether this is an interface.
1229 /// Returns all members of this class with the corresponding MemberTypes
1230 /// and BindingFlags.
1233 /// When implementing this method, make sure not to return any inherited
1234 /// members and check the MemberTypes and BindingFlags properly.
1235 /// Unfortunately, System.Reflection is lame and doesn't provide a way to
1236 /// get the BindingFlags (static/non-static,public/non-public) in the
1237 /// MemberInfo class, but the cache needs this information. That's why
1238 /// this method is called multiple times with different BindingFlags.
1240 MemberList GetMembers (MemberTypes mt, BindingFlags bf);
1243 /// Return the container's member cache.
1245 MemberCache MemberCache {
1251 /// The MemberCache is used by dynamic and non-dynamic types to speed up
1252 /// member lookups. It has a member name based hash table; it maps each member
1253 /// name to a list of CacheEntry objects. Each CacheEntry contains a MemberInfo
1254 /// and the BindingFlags that were initially used to get it. The cache contains
1255 /// all members of the current class and all inherited members. If this cache is
1256 /// for an interface types, it also contains all inherited members.
1258 /// There are two ways to get a MemberCache:
1259 /// * if this is a dynamic type, lookup the corresponding DeclSpace and then
1260 /// use the DeclSpace.MemberCache property.
1261 /// * if this not a dynamic type, call TypeHandle.GetTypeHandle() to get a
1262 /// TypeHandle instance for the type and then use TypeHandle.MemberCache.
1264 public class MemberCache {
1265 public readonly IMemberContainer Container;
1266 protected Hashtable member_hash;
1267 protected Hashtable method_hash;
1270 /// Create a new MemberCache for the given IMemberContainer `container'.
1272 public MemberCache (IMemberContainer container)
1274 this.Container = container;
1276 Timer.IncrementCounter (CounterType.MemberCache);
1277 Timer.StartTimer (TimerType.CacheInit);
1279 // If we have a parent class (we have a parent class unless we're
1280 // TypeManager.object_type), we deep-copy its MemberCache here.
1281 if (Container.ParentCache != null)
1282 member_hash = SetupCache (Container.ParentCache);
1284 member_hash = new Hashtable ();
1286 // If this is neither a dynamic type nor an interface, create a special
1287 // method cache with all declared and inherited methods.
1288 Type type = container.Type;
1289 if (!(type is TypeBuilder) && !type.IsInterface) {
1290 method_hash = new Hashtable ();
1294 // Add all members from the current class.
1295 AddMembers (Container);
1297 Timer.StopTimer (TimerType.CacheInit);
1300 public MemberCache (Type[] ifaces)
1303 // The members of this cache all belong to other caches.
1304 // So, 'Container' will not be used.
1306 this.Container = null;
1308 member_hash = new Hashtable ();
1312 foreach (Type itype in ifaces)
1313 AddCacheContents (TypeManager.LookupMemberCache (itype));
1317 /// Bootstrap this member cache by doing a deep-copy of our parent.
1319 Hashtable SetupCache (MemberCache parent)
1321 Hashtable hash = new Hashtable ();
1326 IDictionaryEnumerator it = parent.member_hash.GetEnumerator ();
1327 while (it.MoveNext ()) {
1328 hash [it.Key] = ((ArrayList) it.Value).Clone ();
1335 /// Add the contents of `cache' to the member_hash.
1337 void AddCacheContents (MemberCache cache)
1339 IDictionaryEnumerator it = cache.member_hash.GetEnumerator ();
1340 while (it.MoveNext ()) {
1341 ArrayList list = (ArrayList) member_hash [it.Key];
1343 member_hash [it.Key] = list = new ArrayList ();
1345 ArrayList entries = (ArrayList) it.Value;
1346 for (int i = entries.Count-1; i >= 0; i--) {
1347 CacheEntry entry = (CacheEntry) entries [i];
1349 if (entry.Container != cache.Container)
1357 /// Add all members from class `container' to the cache.
1359 void AddMembers (IMemberContainer container)
1361 // We need to call AddMembers() with a single member type at a time
1362 // to get the member type part of CacheEntry.EntryType right.
1363 if (!container.IsInterface) {
1364 AddMembers (MemberTypes.Constructor, container);
1365 AddMembers (MemberTypes.Field, container);
1367 AddMembers (MemberTypes.Method, container);
1368 AddMembers (MemberTypes.Property, container);
1369 AddMembers (MemberTypes.Event, container);
1370 // Nested types are returned by both Static and Instance searches.
1371 AddMembers (MemberTypes.NestedType,
1372 BindingFlags.Static | BindingFlags.Public, container);
1373 AddMembers (MemberTypes.NestedType,
1374 BindingFlags.Static | BindingFlags.NonPublic, container);
1377 void AddMembers (MemberTypes mt, IMemberContainer container)
1379 AddMembers (mt, BindingFlags.Static | BindingFlags.Public, container);
1380 AddMembers (mt, BindingFlags.Static | BindingFlags.NonPublic, container);
1381 AddMembers (mt, BindingFlags.Instance | BindingFlags.Public, container);
1382 AddMembers (mt, BindingFlags.Instance | BindingFlags.NonPublic, container);
1386 /// Add all members from class `container' with the requested MemberTypes and
1387 /// BindingFlags to the cache. This method is called multiple times with different
1388 /// MemberTypes and BindingFlags.
1390 void AddMembers (MemberTypes mt, BindingFlags bf, IMemberContainer container)
1392 MemberList members = container.GetMembers (mt, bf);
1394 foreach (MemberInfo member in members) {
1395 string name = member.Name;
1397 // We use a name-based hash table of ArrayList's.
1398 ArrayList list = (ArrayList) member_hash [name];
1400 list = new ArrayList ();
1401 member_hash.Add (name, list);
1404 // When this method is called for the current class, the list will
1405 // already contain all inherited members from our parent classes.
1406 // We cannot add new members in front of the list since this'd be an
1407 // expensive operation, that's why the list is sorted in reverse order
1408 // (ie. members from the current class are coming last).
1409 list.Add (new CacheEntry (container, member, mt, bf));
1414 /// Add all declared and inherited methods from class `type' to the method cache.
1416 void AddMethods (Type type)
1418 AddMethods (BindingFlags.Static | BindingFlags.Public |
1419 BindingFlags.FlattenHierarchy, type);
1420 AddMethods (BindingFlags.Static | BindingFlags.NonPublic |
1421 BindingFlags.FlattenHierarchy, type);
1422 AddMethods (BindingFlags.Instance | BindingFlags.Public, type);
1423 AddMethods (BindingFlags.Instance | BindingFlags.NonPublic, type);
1426 void AddMethods (BindingFlags bf, Type type)
1428 MemberInfo [] members = type.GetMethods (bf);
1430 Array.Reverse (members);
1432 foreach (MethodBase member in members) {
1433 string name = member.Name;
1435 // We use a name-based hash table of ArrayList's.
1436 ArrayList list = (ArrayList) method_hash [name];
1438 list = new ArrayList ();
1439 method_hash.Add (name, list);
1442 // Unfortunately, the elements returned by Type.GetMethods() aren't
1443 // sorted so we need to do this check for every member.
1444 BindingFlags new_bf = bf;
1445 if (member.DeclaringType == type)
1446 new_bf |= BindingFlags.DeclaredOnly;
1448 list.Add (new CacheEntry (Container, member, MemberTypes.Method, new_bf));
1455 /// Compute and return a appropriate `EntryType' magic number for the given
1456 /// MemberTypes and BindingFlags.
1458 protected static EntryType GetEntryType (MemberTypes mt, BindingFlags bf)
1460 EntryType type = EntryType.None;
1462 if ((mt & MemberTypes.Constructor) != 0)
1463 type |= EntryType.Constructor;
1464 if ((mt & MemberTypes.Event) != 0)
1465 type |= EntryType.Event;
1466 if ((mt & MemberTypes.Field) != 0)
1467 type |= EntryType.Field;
1468 if ((mt & MemberTypes.Method) != 0)
1469 type |= EntryType.Method;
1470 if ((mt & MemberTypes.Property) != 0)
1471 type |= EntryType.Property;
1472 // Nested types are returned by static and instance searches.
1473 if ((mt & MemberTypes.NestedType) != 0)
1474 type |= EntryType.NestedType | EntryType.Static | EntryType.Instance;
1476 if ((bf & BindingFlags.Instance) != 0)
1477 type |= EntryType.Instance;
1478 if ((bf & BindingFlags.Static) != 0)
1479 type |= EntryType.Static;
1480 if ((bf & BindingFlags.Public) != 0)
1481 type |= EntryType.Public;
1482 if ((bf & BindingFlags.NonPublic) != 0)
1483 type |= EntryType.NonPublic;
1484 if ((bf & BindingFlags.DeclaredOnly) != 0)
1485 type |= EntryType.Declared;
1491 /// The `MemberTypes' enumeration type is a [Flags] type which means that it may
1492 /// denote multiple member types. Returns true if the given flags value denotes a
1493 /// single member types.
1495 public static bool IsSingleMemberType (MemberTypes mt)
1498 case MemberTypes.Constructor:
1499 case MemberTypes.Event:
1500 case MemberTypes.Field:
1501 case MemberTypes.Method:
1502 case MemberTypes.Property:
1503 case MemberTypes.NestedType:
1512 /// We encode the MemberTypes and BindingFlags of each members in a "magic"
1513 /// number to speed up the searching process.
1516 protected enum EntryType {
1521 MaskStatic = Instance|Static,
1525 MaskProtection = Public|NonPublic,
1529 Constructor = 0x020,
1536 MaskType = Constructor|Event|Field|Method|Property|NestedType
1539 protected struct CacheEntry {
1540 public readonly IMemberContainer Container;
1541 public readonly EntryType EntryType;
1542 public readonly MemberInfo Member;
1544 public CacheEntry (IMemberContainer container, MemberInfo member,
1545 MemberTypes mt, BindingFlags bf)
1547 this.Container = container;
1548 this.Member = member;
1549 this.EntryType = GetEntryType (mt, bf);
1552 public override string ToString ()
1554 return String.Format ("CacheEntry ({0}:{1}:{2})", Container.Name,
1560 /// This is called each time we're walking up one level in the class hierarchy
1561 /// and checks whether we can abort the search since we've already found what
1562 /// we were looking for.
1564 protected bool DoneSearching (ArrayList list)
1567 // We've found exactly one member in the current class and it's not
1568 // a method or constructor.
1570 if (list.Count == 1 && !(list [0] is MethodBase))
1574 // Multiple properties: we query those just to find out the indexer
1577 if ((list.Count > 0) && (list [0] is PropertyInfo))
1584 /// Looks up members with name `name'. If you provide an optional
1585 /// filter function, it'll only be called with members matching the
1586 /// requested member name.
1588 /// This method will try to use the cache to do the lookup if possible.
1590 /// Unlike other FindMembers implementations, this method will always
1591 /// check all inherited members - even when called on an interface type.
1593 /// If you know that you're only looking for methods, you should use
1594 /// MemberTypes.Method alone since this speeds up the lookup a bit.
1595 /// When doing a method-only search, it'll try to use a special method
1596 /// cache (unless it's a dynamic type or an interface) and the returned
1597 /// MemberInfo's will have the correct ReflectedType for inherited methods.
1598 /// The lookup process will automatically restart itself in method-only
1599 /// search mode if it discovers that it's about to return methods.
1601 ArrayList global = new ArrayList ();
1602 bool using_global = false;
1604 static MemberInfo [] emptyMemberInfo = new MemberInfo [0];
1606 public MemberInfo [] FindMembers (MemberTypes mt, BindingFlags bf, string name,
1607 MemberFilter filter, object criteria)
1610 throw new Exception ();
1612 bool declared_only = (bf & BindingFlags.DeclaredOnly) != 0;
1613 bool method_search = mt == MemberTypes.Method;
1614 // If we have a method cache and we aren't already doing a method-only search,
1615 // then we restart a method search if the first match is a method.
1616 bool do_method_search = !method_search && (method_hash != null);
1618 ArrayList applicable;
1620 // If this is a method-only search, we try to use the method cache if
1621 // possible; a lookup in the method cache will return a MemberInfo with
1622 // the correct ReflectedType for inherited methods.
1624 if (method_search && (method_hash != null))
1625 applicable = (ArrayList) method_hash [name];
1627 applicable = (ArrayList) member_hash [name];
1629 if (applicable == null)
1630 return emptyMemberInfo;
1633 // 32 slots gives 53 rss/54 size
1634 // 2/4 slots gives 55 rss
1636 // Strange: from 25,000 calls, only 1,800
1637 // are above 2. Why does this impact it?
1640 using_global = true;
1642 Timer.StartTimer (TimerType.CachedLookup);
1644 EntryType type = GetEntryType (mt, bf);
1646 IMemberContainer current = Container;
1649 // `applicable' is a list of all members with the given member name `name'
1650 // in the current class and all its parent classes. The list is sorted in
1651 // reverse order due to the way how the cache is initialy created (to speed
1652 // things up, we're doing a deep-copy of our parent).
1654 for (int i = applicable.Count-1; i >= 0; i--) {
1655 CacheEntry entry = (CacheEntry) applicable [i];
1657 // This happens each time we're walking one level up in the class
1658 // hierarchy. If we're doing a DeclaredOnly search, we must abort
1659 // the first time this happens (this may already happen in the first
1660 // iteration of this loop if there are no members with the name we're
1661 // looking for in the current class).
1662 if (entry.Container != current) {
1663 if (declared_only || DoneSearching (global))
1666 current = entry.Container;
1669 // Is the member of the correct type ?
1670 if ((entry.EntryType & type & EntryType.MaskType) == 0)
1673 // Is the member static/non-static ?
1674 if ((entry.EntryType & type & EntryType.MaskStatic) == 0)
1677 // Apply the filter to it.
1678 if (filter (entry.Member, criteria)) {
1679 if ((entry.EntryType & EntryType.MaskType) != EntryType.Method)
1680 do_method_search = false;
1681 global.Add (entry.Member);
1685 Timer.StopTimer (TimerType.CachedLookup);
1687 // If we have a method cache and we aren't already doing a method-only
1688 // search, we restart in method-only search mode if the first match is
1689 // a method. This ensures that we return a MemberInfo with the correct
1690 // ReflectedType for inherited methods.
1691 if (do_method_search && (global.Count > 0)){
1692 using_global = false;
1694 return FindMembers (MemberTypes.Method, bf, name, filter, criteria);
1697 using_global = false;
1698 MemberInfo [] copy = new MemberInfo [global.Count];
1699 global.CopyTo (copy);
1703 // find the nested type @name in @this.
1704 public Type FindNestedType (string name)
1706 ArrayList applicable = (ArrayList) member_hash [name];
1707 if (applicable == null)
1710 for (int i = applicable.Count-1; i >= 0; i--) {
1711 CacheEntry entry = (CacheEntry) applicable [i];
1712 if ((entry.EntryType & EntryType.NestedType & EntryType.MaskType) != 0)
1713 return (Type) entry.Member;
1720 // This finds the method or property for us to override. invocationType is the type where
1721 // the override is going to be declared, name is the name of the method/property, and
1722 // paramTypes is the parameters, if any to the method or property
1724 // Because the MemberCache holds members from this class and all the base classes,
1725 // we can avoid tons of reflection stuff.
1727 public MemberInfo FindMemberToOverride (Type invocationType, string name, Type [] paramTypes, bool is_property)
1729 ArrayList applicable;
1730 if (method_hash != null && !is_property)
1731 applicable = (ArrayList) method_hash [name];
1733 applicable = (ArrayList) member_hash [name];
1735 if (applicable == null)
1738 // Walk the chain of methods, starting from the top.
1740 for (int i = applicable.Count - 1; i >= 0; i--) {
1741 CacheEntry entry = (CacheEntry) applicable [i];
1743 if ((entry.EntryType & (is_property ? (EntryType.Property | EntryType.Field) : EntryType.Method)) == 0)
1746 PropertyInfo pi = null;
1747 MethodInfo mi = null;
1748 FieldInfo fi = null;
1749 Type [] cmpAttrs = null;
1752 if ((entry.EntryType & EntryType.Field) != 0) {
1753 fi = (FieldInfo)entry.Member;
1755 // TODO: For this case we ignore member type
1756 //fb = TypeManager.GetField (fi);
1757 //cmpAttrs = new Type[] { fb.MemberType };
1759 pi = (PropertyInfo) entry.Member;
1760 cmpAttrs = TypeManager.GetArgumentTypes (pi);
1763 mi = (MethodInfo) entry.Member;
1764 cmpAttrs = TypeManager.GetArgumentTypes (mi);
1768 // TODO: Almost duplicate !
1770 switch (fi.Attributes & FieldAttributes.FieldAccessMask) {
1771 case FieldAttributes.Private:
1773 // A private method is Ok if we are a nested subtype.
1774 // The spec actually is not very clear about this, see bug 52458.
1776 if (invocationType != entry.Container.Type &
1777 TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
1781 case FieldAttributes.FamANDAssem:
1782 case FieldAttributes.Assembly:
1784 // Check for assembly methods
1786 if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
1790 return entry.Member;
1794 // Check the arguments
1796 if (cmpAttrs.Length != paramTypes.Length)
1799 for (int j = cmpAttrs.Length - 1; j >= 0; j --)
1800 if (paramTypes [j] != cmpAttrs [j])
1804 // get one of the methods because this has the visibility info.
1807 mi = pi.GetGetMethod (true);
1809 mi = pi.GetSetMethod (true);
1815 switch (mi.Attributes & MethodAttributes.MemberAccessMask) {
1816 case MethodAttributes.Private:
1818 // A private method is Ok if we are a nested subtype.
1819 // The spec actually is not very clear about this, see bug 52458.
1821 if (invocationType == entry.Container.Type ||
1822 TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
1823 return entry.Member;
1826 case MethodAttributes.FamANDAssem:
1827 case MethodAttributes.Assembly:
1829 // Check for assembly methods
1831 if (mi.DeclaringType.Assembly == CodeGen.Assembly.Builder)
1832 return entry.Member;
1837 // A protected method is ok, because we are overriding.
1838 // public is always ok.
1840 return entry.Member;
1850 /// The method is looking for conflict with inherited symbols (errors CS0108, CS0109).
1851 /// We handle two cases. The first is for types without parameters (events, field, properties).
1852 /// The second are methods, indexers and this is why ignore_complex_types is here.
1853 /// The latest param is temporary hack. See DoDefineMembers method for more info.
1855 public MemberInfo FindMemberWithSameName (string name, bool ignore_complex_types, MemberInfo ignore_member)
1857 ArrayList applicable = null;
1859 if (method_hash != null)
1860 applicable = (ArrayList) method_hash [name];
1862 if (applicable != null) {
1863 for (int i = applicable.Count - 1; i >= 0; i--) {
1864 CacheEntry entry = (CacheEntry) applicable [i];
1865 if ((entry.EntryType & EntryType.Public) != 0)
1866 return entry.Member;
1870 if (member_hash == null)
1872 applicable = (ArrayList) member_hash [name];
1874 if (applicable != null) {
1875 for (int i = applicable.Count - 1; i >= 0; i--) {
1876 CacheEntry entry = (CacheEntry) applicable [i];
1877 if ((entry.EntryType & EntryType.Public) != 0 & entry.Member != ignore_member) {
1878 if (ignore_complex_types) {
1879 if ((entry.EntryType & EntryType.Method) != 0)
1882 // Does exist easier way how to detect indexer ?
1883 if ((entry.EntryType & EntryType.Property) != 0) {
1884 Type[] arg_types = TypeManager.GetArgumentTypes ((PropertyInfo)entry.Member);
1885 if (arg_types.Length > 0)
1889 return entry.Member;
1896 Hashtable locase_table;
1899 /// Builds low-case table for CLS Compliance test
1901 public Hashtable GetPublicMembers ()
1903 if (locase_table != null)
1904 return locase_table;
1906 locase_table = new Hashtable ();
1907 foreach (DictionaryEntry entry in member_hash) {
1908 ArrayList members = (ArrayList)entry.Value;
1909 for (int ii = 0; ii < members.Count; ++ii) {
1910 CacheEntry member_entry = (CacheEntry) members [ii];
1912 if ((member_entry.EntryType & EntryType.Public) == 0)
1915 // TODO: Does anyone know easier way how to detect that member is internal ?
1916 switch (member_entry.EntryType & EntryType.MaskType) {
1917 case EntryType.Constructor:
1920 case EntryType.Field:
1921 if ((((FieldInfo)member_entry.Member).Attributes & (FieldAttributes.Assembly | FieldAttributes.Public)) == FieldAttributes.Assembly)
1925 case EntryType.Method:
1926 if ((((MethodInfo)member_entry.Member).Attributes & (MethodAttributes.Assembly | MethodAttributes.Public)) == MethodAttributes.Assembly)
1930 case EntryType.Property:
1931 PropertyInfo pi = (PropertyInfo)member_entry.Member;
1932 if (pi.GetSetMethod () == null && pi.GetGetMethod () == null)
1936 case EntryType.Event:
1937 EventInfo ei = (EventInfo)member_entry.Member;
1938 MethodInfo mi = ei.GetAddMethod ();
1939 if ((mi.Attributes & (MethodAttributes.Assembly | MethodAttributes.Public)) == MethodAttributes.Assembly)
1943 string lcase = ((string)entry.Key).ToLower (System.Globalization.CultureInfo.InvariantCulture);
1944 locase_table [lcase] = member_entry.Member;
1948 return locase_table;
1951 public Hashtable Members {
1958 /// Cls compliance check whether methods or constructors parameters differing only in ref or out, or in array rank
1960 public void VerifyClsParameterConflict (ArrayList al, MethodCore method, MemberInfo this_builder)
1962 EntryType tested_type = (method is Constructor ? EntryType.Constructor : EntryType.Method) | EntryType.Public;
1964 for (int i = 0; i < al.Count; ++i) {
1965 MemberCache.CacheEntry entry = (MemberCache.CacheEntry) al [i];
1968 if (entry.Member == this_builder)
1971 if ((entry.EntryType & tested_type) != tested_type)
1974 MethodBase method_to_compare = (MethodBase)entry.Member;
1975 if (AttributeTester.AreOverloadedMethodParamsClsCompliant (method.ParameterTypes, TypeManager.GetArgumentTypes (method_to_compare)))
1978 IMethodData md = TypeManager.GetMethod (method_to_compare);
1980 // TODO: now we are ignoring CLSCompliance(false) on method from other assembly which is buggy.
1981 // However it is exactly what csc does.
1982 if (md != null && !md.IsClsCompliaceRequired (method.Parent))
1985 Report.SymbolRelatedToPreviousError (entry.Member);
1986 Report.Error (3006, method.Location, "Overloaded method '{0}' differing only in ref or out, or in array rank, is not CLS-compliant", method.GetSignatureForError ());