// decl.cs: Declaration base class for structs, classes, enums and interfaces.
//
// Author: Miguel de Icaza (miguel@gnu.org)
+// Marek Safar (marek.safar@seznam.cz)
//
// Licensed under the terms of the GNU GPL
//
using System;
using System.Text;
using System.Collections;
+using System.Globalization;
using System.Reflection.Emit;
using System.Reflection;
HasCompliantAttribute_Undetected = 1 << 5, // Presence of CLSCompliantAttribute has not been detected
HasClsCompliantAttribute = 1 << 6, // Type has CLSCompliantAttribute
ClsCompliantAttributeTrue = 1 << 7, // Type has CLSCompliant (true)
+ Excluded_Undetected = 1 << 8, // Conditional attribute has not been detected yet
+ Excluded = 1 << 9 // Method is conditional
+
}
/// <summary>
Name = name.GetName (!(this is GenericMethod) && !(this is Method));
MemberName = name;
Location = loc;
- caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected;
+ caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
+ }
+
+ /// <summary>
+ /// Tests presence of ObsoleteAttribute and report proper error
+ /// </summary>
+ protected void CheckUsageOfObsoleteAttribute (Type type)
+ {
+ if (type == null)
+ return;
+
+ ObsoleteAttribute obsolete_attr = AttributeTester.GetObsoleteAttribute (type);
+ if (obsolete_attr == null)
+ return;
+
+ AttributeTester.Report_ObsoleteMessage (obsolete_attr, type.FullName, Location);
}
public abstract bool Define (TypeContainer parent);
/// </summary>
public virtual void Emit (TypeContainer container)
{
+ VerifyObsoleteAttribute ();
+
if (!RootContext.VerifyClsCompliance)
return;
return false;
}
+ /// <summary>
+ /// Returns instance of ObsoleteAttribute for this MemberCore
+ /// </summary>
+ public ObsoleteAttribute GetObsoleteAttribute (DeclSpace ds)
+ {
+ // ((flags & (Flags.Obsolete_Undetected | Flags.Obsolete)) == 0) is slower, but why ?
+ if ((caching_flags & Flags.Obsolete_Undetected) == 0 && (caching_flags & Flags.Obsolete) == 0) {
+ return null;
+ }
+
+ caching_flags &= ~Flags.Obsolete_Undetected;
+
+ if (OptAttributes == null)
+ return null;
+
+ // TODO: remove this allocation
+ EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
+ null, null, ds.ModFlags, false);
+
+ Attribute obsolete_attr = OptAttributes.Search (TypeManager.obsolete_attribute_type, ec);
+ if (obsolete_attr == null)
+ return null;
+
+ ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ds);
+ if (obsolete == null)
+ return null;
+
+ caching_flags |= Flags.Obsolete;
+ return obsolete;
+ }
+
/// <summary>
/// Analyze whether CLS-Compliant verification must be execute for this MemberCore.
/// </summary>
return true;
}
+ protected abstract void VerifyObsoleteAttribute ();
+
}
/// <summary>
TypeContainer parent;
+ static string[] attribute_targets = new string [] { "type" };
+
public DeclSpace (NamespaceEntry ns, TypeContainer parent, MemberName name,
Attributes attrs, Location l)
: base (name, attrs, l)
public Type ResolveType (TypeExpr d, Location loc)
{
if (!d.CheckAccessLevel (this)) {
- Report. Error (122, loc, "`" + d.Name + "' " +
- "is inaccessible because of its protection level");
+ Report.Error_T (122, loc, d.Name);
return null;
}
if (t != null)
return t;
+ if (name.IndexOf ('.') > 0)
+ continue;
+
+ IAlias alias_value = ns.LookupAlias (name);
+ if (alias_value != null) {
+ t = LookupInterfaceOrClass ("", alias_value.Name, out error);
+ if (error)
+ return null;
+
+ if (t != null)
+ return t;
+ }
+
//
// Now check the using clause list
//
if (l != type_name.Length)
continue;
- if (String.Compare (Name, type_name, true) == 0 &&
+ if (String.Compare (Name, type_name, true, CultureInfo.InvariantCulture) == 0 &&
AttributeTester.IsClsCompliant (TypeManager.all_imported_types [type_name] as Type)) {
Report.SymbolRelatedToPreviousError ((Type)TypeManager.all_imported_types [type_name]);
return false;
if (l != name.Length)
continue;
- if (String.Compare (Name, name, true) == 0) {
+ if (String.Compare (Name, name, true, CultureInfo.InvariantCulture) == 0) {
if (Name == name)
continue;
return new TypeExpression (TypeBuilder, Location);
}
}
+
+ protected override string[] ValidAttributeTargets {
+ get {
+ return attribute_targets;
+ }
+ }
}
/// <summary>