using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
+using System.Globalization;
namespace Mono.CSharp {
+ // Maybe can be usefull to derive from MemberCore
class EnumMember: Attributable {
string name;
Enum parent;
OptAttributes.Emit (ec, this);
}
+ // TODO: caching would be usefull
+ public ObsoleteAttribute GetObsoleteAttribute (EmitContext ec)
+ {
+ if (OptAttributes == null)
+ return null;
+
+ Attribute obsolete_attr = OptAttributes.Search (TypeManager.obsolete_attribute_type, ec);
+ if (obsolete_attr == null)
+ return null;
+
+ ObsoleteAttribute obsolete = obsolete_attr.GetObsoleteAttribute (ec.DeclSpace);
+ if (obsolete == null)
+ return null;
+
+ return obsolete;
+ }
+
protected override string[] ValidAttributeTargets {
get {
return attribute_targets;
attr |= TypeAttributes.Class | TypeAttributes.Sealed;
+ if (!(BaseType is TypeLookupExpression)) {
+ Report.Error (1008, Location,
+ "Type byte, sbyte, short, ushort, int, uint, " +
+ "long, or ulong expected (got: `{0}')", BaseType);
+ return null;
+ }
+
UnderlyingType = ResolveType (BaseType, false, Location);
if (UnderlyingType != TypeManager.int32_type &&
default_value = GetNextDefaultValue (default_value);
}
+
return true;
}
continue;
string enumerator_name = ordered_enums [ii] as string;
- if (String.Compare (checked_name, enumerator_name, true) == 0) {
+ if (String.Compare (checked_name, enumerator_name, true, CultureInfo.InvariantCulture) == 0) {
Report.SymbolRelatedToPreviousError ((Location)member_to_location [enumerator_name], enumerator_name);
Report.Error_T (3005, (Location)member_to_location [checked_name], GetEnumeratorName (checked_name));
break;
}
}
+ protected override void VerifyObsoleteAttribute()
+ {
+ // UnderlyingType is never obsolete
+ }
+
+ /// <summary>
+ /// Returns ObsoleteAttribute for both enum type and enum member
+ /// </summary>
+ public ObsoleteAttribute GetObsoleteAttribute (EmitContext ec, string identifier)
+ {
+ if ((caching_flags & Flags.Obsolete_Undetected) == 0 && (caching_flags & Flags.Obsolete) == 0) {
+ return null;
+ }
+
+ ObsoleteAttribute oa = GetObsoleteAttribute (ec.DeclSpace);
+ if (oa != null)
+ return oa;
+
+ EnumMember em = (EnumMember)name_to_member [identifier];
+ oa = em.GetObsoleteAttribute (ec);
+
+ if (oa == null)
+ return null;
+
+ caching_flags |= Flags.Obsolete;
+ return oa;
+ }
}
}