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 {
23 /// Base representation for members. This is used to keep track
24 /// of Name, Location and Modifier flags, and handling Attributes.
26 public abstract class MemberCore : Attributable {
33 /// Modifier flags that the user specified in the source code
37 public readonly TypeContainer Parent;
40 /// Location where this declaration happens
42 public readonly Location Location;
46 Obsolete_Undetected = 1, // Obsolete attribute has not been detected yet
47 Obsolete = 1 << 1, // Type has obsolete attribute
48 ClsCompliance_Undetected = 1 << 2, // CLS Compliance has not been detected yet
49 ClsCompliant = 1 << 3, // Type is CLS Compliant
50 CloseTypeCreated = 1 << 4, // Tracks whether we have Closed the type
51 HasCompliantAttribute_Undetected = 1 << 5, // Presence of CLSCompliantAttribute has not been detected
52 HasClsCompliantAttribute = 1 << 6, // Type has CLSCompliantAttribute
53 ClsCompliantAttributeTrue = 1 << 7, // Type has CLSCompliant (true)
54 Excluded_Undetected = 1 << 8, // Conditional attribute has not been detected yet
55 Excluded = 1 << 9 // Method is conditional
60 /// MemberCore flags at first detected then cached
62 protected Flags caching_flags;
64 public MemberCore (TypeContainer parent, string name, Attributes attrs,
71 caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
75 /// Tests presence of ObsoleteAttribute and report proper error
77 protected void CheckUsageOfObsoleteAttribute (Type type)
82 ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
83 if (obsolete_attr == null)
86 AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, Location);
89 public abstract bool Define ();
92 // Returns full member name for error message
94 public virtual string GetSignatureForError ()
100 /// Use this method when MethodBuilder is null
102 public virtual string GetSignatureForError (TypeContainer tc)
108 /// Base Emit method. This is also entry point for CLS-Compliant verification.
110 public virtual void Emit ()
112 VerifyObsoleteAttribute ();
114 if (!RootContext.VerifyClsCompliance)
117 VerifyClsCompliance (Parent);
121 // Whehter is it ok to use an unsafe pointer in this type container
123 public bool UnsafeOK (DeclSpace parent)
126 // First check if this MemberCore modifier flags has unsafe set
128 if ((ModFlags & Modifiers.UNSAFE) != 0)
131 if (parent.UnsafeContext)
134 Expression.UnsafeError (Location);
139 /// Returns instance of ObsoleteAttribute for this MemberCore
141 public ObsoleteAttribute GetObsoleteAttribute (DeclSpace ds)
143 // ((flags & (Flags.Obsolete_Undetected | Flags.Obsolete)) == 0) is slower, but why ?
144 if ((caching_flags & Flags.Obsolete_Undetected) == 0 && (caching_flags & Flags.Obsolete) == 0) {
148 caching_flags &= ~Flags.Obsolete_Undetected;
150 if (OptAttributes == null)
153 // TODO: remove this allocation
154 EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
155 null, null, ds.ModFlags, false);
157 Attribute obsolete_attr = OptAttributes.Search (TypeManager.obsolete_attribute_type, ec);
158 if (obsolete_attr == null)
161 ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ds);
162 if (obsolete == null)
165 caching_flags |= Flags.Obsolete;
170 /// Analyze whether CLS-Compliant verification must be execute for this MemberCore.
172 public override bool IsClsCompliaceRequired (DeclSpace container)
174 if ((caching_flags & Flags.ClsCompliance_Undetected) == 0)
175 return (caching_flags & Flags.ClsCompliant) != 0;
177 if (GetClsCompliantAttributeValue (container) && IsExposedFromAssembly (container)) {
178 caching_flags &= ~Flags.ClsCompliance_Undetected;
179 caching_flags |= Flags.ClsCompliant;
183 caching_flags &= ~Flags.ClsCompliance_Undetected;
188 /// Returns true when MemberCore is exposed from assembly.
190 protected bool IsExposedFromAssembly (DeclSpace ds)
192 if ((ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
195 DeclSpace parentContainer = ds;
196 while (parentContainer != null && parentContainer.ModFlags != 0) {
197 if ((parentContainer.ModFlags & (Modifiers.PUBLIC | Modifiers.PROTECTED)) == 0)
199 parentContainer = parentContainer.Parent;
205 /// Resolve CLSCompliantAttribute value or gets cached value.
207 bool GetClsCompliantAttributeValue (DeclSpace ds)
209 if (OptAttributes != null) {
210 EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
211 null, null, ds.ModFlags, false);
212 Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ec);
213 if (cls_attribute != null) {
214 caching_flags |= Flags.HasClsCompliantAttribute;
215 return cls_attribute.GetClsCompliantAttributeValue (ds);
218 return ds.GetClsCompliantAttributeValue ();
222 /// Returns true if MemberCore is explicitly marked with CLSCompliantAttribute
224 protected bool HasClsCompliantAttribute {
226 return (caching_flags & Flags.HasClsCompliantAttribute) != 0;
231 /// The main virtual method for CLS-Compliant verifications.
232 /// The method returns true if member is CLS-Compliant and false if member is not
233 /// CLS-Compliant which means that CLS-Compliant tests are not necessary. A descendants override it
234 /// and add their extra verifications.
236 protected virtual bool VerifyClsCompliance (DeclSpace ds)
238 if (!IsClsCompliaceRequired (ds)) {
239 if ((RootContext.WarningLevel >= 2) && HasClsCompliantAttribute && !IsExposedFromAssembly (ds)) {
240 Report.Warning (3019, Location, "CLS compliance checking will not be performed on '{0}' because it is private or internal", GetSignatureForError ());
245 if (!CodeGen.Assembly.IsClsCompliant) {
246 if (HasClsCompliantAttribute) {
247 Report.Error (3014, Location, "'{0}' cannot be marked as CLS-compliant because the assembly does not have a CLSCompliant attribute", GetSignatureForError ());
251 int index = Name.LastIndexOf ('.');
252 if (Name [index > 0 ? index + 1 : 0] == '_') {
253 Report.Error (3008, Location, "Identifier '{0}' is not CLS-compliant", GetSignatureForError () );
258 protected abstract void VerifyObsoleteAttribute ();
263 /// Base class for structs, classes, enumerations and interfaces.
266 /// They all create new declaration spaces. This
267 /// provides the common foundation for managing those name
270 public abstract class DeclSpace : MemberCore {
272 /// this points to the actual definition that is being
273 /// created with System.Reflection.Emit
275 public TypeBuilder TypeBuilder;
278 // This is the namespace in which this typecontainer
279 // was declared. We use this to resolve names.
281 public NamespaceEntry NamespaceEntry;
283 public Hashtable Cache = new Hashtable ();
285 public string Basename;
288 /// defined_names is used for toplevel objects
290 protected Hashtable defined_names;
292 static string[] attribute_targets = new string [] { "type" };
294 public DeclSpace (NamespaceEntry ns, TypeContainer parent, string name, Attributes attrs, Location l)
295 : base (parent, name, attrs, l)
298 Basename = name.Substring (1 + name.LastIndexOf ('.'));
299 defined_names = new Hashtable ();
302 public void RecordDecl ()
304 if ((NamespaceEntry != null) && (Parent == RootContext.Tree.Types))
305 NamespaceEntry.DefineName (Basename, this);
309 /// The result value from adding an declaration into
310 /// a struct or a class
312 public enum AdditionResult {
314 /// The declaration has been successfully
315 /// added to the declation space.
320 /// The symbol has already been defined.
325 /// Returned if the declation being added to the
326 /// name space clashes with its container name.
328 /// The only exceptions for this are constructors
329 /// and static constructors
334 /// Returned if a constructor was created (because syntactically
335 /// it looked like a constructor) but was not (because the name
336 /// of the method is not the same as the container class
341 /// This is only used by static constructors to emit the
342 /// error 111, but this error for other things really
343 /// happens at another level for other functions.
348 /// Some other error.
354 /// Returns a status code based purely on the name
355 /// of the member being added
357 protected AdditionResult IsValid (string basename, string name)
359 if (basename == Basename)
360 return AdditionResult.EnclosingClash;
362 if (defined_names.Contains (name))
363 return AdditionResult.NameExists;
365 return AdditionResult.Success;
368 public static int length;
369 public static int small;
372 /// Introduce @name into this declaration space and
373 /// associates it with the object @o. Note that for
374 /// methods this will just point to the first method. o
376 public void DefineName (string name, object o)
378 defined_names.Add (name, o);
381 int p = name.LastIndexOf ('.');
389 /// Returns the object associated with a given name in the declaration
390 /// space. This is the inverse operation of `DefineName'
392 public object GetDefinition (string name)
394 return defined_names [name];
397 bool in_transit = false;
400 /// This function is used to catch recursive definitions
403 public bool InTransit {
414 /// Looks up the alias for the name
416 public string LookupAlias (string name)
418 if (NamespaceEntry != null)
419 return NamespaceEntry.LookupAlias (name);
425 // root_types contains all the types. All TopLevel types
426 // hence have a parent that points to `root_types', that is
427 // why there is a non-obvious test down here.
429 public bool IsTopLevel {
432 if (Parent.Parent == null)
439 public virtual void CloseType ()
441 if ((caching_flags & Flags.CloseTypeCreated) == 0){
443 TypeBuilder.CreateType ();
446 // The try/catch is needed because
447 // nested enumerations fail to load when they
450 // Even if this is the right order (enumerations
451 // declared after types).
453 // Note that this still creates the type and
454 // it is possible to save it
456 caching_flags |= Flags.CloseTypeCreated;
461 /// Should be overriten by the appropriate declaration space
463 public abstract TypeBuilder DefineType ();
466 /// Define all members, but don't apply any attributes or do anything which may
467 /// access not-yet-defined classes. This method also creates the MemberCache.
469 public abstract bool DefineMembers (TypeContainer parent);
472 // Whether this is an `unsafe context'
474 public bool UnsafeContext {
476 if ((ModFlags & Modifiers.UNSAFE) != 0)
479 return Parent.UnsafeContext;
484 public static string MakeFQN (string nsn, string name)
488 return String.Concat (nsn, ".", name);
491 EmitContext type_resolve_ec;
492 EmitContext GetTypeResolveEmitContext (TypeContainer parent, Location loc)
494 type_resolve_ec = new EmitContext (parent, this, loc, null, null, ModFlags, false);
495 type_resolve_ec.ResolvingTypeTree = true;
497 return type_resolve_ec;
501 // Looks up the type, as parsed into the expression `e'
503 public Type ResolveType (Expression e, bool silent, Location loc)
505 if (type_resolve_ec == null)
506 type_resolve_ec = GetTypeResolveEmitContext (Parent, loc);
507 type_resolve_ec.loc = loc;
508 type_resolve_ec.ContainerType = TypeBuilder;
510 int errors = Report.Errors;
511 TypeExpr d = e.ResolveAsTypeTerminal (type_resolve_ec);
513 if (d == null || d.eclass != ExprClass.Type){
514 if (!silent && errors == Report.Errors){
515 Report.Error (246, loc, "Cannot find type `"+ e.ToString () +"'");
520 if (!d.CheckAccessLevel (this)) {
521 Report.Error (122, loc, "'{0}' is inaccessible due to its protection level", d.Name);
529 // Resolves the expression `e' for a type, and will recursively define
532 public TypeExpr ResolveTypeExpr (Expression e, bool silent, Location loc)
534 if (type_resolve_ec == null)
535 type_resolve_ec = GetTypeResolveEmitContext (Parent, loc);
536 type_resolve_ec.loc = loc;
537 type_resolve_ec.ContainerType = TypeBuilder;
539 TypeExpr d = e.ResolveAsTypeTerminal (type_resolve_ec);
541 if (d == null || d.eclass != ExprClass.Type){
543 Report.Error (246, loc, "Cannot find type `"+ e +"'");
551 public bool CheckAccessLevel (Type check_type)
553 if (check_type == TypeBuilder)
556 TypeAttributes check_attr = check_type.Attributes & TypeAttributes.VisibilityMask;
559 // Broken Microsoft runtime, return public for arrays, no matter what
560 // the accessibility is for their underlying class, and they return
561 // NonPublic visibility for pointers
563 if (check_type.IsArray || check_type.IsPointer)
564 return CheckAccessLevel (TypeManager.GetElementType (check_type));
567 case TypeAttributes.Public:
570 case TypeAttributes.NotPublic:
572 // In same cases is null.
573 if (TypeBuilder == null)
577 // This test should probably use the declaringtype.
579 return check_type.Assembly == TypeBuilder.Assembly;
581 case TypeAttributes.NestedPublic:
584 case TypeAttributes.NestedPrivate:
585 string check_type_name = check_type.FullName;
586 string type_name = TypeBuilder.FullName;
588 int cio = check_type_name.LastIndexOf ('+');
589 string container = check_type_name.Substring (0, cio);
592 // Check if the check_type is a nested class of the current type
594 if (check_type_name.StartsWith (type_name + "+")){
598 if (type_name.StartsWith (container)){
604 case TypeAttributes.NestedFamily:
606 // Only accessible to methods in current type or any subtypes
608 return FamilyAccessible (check_type);
610 case TypeAttributes.NestedFamANDAssem:
611 return (check_type.Assembly == TypeBuilder.Assembly) &&
612 FamilyAccessible (check_type);
614 case TypeAttributes.NestedFamORAssem:
615 return (check_type.Assembly == TypeBuilder.Assembly) ||
616 FamilyAccessible (check_type);
618 case TypeAttributes.NestedAssembly:
619 return check_type.Assembly == TypeBuilder.Assembly;
622 Console.WriteLine ("HERE: " + check_attr);
627 protected bool FamilyAccessible (Type check_type)
629 Type declaring = check_type.DeclaringType;
630 if (TypeBuilder.IsSubclassOf (declaring))
633 string check_type_name = check_type.FullName;
635 int cio = check_type_name.LastIndexOf ('+');
636 string container = check_type_name.Substring (0, cio);
639 // Check if the check_type is a nested class of the current type
641 if (check_type_name.StartsWith (container + "+"))
647 // Access level of a type.
649 enum AccessLevel { // Each column represents `is this scope larger or equal to Blah scope'
650 // Public Assembly Protected
651 Protected = (0 << 0) | (0 << 1) | (X << 2),
652 Public = (X << 0) | (X << 1) | (X << 2),
653 Private = (0 << 0) | (0 << 1) | (0 << 2),
654 Internal = (0 << 0) | (X << 1) | (0 << 2),
655 ProtectedOrInternal = (0 << 0) | (X << 1) | (X << 2),
658 static AccessLevel GetAccessLevelFromModifiers (int flags)
660 if ((flags & Modifiers.INTERNAL) != 0) {
662 if ((flags & Modifiers.PROTECTED) != 0)
663 return AccessLevel.ProtectedOrInternal;
665 return AccessLevel.Internal;
667 } else if ((flags & Modifiers.PROTECTED) != 0)
668 return AccessLevel.Protected;
670 else if ((flags & Modifiers.PRIVATE) != 0)
671 return AccessLevel.Private;
674 return AccessLevel.Public;
677 // What is the effective access level of this?
679 AccessLevel EffectiveAccessLevel {
681 AccessLevel myAccess = GetAccessLevelFromModifiers (ModFlags);
682 if (!IsTopLevel && (Parent != null))
683 return myAccess & Parent.EffectiveAccessLevel;
689 // Return the access level for type `t'
690 static AccessLevel TypeEffectiveAccessLevel (Type t)
693 return AccessLevel.Public;
694 if (t.IsNestedPrivate)
695 return AccessLevel.Private;
697 return AccessLevel.Internal;
699 // By now, it must be nested
700 AccessLevel parentLevel = TypeEffectiveAccessLevel (t.DeclaringType);
702 if (t.IsNestedPublic)
704 if (t.IsNestedAssembly)
705 return parentLevel & AccessLevel.Internal;
706 if (t.IsNestedFamily)
707 return parentLevel & AccessLevel.Protected;
708 if (t.IsNestedFamORAssem)
709 return parentLevel & AccessLevel.ProtectedOrInternal;
710 if (t.IsNestedFamANDAssem)
711 throw new NotImplementedException ("NestedFamANDAssem not implemented, cant make this kind of type from c# anyways");
713 // nested private is taken care of
715 throw new Exception ("I give up, what are you?");
719 // This answers `is the type P, as accessible as a member M which has the
720 // accessability @flags which is declared as a nested member of the type T, this declspace'
722 public bool AsAccessible (Type p, int flags)
725 // 1) if M is private, its accessability is the same as this declspace.
726 // we already know that P is accessible to T before this method, so we
730 if ((flags & Modifiers.PRIVATE) != 0)
733 while (p.IsArray || p.IsPointer || p.IsByRef)
734 p = TypeManager.GetElementType (p);
736 AccessLevel pAccess = TypeEffectiveAccessLevel (p);
737 AccessLevel mAccess = this.EffectiveAccessLevel &
738 GetAccessLevelFromModifiers (flags);
740 // for every place from which we can access M, we must
741 // be able to access P as well. So, we want
742 // For every bit in M and P, M_i -> P_1 == true
743 // or, ~ (M -> P) == 0 <-> ~ ( ~M | P) == 0
745 return ~ (~ mAccess | pAccess) == 0;
748 static DoubleHash dh = new DoubleHash (1000);
750 Type DefineTypeAndParents (DeclSpace tc)
752 DeclSpace container = tc.Parent;
754 if (container.TypeBuilder == null && container.Name != "")
755 DefineTypeAndParents (container);
757 return tc.DefineType ();
760 Type LookupInterfaceOrClass (string ns, string name, out bool error)
767 int p = name.LastIndexOf ('.');
769 if (dh.Lookup (ns, name, out r))
773 // If the type is not a nested type, we do not need `LookupType's processing.
774 // If the @name does not have a `.' in it, this cant be a nested type.
777 if (Namespace.IsNamespace (ns)) {
779 t = TypeManager.LookupType (ns + "." + name);
781 t = TypeManager.LookupTypeDirect (ns + "." + name);
785 t = TypeManager.LookupType (name);
787 t = TypeManager.LookupTypeDirect (name);
791 dh.Insert (ns, name, t);
796 // In case we are fed a composite name, normalize it.
800 ns = MakeFQN (ns, name.Substring (0, p));
801 name = name.Substring (p+1);
804 parent = RootContext.Tree.LookupByNamespace (ns, name);
805 if (parent == null) {
806 dh.Insert (ns, name, null);
810 t = DefineTypeAndParents (parent);
816 dh.Insert (ns, name, t);
820 public static void Error_AmbiguousTypeReference (Location loc, string name, Type t1, Type t2)
822 Report.Error (104, loc,
823 String.Format ("`{0}' is an ambiguous reference ({1} or {2}) ", name,
824 t1.FullName, t2.FullName));
828 /// GetType is used to resolve type names at the DeclSpace level.
829 /// Use this to lookup class/struct bases, interface bases or
830 /// delegate type references
834 /// Contrast this to LookupType which is used inside method bodies to
835 /// lookup types that have already been defined. GetType is used
836 /// during the tree resolution process and potentially define
837 /// recursively the type
839 public Type FindType (Location loc, string name)
845 // For the case the type we are looking for is nested within this one
846 // or is in any base class
848 DeclSpace containing_ds = this;
850 while (containing_ds != null){
851 Type container_type = containing_ds.TypeBuilder;
852 Type current_type = container_type;
854 while (current_type != null && current_type != TypeManager.object_type) {
855 string pre = current_type.FullName;
857 t = LookupInterfaceOrClass (pre, name, out error);
861 if ((t != null) && containing_ds.CheckAccessLevel (t))
864 current_type = current_type.BaseType;
866 containing_ds = containing_ds.Parent;
870 // Attempt to lookup the class on our namespace and all it's implicit parents
872 for (NamespaceEntry ns = NamespaceEntry; ns != null; ns = ns.ImplicitParent) {
873 t = LookupInterfaceOrClass (ns.FullName, name, out error);
882 // Attempt to do a direct unqualified lookup
884 t = LookupInterfaceOrClass ("", name, out error);
892 // Attempt to lookup the class on any of the `using'
896 for (NamespaceEntry ns = NamespaceEntry; ns != null; ns = ns.Parent){
898 t = LookupInterfaceOrClass (ns.FullName, name, out error);
905 if (name.IndexOf ('.') > 0)
908 string alias_value = ns.LookupAlias (name);
909 if (alias_value != null) {
910 t = LookupInterfaceOrClass ("", alias_value, out error);
919 // Now check the using clause list
922 foreach (Namespace using_ns in ns.GetUsingTable ()) {
923 match = LookupInterfaceOrClass (using_ns.Name, name, out error);
929 if (CheckAccessLevel (match)) {
930 Error_AmbiguousTypeReference (loc, name, t, match);
943 //Report.Error (246, Location, "Can not find type `"+name+"'");
948 /// This function is broken and not what you're looking for. It should only
949 /// be used while the type is still being created since it doesn't use the cache
950 /// and relies on the filter doing the member name check.
952 public abstract MemberList FindMembers (MemberTypes mt, BindingFlags bf,
953 MemberFilter filter, object criteria);
956 /// If we have a MemberCache, return it. This property may return null if the
957 /// class doesn't have a member cache or while it's still being created.
959 public abstract MemberCache MemberCache {
963 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
966 TypeBuilder.SetCustomAttribute (cb);
967 } catch (System.ArgumentException e) {
968 Report.Warning (-21, a.Location,
969 "The CharSet named property on StructLayout\n"+
970 "\tdoes not work correctly on Microsoft.NET\n"+
971 "\tYou might want to remove the CharSet declaration\n"+
972 "\tor compile using the Mono runtime instead of the\n"+
973 "\tMicrosoft .NET runtime\n"+
974 "\tThe runtime gave the error: " + e);
979 /// Goes through class hierarchy and get value of first CLSCompliantAttribute that found.
980 /// If no is attribute exists then return assembly CLSCompliantAttribute.
982 public bool GetClsCompliantAttributeValue ()
984 if ((caching_flags & Flags.HasCompliantAttribute_Undetected) == 0)
985 return (caching_flags & Flags.ClsCompliantAttributeTrue) != 0;
987 caching_flags &= ~Flags.HasCompliantAttribute_Undetected;
989 if (OptAttributes != null) {
990 EmitContext ec = new EmitContext (Parent, this, Location,
991 null, null, ModFlags, false);
992 Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ec);
993 if (cls_attribute != null) {
994 caching_flags |= Flags.HasClsCompliantAttribute;
995 if (cls_attribute.GetClsCompliantAttributeValue (this)) {
996 caching_flags |= Flags.ClsCompliantAttributeTrue;
1003 if (Parent == null) {
1004 if (CodeGen.Assembly.IsClsCompliant) {
1005 caching_flags |= Flags.ClsCompliantAttributeTrue;
1011 if (Parent.GetClsCompliantAttributeValue ()) {
1012 caching_flags |= Flags.ClsCompliantAttributeTrue;
1018 public override string[] ValidAttributeTargets {
1020 return attribute_targets;
1026 /// This is a readonly list of MemberInfo's.
1028 public class MemberList : IList {
1029 public readonly IList List;
1033 /// Create a new MemberList from the given IList.
1035 public MemberList (IList list)
1040 this.List = new ArrayList ();
1045 /// Concatenate the ILists `first' and `second' to a new MemberList.
1047 public MemberList (IList first, IList second)
1049 ArrayList list = new ArrayList ();
1050 list.AddRange (first);
1051 list.AddRange (second);
1056 public static readonly MemberList Empty = new MemberList (new ArrayList ());
1059 /// Cast the MemberList into a MemberInfo[] array.
1062 /// This is an expensive operation, only use it if it's really necessary.
1064 public static explicit operator MemberInfo [] (MemberList list)
1066 Timer.StartTimer (TimerType.MiscTimer);
1067 MemberInfo [] result = new MemberInfo [list.Count];
1068 list.CopyTo (result, 0);
1069 Timer.StopTimer (TimerType.MiscTimer);
1081 public bool IsSynchronized {
1083 return List.IsSynchronized;
1087 public object SyncRoot {
1089 return List.SyncRoot;
1093 public void CopyTo (Array array, int index)
1095 List.CopyTo (array, index);
1100 public IEnumerator GetEnumerator ()
1102 return List.GetEnumerator ();
1107 public bool IsFixedSize {
1113 public bool IsReadOnly {
1119 object IList.this [int index] {
1121 return List [index];
1125 throw new NotSupportedException ();
1129 // FIXME: try to find out whether we can avoid the cast in this indexer.
1130 public MemberInfo this [int index] {
1132 return (MemberInfo) List [index];
1136 public int Add (object value)
1138 throw new NotSupportedException ();
1141 public void Clear ()
1143 throw new NotSupportedException ();
1146 public bool Contains (object value)
1148 return List.Contains (value);
1151 public int IndexOf (object value)
1153 return List.IndexOf (value);
1156 public void Insert (int index, object value)
1158 throw new NotSupportedException ();
1161 public void Remove (object value)
1163 throw new NotSupportedException ();
1166 public void RemoveAt (int index)
1168 throw new NotSupportedException ();
1173 /// This interface is used to get all members of a class when creating the
1174 /// member cache. It must be implemented by all DeclSpace derivatives which
1175 /// want to support the member cache and by TypeHandle to get caching of
1176 /// non-dynamic types.
1178 public interface IMemberContainer {
1180 /// The name of the IMemberContainer. This is only used for
1181 /// debugging purposes.
1188 /// The type of this IMemberContainer.
1195 /// Returns the IMemberContainer of the parent class or null if this
1196 /// is an interface or TypeManger.object_type.
1197 /// This is used when creating the member cache for a class to get all
1198 /// members from the parent class.
1200 IMemberContainer ParentContainer {
1205 /// Whether this is an interface.
1212 /// Returns all members of this class with the corresponding MemberTypes
1213 /// and BindingFlags.
1216 /// When implementing this method, make sure not to return any inherited
1217 /// members and check the MemberTypes and BindingFlags properly.
1218 /// Unfortunately, System.Reflection is lame and doesn't provide a way to
1219 /// get the BindingFlags (static/non-static,public/non-public) in the
1220 /// MemberInfo class, but the cache needs this information. That's why
1221 /// this method is called multiple times with different BindingFlags.
1223 MemberList GetMembers (MemberTypes mt, BindingFlags bf);
1226 /// Return the container's member cache.
1228 MemberCache MemberCache {
1234 /// The MemberCache is used by dynamic and non-dynamic types to speed up
1235 /// member lookups. It has a member name based hash table; it maps each member
1236 /// name to a list of CacheEntry objects. Each CacheEntry contains a MemberInfo
1237 /// and the BindingFlags that were initially used to get it. The cache contains
1238 /// all members of the current class and all inherited members. If this cache is
1239 /// for an interface types, it also contains all inherited members.
1241 /// There are two ways to get a MemberCache:
1242 /// * if this is a dynamic type, lookup the corresponding DeclSpace and then
1243 /// use the DeclSpace.MemberCache property.
1244 /// * if this not a dynamic type, call TypeHandle.GetTypeHandle() to get a
1245 /// TypeHandle instance for the type and then use TypeHandle.MemberCache.
1247 public class MemberCache {
1248 public readonly IMemberContainer Container;
1249 protected Hashtable member_hash;
1250 protected Hashtable method_hash;
1253 /// Create a new MemberCache for the given IMemberContainer `container'.
1255 public MemberCache (IMemberContainer container)
1257 this.Container = container;
1259 Timer.IncrementCounter (CounterType.MemberCache);
1260 Timer.StartTimer (TimerType.CacheInit);
1264 // If we have a parent class (we have a parent class unless we're
1265 // TypeManager.object_type), we deep-copy its MemberCache here.
1266 if (Container.IsInterface) {
1269 if (Container.ParentContainer != null)
1270 parent = Container.ParentContainer.MemberCache;
1272 parent = TypeHandle.ObjectType.MemberCache;
1273 member_hash = SetupCacheForInterface (parent);
1274 } else if (Container.ParentContainer != null)
1275 member_hash = SetupCache (Container.ParentContainer.MemberCache);
1277 member_hash = new Hashtable ();
1279 // If this is neither a dynamic type nor an interface, create a special
1280 // method cache with all declared and inherited methods.
1281 Type type = container.Type;
1282 if (!(type is TypeBuilder) && !type.IsInterface) {
1283 method_hash = new Hashtable ();
1287 // Add all members from the current class.
1288 AddMembers (Container);
1290 Timer.StopTimer (TimerType.CacheInit);
1294 /// Bootstrap this member cache by doing a deep-copy of our parent.
1296 Hashtable SetupCache (MemberCache parent)
1298 Hashtable hash = new Hashtable ();
1300 IDictionaryEnumerator it = parent.member_hash.GetEnumerator ();
1301 while (it.MoveNext ()) {
1302 hash [it.Key] = ((ArrayList) it.Value).Clone ();
1310 /// Add the contents of `new_hash' to `hash'.
1312 void AddHashtable (Hashtable hash, MemberCache cache)
1314 Hashtable new_hash = cache.member_hash;
1315 IDictionaryEnumerator it = new_hash.GetEnumerator ();
1316 while (it.MoveNext ()) {
1317 ArrayList list = (ArrayList) hash [it.Key];
1319 hash [it.Key] = list = new ArrayList ();
1321 foreach (CacheEntry entry in (ArrayList) it.Value) {
1322 if (entry.Container != cache.Container)
1330 /// Bootstrap the member cache for an interface type.
1331 /// Type.GetMembers() won't return any inherited members for interface types,
1332 /// so we need to do this manually. Interfaces also inherit from System.Object.
1334 Hashtable SetupCacheForInterface (MemberCache parent)
1336 Hashtable hash = SetupCache (parent);
1337 TypeExpr [] ifaces = TypeManager.GetInterfaces (Container.Type);
1339 foreach (TypeExpr iface in ifaces) {
1340 Type itype = iface.Type;
1342 IMemberContainer iface_container =
1343 TypeManager.LookupMemberContainer (itype);
1345 MemberCache iface_cache = iface_container.MemberCache;
1347 AddHashtable (hash, iface_cache);
1354 /// Add all members from class `container' to the cache.
1356 void AddMembers (IMemberContainer container)
1358 // We need to call AddMembers() with a single member type at a time
1359 // to get the member type part of CacheEntry.EntryType right.
1360 AddMembers (MemberTypes.Constructor, container);
1361 AddMembers (MemberTypes.Field, container);
1362 AddMembers (MemberTypes.Method, container);
1363 AddMembers (MemberTypes.Property, container);
1364 AddMembers (MemberTypes.Event, container);
1365 // Nested types are returned by both Static and Instance searches.
1366 AddMembers (MemberTypes.NestedType,
1367 BindingFlags.Static | BindingFlags.Public, container);
1368 AddMembers (MemberTypes.NestedType,
1369 BindingFlags.Static | BindingFlags.NonPublic, container);
1372 void AddMembers (MemberTypes mt, IMemberContainer container)
1374 AddMembers (mt, BindingFlags.Static | BindingFlags.Public, container);
1375 AddMembers (mt, BindingFlags.Static | BindingFlags.NonPublic, container);
1376 AddMembers (mt, BindingFlags.Instance | BindingFlags.Public, container);
1377 AddMembers (mt, BindingFlags.Instance | BindingFlags.NonPublic, container);
1381 /// Add all members from class `container' with the requested MemberTypes and
1382 /// BindingFlags to the cache. This method is called multiple times with different
1383 /// MemberTypes and BindingFlags.
1385 void AddMembers (MemberTypes mt, BindingFlags bf, IMemberContainer container)
1387 MemberList members = container.GetMembers (mt, bf);
1389 foreach (MemberInfo member in members) {
1390 string name = member.Name;
1392 // We use a name-based hash table of ArrayList's.
1393 ArrayList list = (ArrayList) member_hash [name];
1395 list = new ArrayList ();
1396 member_hash.Add (name, list);
1399 // When this method is called for the current class, the list will
1400 // already contain all inherited members from our parent classes.
1401 // We cannot add new members in front of the list since this'd be an
1402 // expensive operation, that's why the list is sorted in reverse order
1403 // (ie. members from the current class are coming last).
1404 list.Add (new CacheEntry (container, member, mt, bf));
1409 /// Add all declared and inherited methods from class `type' to the method cache.
1411 void AddMethods (Type type)
1413 AddMethods (BindingFlags.Static | BindingFlags.Public |
1414 BindingFlags.FlattenHierarchy, type);
1415 AddMethods (BindingFlags.Static | BindingFlags.NonPublic |
1416 BindingFlags.FlattenHierarchy, type);
1417 AddMethods (BindingFlags.Instance | BindingFlags.Public, type);
1418 AddMethods (BindingFlags.Instance | BindingFlags.NonPublic, type);
1421 void AddMethods (BindingFlags bf, Type type)
1423 MemberInfo [] members = type.GetMethods (bf);
1425 Array.Reverse (members);
1427 foreach (MethodBase member in members) {
1428 string name = member.Name;
1430 // We use a name-based hash table of ArrayList's.
1431 ArrayList list = (ArrayList) method_hash [name];
1433 list = new ArrayList ();
1434 method_hash.Add (name, list);
1437 // Unfortunately, the elements returned by Type.GetMethods() aren't
1438 // sorted so we need to do this check for every member.
1439 BindingFlags new_bf = bf;
1440 if (member.DeclaringType == type)
1441 new_bf |= BindingFlags.DeclaredOnly;
1443 list.Add (new CacheEntry (Container, member, MemberTypes.Method, new_bf));
1450 /// Compute and return a appropriate `EntryType' magic number for the given
1451 /// MemberTypes and BindingFlags.
1453 protected static EntryType GetEntryType (MemberTypes mt, BindingFlags bf)
1455 EntryType type = EntryType.None;
1457 if ((mt & MemberTypes.Constructor) != 0)
1458 type |= EntryType.Constructor;
1459 if ((mt & MemberTypes.Event) != 0)
1460 type |= EntryType.Event;
1461 if ((mt & MemberTypes.Field) != 0)
1462 type |= EntryType.Field;
1463 if ((mt & MemberTypes.Method) != 0)
1464 type |= EntryType.Method;
1465 if ((mt & MemberTypes.Property) != 0)
1466 type |= EntryType.Property;
1467 // Nested types are returned by static and instance searches.
1468 if ((mt & MemberTypes.NestedType) != 0)
1469 type |= EntryType.NestedType | EntryType.Static | EntryType.Instance;
1471 if ((bf & BindingFlags.Instance) != 0)
1472 type |= EntryType.Instance;
1473 if ((bf & BindingFlags.Static) != 0)
1474 type |= EntryType.Static;
1475 if ((bf & BindingFlags.Public) != 0)
1476 type |= EntryType.Public;
1477 if ((bf & BindingFlags.NonPublic) != 0)
1478 type |= EntryType.NonPublic;
1479 if ((bf & BindingFlags.DeclaredOnly) != 0)
1480 type |= EntryType.Declared;
1486 /// The `MemberTypes' enumeration type is a [Flags] type which means that it may
1487 /// denote multiple member types. Returns true if the given flags value denotes a
1488 /// single member types.
1490 public static bool IsSingleMemberType (MemberTypes mt)
1493 case MemberTypes.Constructor:
1494 case MemberTypes.Event:
1495 case MemberTypes.Field:
1496 case MemberTypes.Method:
1497 case MemberTypes.Property:
1498 case MemberTypes.NestedType:
1507 /// We encode the MemberTypes and BindingFlags of each members in a "magic"
1508 /// number to speed up the searching process.
1511 protected enum EntryType {
1516 MaskStatic = Instance|Static,
1520 MaskProtection = Public|NonPublic,
1524 Constructor = 0x020,
1531 MaskType = Constructor|Event|Field|Method|Property|NestedType
1534 protected struct CacheEntry {
1535 public readonly IMemberContainer Container;
1536 public readonly EntryType EntryType;
1537 public readonly MemberInfo Member;
1539 public CacheEntry (IMemberContainer container, MemberInfo member,
1540 MemberTypes mt, BindingFlags bf)
1542 this.Container = container;
1543 this.Member = member;
1544 this.EntryType = GetEntryType (mt, bf);
1549 /// This is called each time we're walking up one level in the class hierarchy
1550 /// and checks whether we can abort the search since we've already found what
1551 /// we were looking for.
1553 protected bool DoneSearching (ArrayList list)
1556 // We've found exactly one member in the current class and it's not
1557 // a method or constructor.
1559 if (list.Count == 1 && !(list [0] is MethodBase))
1563 // Multiple properties: we query those just to find out the indexer
1566 if ((list.Count > 0) && (list [0] is PropertyInfo))
1573 /// Looks up members with name `name'. If you provide an optional
1574 /// filter function, it'll only be called with members matching the
1575 /// requested member name.
1577 /// This method will try to use the cache to do the lookup if possible.
1579 /// Unlike other FindMembers implementations, this method will always
1580 /// check all inherited members - even when called on an interface type.
1582 /// If you know that you're only looking for methods, you should use
1583 /// MemberTypes.Method alone since this speeds up the lookup a bit.
1584 /// When doing a method-only search, it'll try to use a special method
1585 /// cache (unless it's a dynamic type or an interface) and the returned
1586 /// MemberInfo's will have the correct ReflectedType for inherited methods.
1587 /// The lookup process will automatically restart itself in method-only
1588 /// search mode if it discovers that it's about to return methods.
1590 ArrayList global = new ArrayList ();
1591 bool using_global = false;
1593 static MemberInfo [] emptyMemberInfo = new MemberInfo [0];
1595 public MemberInfo [] FindMembers (MemberTypes mt, BindingFlags bf, string name,
1596 MemberFilter filter, object criteria)
1599 throw new Exception ();
1601 bool declared_only = (bf & BindingFlags.DeclaredOnly) != 0;
1602 bool method_search = mt == MemberTypes.Method;
1603 // If we have a method cache and we aren't already doing a method-only search,
1604 // then we restart a method search if the first match is a method.
1605 bool do_method_search = !method_search && (method_hash != null);
1607 ArrayList applicable;
1609 // If this is a method-only search, we try to use the method cache if
1610 // possible; a lookup in the method cache will return a MemberInfo with
1611 // the correct ReflectedType for inherited methods.
1613 if (method_search && (method_hash != null))
1614 applicable = (ArrayList) method_hash [name];
1616 applicable = (ArrayList) member_hash [name];
1618 if (applicable == null)
1619 return emptyMemberInfo;
1622 // 32 slots gives 53 rss/54 size
1623 // 2/4 slots gives 55 rss
1625 // Strange: from 25,000 calls, only 1,800
1626 // are above 2. Why does this impact it?
1629 using_global = true;
1631 Timer.StartTimer (TimerType.CachedLookup);
1633 EntryType type = GetEntryType (mt, bf);
1635 IMemberContainer current = Container;
1638 // `applicable' is a list of all members with the given member name `name'
1639 // in the current class and all its parent classes. The list is sorted in
1640 // reverse order due to the way how the cache is initialy created (to speed
1641 // things up, we're doing a deep-copy of our parent).
1643 for (int i = applicable.Count-1; i >= 0; i--) {
1644 CacheEntry entry = (CacheEntry) applicable [i];
1646 // This happens each time we're walking one level up in the class
1647 // hierarchy. If we're doing a DeclaredOnly search, we must abort
1648 // the first time this happens (this may already happen in the first
1649 // iteration of this loop if there are no members with the name we're
1650 // looking for in the current class).
1651 if (entry.Container != current) {
1652 if (declared_only || DoneSearching (global))
1655 current = entry.Container;
1658 // Is the member of the correct type ?
1659 if ((entry.EntryType & type & EntryType.MaskType) == 0)
1662 // Is the member static/non-static ?
1663 if ((entry.EntryType & type & EntryType.MaskStatic) == 0)
1666 // Apply the filter to it.
1667 if (filter (entry.Member, criteria)) {
1668 if ((entry.EntryType & EntryType.MaskType) != EntryType.Method)
1669 do_method_search = false;
1670 global.Add (entry.Member);
1674 Timer.StopTimer (TimerType.CachedLookup);
1676 // If we have a method cache and we aren't already doing a method-only
1677 // search, we restart in method-only search mode if the first match is
1678 // a method. This ensures that we return a MemberInfo with the correct
1679 // ReflectedType for inherited methods.
1680 if (do_method_search && (global.Count > 0)){
1681 using_global = false;
1683 return FindMembers (MemberTypes.Method, bf, name, filter, criteria);
1686 using_global = false;
1687 MemberInfo [] copy = new MemberInfo [global.Count];
1688 global.CopyTo (copy);
1692 // find the nested type @name in @this.
1693 public Type FindNestedType (string name)
1695 ArrayList applicable = (ArrayList) member_hash [name];
1696 if (applicable == null)
1699 for (int i = applicable.Count-1; i >= 0; i--) {
1700 CacheEntry entry = (CacheEntry) applicable [i];
1701 if ((entry.EntryType & EntryType.NestedType & EntryType.MaskType) != 0)
1702 return (Type) entry.Member;
1709 // This finds the method or property for us to override. invocationType is the type where
1710 // the override is going to be declared, name is the name of the method/property, and
1711 // paramTypes is the parameters, if any to the method or property
1713 // Because the MemberCache holds members from this class and all the base classes,
1714 // we can avoid tons of reflection stuff.
1716 public MemberInfo FindMemberToOverride (Type invocationType, string name, Type [] paramTypes, bool is_property)
1718 ArrayList applicable;
1719 if (method_hash != null && !is_property)
1720 applicable = (ArrayList) method_hash [name];
1722 applicable = (ArrayList) member_hash [name];
1724 if (applicable == null)
1727 // Walk the chain of methods, starting from the top.
1729 for (int i = applicable.Count - 1; i >= 0; i--) {
1730 CacheEntry entry = (CacheEntry) applicable [i];
1732 if ((entry.EntryType & (is_property ? (EntryType.Property | EntryType.Field) : EntryType.Method)) == 0)
1735 PropertyInfo pi = null;
1736 MethodInfo mi = null;
1737 FieldInfo fi = null;
1738 Type [] cmpAttrs = null;
1741 if ((entry.EntryType & EntryType.Field) != 0) {
1742 fi = (FieldInfo)entry.Member;
1744 // TODO: For this case we ignore member type
1745 //fb = TypeManager.GetField (fi);
1746 //cmpAttrs = new Type[] { fb.MemberType };
1748 pi = (PropertyInfo) entry.Member;
1749 cmpAttrs = TypeManager.GetArgumentTypes (pi);
1752 mi = (MethodInfo) entry.Member;
1753 cmpAttrs = TypeManager.GetArgumentTypes (mi);
1757 // TODO: Almost duplicate !
1759 switch (fi.Attributes & FieldAttributes.FieldAccessMask) {
1760 case FieldAttributes.Private:
1762 // A private method is Ok if we are a nested subtype.
1763 // The spec actually is not very clear about this, see bug 52458.
1765 if (invocationType != entry.Container.Type &
1766 TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
1770 case FieldAttributes.FamANDAssem:
1771 case FieldAttributes.Assembly:
1773 // Check for assembly methods
1775 if (mi.DeclaringType.Assembly != CodeGen.Assembly.Builder)
1779 return entry.Member;
1783 // Check the arguments
1785 if (cmpAttrs.Length != paramTypes.Length)
1788 for (int j = cmpAttrs.Length - 1; j >= 0; j --)
1789 if (paramTypes [j] != cmpAttrs [j])
1793 // get one of the methods because this has the visibility info.
1796 mi = pi.GetGetMethod (true);
1798 mi = pi.GetSetMethod (true);
1804 switch (mi.Attributes & MethodAttributes.MemberAccessMask) {
1805 case MethodAttributes.Private:
1807 // A private method is Ok if we are a nested subtype.
1808 // The spec actually is not very clear about this, see bug 52458.
1810 if (invocationType == entry.Container.Type ||
1811 TypeManager.IsNestedChildOf (invocationType, entry.Container.Type))
1812 return entry.Member;
1815 case MethodAttributes.FamANDAssem:
1816 case MethodAttributes.Assembly:
1818 // Check for assembly methods
1820 if (mi.DeclaringType.Assembly == CodeGen.Assembly.Builder)
1821 return entry.Member;
1826 // A protected method is ok, because we are overriding.
1827 // public is always ok.
1829 return entry.Member;
1839 /// The method is looking for conflict with inherited symbols (errors CS0108, CS0109).
1840 /// We handle two cases. The first is for types without parameters (events, field, properties).
1841 /// The second are methods, indexers and this is why ignore_complex_types is here.
1842 /// The latest param is temporary hack. See DoDefineMembers method for more info.
1844 public MemberInfo FindMemberWithSameName (string name, bool ignore_complex_types, MemberInfo ignore_member)
1846 ArrayList applicable = null;
1848 if (method_hash != null)
1849 applicable = (ArrayList) method_hash [name];
1851 if (applicable != null) {
1852 for (int i = applicable.Count - 1; i >= 0; i--) {
1853 CacheEntry entry = (CacheEntry) applicable [i];
1854 if ((entry.EntryType & EntryType.Public) != 0)
1855 return entry.Member;
1859 if (member_hash == null)
1861 applicable = (ArrayList) member_hash [name];
1863 if (applicable != null) {
1864 for (int i = applicable.Count - 1; i >= 0; i--) {
1865 CacheEntry entry = (CacheEntry) applicable [i];
1866 if ((entry.EntryType & EntryType.Public) != 0 & entry.Member != ignore_member) {
1867 if (ignore_complex_types) {
1868 if ((entry.EntryType & EntryType.Method) != 0)
1871 // Does exist easier way how to detect indexer ?
1872 if ((entry.EntryType & EntryType.Property) != 0) {
1873 Type[] arg_types = TypeManager.GetArgumentTypes ((PropertyInfo)entry.Member);
1874 if (arg_types.Length == 1)
1878 return entry.Member;
1885 Hashtable locase_table;
1888 /// Builds low-case table for CLS Compliance test
1890 public Hashtable GetPublicMembers ()
1892 if (locase_table != null)
1893 return locase_table;
1895 locase_table = new Hashtable ();
1896 foreach (DictionaryEntry entry in member_hash) {
1897 ArrayList members = (ArrayList)entry.Value;
1898 for (int ii = 0; ii < members.Count; ++ii) {
1899 CacheEntry member_entry = (CacheEntry) members [ii];
1901 if ((member_entry.EntryType & EntryType.Public) == 0)
1904 // TODO: Does anyone know easier way how to detect that member is internal ?
1905 switch (member_entry.EntryType & EntryType.MaskType) {
1906 case EntryType.Constructor:
1909 case EntryType.Field:
1910 if ((((FieldInfo)member_entry.Member).Attributes & (FieldAttributes.Assembly | FieldAttributes.Public)) == FieldAttributes.Assembly)
1914 case EntryType.Method:
1915 if ((((MethodInfo)member_entry.Member).Attributes & (MethodAttributes.Assembly | MethodAttributes.Public)) == MethodAttributes.Assembly)
1919 case EntryType.Property:
1920 PropertyInfo pi = (PropertyInfo)member_entry.Member;
1921 if (pi.GetSetMethod () == null && pi.GetGetMethod () == null)
1925 case EntryType.Event:
1926 EventInfo ei = (EventInfo)member_entry.Member;
1927 MethodInfo mi = ei.GetAddMethod ();
1928 if ((mi.Attributes & (MethodAttributes.Assembly | MethodAttributes.Public)) == MethodAttributes.Assembly)
1932 string lcase = ((string)entry.Key).ToLower (System.Globalization.CultureInfo.InvariantCulture);
1933 locase_table [lcase] = member_entry.Member;
1937 return locase_table;
1940 public Hashtable Members {
1947 /// Cls compliance check whether methods or constructors parameters differing only in ref or out, or in array rank
1949 public void VerifyClsParameterConflict (ArrayList al, MethodCore method, MemberInfo this_builder)
1951 EntryType tested_type = (method is Constructor ? EntryType.Constructor : EntryType.Method) | EntryType.Public;
1953 for (int i = 0; i < al.Count; ++i) {
1954 MemberCache.CacheEntry entry = (MemberCache.CacheEntry) al [i];
1957 if (entry.Member == this_builder)
1960 if ((entry.EntryType & tested_type) != tested_type)
1963 MethodBase method_to_compare = (MethodBase)entry.Member;
1964 if (AttributeTester.AreOverloadedMethodParamsClsCompliant (method.ParameterTypes, TypeManager.GetArgumentTypes (method_to_compare)))
1967 IMethodData md = TypeManager.GetMethod (method_to_compare);
1969 // TODO: now we are ignoring CLSCompliance(false) on method from other assembly which is buggy.
1970 // However it is exactly what csc does.
1971 if (md != null && !md.IsClsCompliaceRequired (method.Parent))
1974 Report.SymbolRelatedToPreviousError (entry.Member);
1975 Report.Error (3006, method.Location, "Overloaded method '{0}' differing only in ref or out, or in array rank, is not CLS-compliant", method.GetSignatureForError ());