/// Base representation for members. This is used to keep track
/// of Name, Location and Modifier flags, and handling Attributes.
/// </summary>
- public abstract class MemberCore : Attributable {
+ public abstract class MemberCore : Attributable, IResolveContext {
/// <summary>
/// Public name
/// </summary>
IsUsed = 1 << 11,
IsAssigned = 1 << 12 // Field is assigned
}
-
+
/// <summary>
/// MemberCore flags at first detected then cached
- /// </summary>
+ /// </summary>
internal Flags caching_flags;
public MemberCore (DeclSpace parent, MemberName name, Attributes attrs)
return null;
Attribute obsolete_attr = OptAttributes.Search (
- TypeManager.obsolete_attribute_type, EmitContext);
+ TypeManager.obsolete_attribute_type);
if (obsolete_attr == null)
return null;
- ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (EmitContext);
+ ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute ();
if (obsolete == null)
return null;
/// <summary>
/// Analyze whether CLS-Compliant verification must be execute for this MemberCore.
/// </summary>
- public override bool IsClsComplianceRequired (DeclSpace container)
+ public override bool IsClsComplianceRequired ()
{
if ((caching_flags & Flags.ClsCompliance_Undetected) == 0)
return (caching_flags & Flags.ClsCompliant) != 0;
- if (GetClsCompliantAttributeValue (container) && IsExposedFromAssembly (container)) {
+ if (GetClsCompliantAttributeValue (Parent) && IsExposedFromAssembly (Parent)) {
caching_flags &= ~Flags.ClsCompliance_Undetected;
caching_flags |= Flags.ClsCompliant;
return true;
{
if (OptAttributes != null) {
Attribute cls_attribute = OptAttributes.Search (
- TypeManager.cls_compliant_attribute_type, ds.EmitContext);
+ TypeManager.cls_compliant_attribute_type);
if (cls_attribute != null) {
caching_flags |= Flags.HasClsCompliantAttribute;
- return cls_attribute.GetClsCompliantAttributeValue (ds.EmitContext);
+ return cls_attribute.GetClsCompliantAttributeValue ();
}
}
return ds.GetClsCompliantAttributeValue ();
/// </summary>
protected virtual bool VerifyClsCompliance (DeclSpace ds)
{
- if (!IsClsComplianceRequired (ds)) {
+ if (!IsClsComplianceRequired ()) {
if (HasClsCompliantAttribute && RootContext.WarningLevel >= 2) {
if (!IsExposedFromAssembly (ds))
Report.Warning (3019, 2, Location, "CLS compliance checking will not be performed on `{0}' because it is not visible from outside this assembly", GetSignatureForError ());
{
DocUtil.GenerateDocComment (this, ds);
}
+
+ public override IResolveContext ResolveContext {
+ get {
+ return this;
+ }
+ }
+
+ #region IResolveContext Members
+
+ public virtual DeclSpace DeclContainer {
+ get {
+ return Parent;
+ }
+ }
+
+ public bool IsInObsoleteScope {
+ get {
+ if (GetObsoleteAttribute () != null)
+ return true;
+
+ return Parent == null ? false : Parent.IsInObsoleteScope;
+ }
+ }
+
+ public bool IsInUnsafeScope {
+ get {
+ if ((ModFlags & Modifiers.UNSAFE) != 0)
+ return true;
+
+ return Parent == null ? false : Parent.IsInUnsafeScope;
+ }
+ }
+
+ #endregion
}
/// <summary>
count_type_params += parent.count_type_params;
}
+ public override DeclSpace DeclContainer {
+ get {
+ return this;
+ }
+ }
+
/// <summary>
/// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
/// </summary>
TypeResolveEmitContext.ResolvingTypeTree = true;
if (this is GenericMethod)
TypeResolveEmitContext.ContainerType = Parent.TypeBuilder;
- return e.ResolveAsTypeTerminal (TypeResolveEmitContext);
+ return e.ResolveAsTypeTerminal (TypeResolveEmitContext, silent);
}
public bool CheckAccessLevel (Type check_type)
caching_flags &= ~Flags.HasCompliantAttribute_Undetected;
if (OptAttributes != null) {
- Attribute cls_attribute = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, ec);
+ Attribute cls_attribute = OptAttributes.Search (TypeManager.cls_compliant_attribute_type);
if (cls_attribute != null) {
caching_flags |= Flags.HasClsCompliantAttribute;
- if (cls_attribute.GetClsCompliantAttributeValue (ec)) {
+ if (cls_attribute.GetClsCompliantAttributeValue ()) {
caching_flags |= Flags.ClsCompliantAttributeTrue;
return true;
}
// We need to call AddMembers() with a single member type at a time
// to get the member type part of CacheEntry.EntryType right.
if (!container.IsInterface) {
- AddMembers (MemberTypes.Constructor, container);
- AddMembers (MemberTypes.Field, container);
+ AddMembers (MemberTypes.Constructor, container);
+ AddMembers (MemberTypes.Field, container);
}
AddMembers (MemberTypes.Method, container);
AddMembers (MemberTypes.Property, container);
protected class CacheEntry {
public readonly IMemberContainer Container;
- public EntryType EntryType;
- public MemberInfo Member;
+ public readonly EntryType EntryType;
+ public readonly MemberInfo Member;
public CacheEntry (IMemberContainer container, MemberInfo member,
MemberTypes mt, BindingFlags bf)
static MemberInfo [] emptyMemberInfo = new MemberInfo [0];
public MemberInfo [] FindMembers (MemberTypes mt, BindingFlags bf, string name,
- MemberFilter filter, object criteria)
+ MemberFilter filter, object criteria)
{
if (using_global)
throw new Exception ();
// TODO: now we are ignoring CLSCompliance(false) on method from other assembly which is buggy.
// However it is exactly what csc does.
- if (md != null && !md.IsClsComplianceRequired (method.Parent))
+ if (md != null && !md.IsClsComplianceRequired ())
continue;
Report.SymbolRelatedToPreviousError (entry.Member);