public readonly Expression LeftExpr;
public readonly string Identifier;
- readonly ArrayList PosArguments;
+ ArrayList PosArguments;
ArrayList NamedArguments;
bool resolve_error;
return LeftExpr == null ? Identifier : LeftExpr.GetSignatureForError () + "." + Identifier;
}
- bool IsValidArgumentType (Type t)
+ public bool HasSecurityAttribute {
+ get {
+ return TypeManager.security_attr_type != null &&
+ TypeManager.IsSubclassOf (type, TypeManager.security_attr_type);
+ }
+ }
+
+ public bool IsValidSecurityAttribute ()
+ {
+ return HasSecurityAttribute && IsSecurityActionValid (false);
+ }
+
+ static bool IsValidArgumentType (Type t)
{
if (t.IsArray)
- t = t.GetElementType ();
+ t = TypeManager.GetElementType (t);
- return TypeManager.IsPrimitiveType (t) ||
+ return t == TypeManager.string_type ||
+ TypeManager.IsPrimitiveType (t) ||
TypeManager.IsEnumType (t) ||
- t == TypeManager.string_type ||
t == TypeManager.object_type ||
t == TypeManager.type_type;
}
if (mg == null)
return null;
- mg = mg.OverloadResolve (ec, PosArguments, false, Location);
+ mg = mg.OverloadResolve (ec, ref PosArguments, false, Location);
if (mg == null)
return null;
ParameterData pd = TypeManager.GetParameterData (constructor);
int pos_arg_count = PosArguments.Count;
- int last_real_param = pd.Count;
-
pos_values = new object [pos_arg_count];
-
- if (pd.HasParams) {
- // When the params is not filled we need to put one
- if (last_real_param > pos_arg_count) {
- object [] new_pos_values = new object [pos_arg_count + 1];
- pos_values.CopyTo (new_pos_values, 0);
- new_pos_values [pos_arg_count] = new object [] {} ;
- pos_values = new_pos_values;
- }
- last_real_param--;
- }
-
for (int j = 0; j < pos_arg_count; ++j) {
Argument a = (Argument) PosArguments [j];
if (!a.Expr.GetAttributableValue (a.Type, out pos_values [j]))
return null;
-
- if (j < last_real_param)
- continue;
-
- if (j == last_real_param) {
- object [] array = new object [pos_arg_count - last_real_param];
- array [0] = pos_values [j];
- pos_values [j] = array;
- continue;
- }
-
- object [] params_array = (object []) pos_values [last_real_param];
- params_array [j - last_real_param] = pos_values [j];
- }
-
- // Adjust the size of the pos_values if it had params
- if (last_real_param != pos_arg_count) {
- object [] new_pos_values = new object [last_real_param + 1];
- Array.Copy (pos_values, new_pos_values, last_real_param + 1);
- pos_values = new_pos_values;
}
// Here we do the checks which should be done by corlib or by runtime.
return null;
}
- return (ConstructorInfo)constructor;
+ return constructor;
}
protected virtual bool ResolveNamedArguments (EmitContext ec)
return false;
}
- if (!IsValidArgumentType (pi.PropertyType)) {
+ if (!IsValidArgumentType (member.Type)) {
Report.SymbolRelatedToPreviousError (pi);
Error_InvalidNamedAgrumentType (member_name);
return false;
}
object value;
- if (!a.Expr.GetAttributableValue (pi.PropertyType, out value))
+ if (!a.Expr.GetAttributableValue (member.Type, out value))
return false;
PropertyBase pb = TypeManager.GetProperty (pi);
return false;
}
- if (!IsValidArgumentType (fi.FieldType)) {
+ if (!IsValidArgumentType (member.Type)) {
Report.SymbolRelatedToPreviousError (fi);
Error_InvalidNamedAgrumentType (member_name);
return false;
}
object value;
- if (!a.Expr.GetAttributableValue (fi.FieldType, out value))
+ if (!a.Expr.GetAttributableValue (member.Type, out value))
return false;
FieldBase fb = TypeManager.GetField (fi);
/// <summary>
/// Tests permitted SecurityAction for assembly or other types
/// </summary>
- public bool CheckSecurityActionValidity (bool for_assembly)
+ protected virtual bool IsSecurityActionValid (bool for_assembly)
{
SecurityAction action = GetSecurityActionValue ();
RootContext.ToplevelTypes.NamespaceEntry = ns;
}
+ protected override bool IsSecurityActionValid (bool for_assembly)
+ {
+ return base.IsSecurityActionValid (true);
+ }
+
void Leave ()
{
RootContext.ToplevelTypes.NamespaceEntry = null;
static PtrHashtable analyzed_types_obsolete;
static PtrHashtable analyzed_member_obsolete;
static PtrHashtable analyzed_method_excluded;
-
-#if NET_2_0
static PtrHashtable fixed_buffer_cache;
-#endif
static object TRUE = new object ();
static object FALSE = new object ();
analyzed_types_obsolete = new PtrHashtable ();
analyzed_member_obsolete = new PtrHashtable ();
analyzed_method_excluded = new PtrHashtable ();
-#if NET_2_0
fixed_buffer_cache = new PtrHashtable ();
-#endif
}
public enum Result {
if (TypeManager.GetConstant (fi) != null)
return null;
-#if NET_2_0
object o = fixed_buffer_cache [fi];
if (o == null) {
+ if (TypeManager.fixed_buffer_attr_type == null)
+ return null;
+
if (!fi.IsDefined (TypeManager.fixed_buffer_attr_type, false)) {
fixed_buffer_cache.Add (fi, FALSE);
return null;
return null;
return (IFixedBuffer)o;
-#else
- return null;
-#endif
}
public static void VerifyModulesClsCompliance ()
// The first module is generated assembly
for (int i = 1; i < modules.Length; ++i) {
Module module = modules [i];
- if (!IsClsCompliant (module)) {
+ if (!GetClsCompliantAttributeValue (module, null)) {
Report.Error (3013, "Added modules must be marked with the CLSCompliant attribute " +
"to match the assembly", module.Name);
return;
return null;
}
- static bool IsClsCompliant (ICustomAttributeProvider attribute_provider)
+ static bool GetClsCompliantAttributeValue (ICustomAttributeProvider attribute_provider, Assembly a)
{
- object[] CompliantAttribute = attribute_provider.GetCustomAttributes (TypeManager.cls_compliant_attribute_type, false);
- if (CompliantAttribute.Length == 0)
+ if (TypeManager.cls_compliant_attribute_type == null)
return false;
- return ((CLSCompliantAttribute)CompliantAttribute[0]).IsCompliant;
+ object[] cls_attr = attribute_provider.GetCustomAttributes (TypeManager.cls_compliant_attribute_type, false);
+ if (cls_attr.Length == 0) {
+ if (a == null)
+ return false;
+
+ return GetClsCompliantAttributeValue (a, null);
+ }
+
+ return ((CLSCompliantAttribute)cls_attr [0]).IsCompliant;
}
static bool AnalyzeTypeCompliance (Type type)
if (TypeManager.IsGenericParameter (type))
return true;
- object[] CompliantAttribute = type.GetCustomAttributes (TypeManager.cls_compliant_attribute_type, false);
- if (CompliantAttribute.Length == 0)
- return IsClsCompliant (type.Assembly);
-
- return ((CLSCompliantAttribute)CompliantAttribute[0]).IsCompliant;
+ return GetClsCompliantAttributeValue (type, type.Assembly);
}
// Registers the core type as we assume that they will never be obsolete which
// Type is external, we can get attribute directly
if (type_ds == null) {
- object[] attribute = type.GetCustomAttributes (TypeManager.obsolete_attribute_type, false);
- if (attribute.Length == 1)
- result = (ObsoleteAttribute)attribute [0];
+ if (TypeManager.obsolete_attribute_type != null) {
+ object [] attribute = type.GetCustomAttributes (TypeManager.obsolete_attribute_type, false);
+ if (attribute.Length == 1)
+ result = (ObsoleteAttribute) attribute [0];
+ }
} else {
result = type_ds.GetObsoleteAttribute ();
}
if ((mi.DeclaringType is TypeBuilder) || TypeManager.IsGenericType (mi.DeclaringType))
return null;
+ if (TypeManager.obsolete_attribute_type == null)
+ return null;
+
ObsoleteAttribute oa = System.Attribute.GetCustomAttribute (mi, TypeManager.obsolete_attribute_type, false)
as ObsoleteAttribute;
analyzed_member_obsolete.Add (mi, oa == null ? FALSE : oa);
return;
}
- if (oa.Message == null) {
+ if (oa.Message == null || oa.Message.Length == 0) {
Report.Warning (612, 1, loc, "`{0}' is obsolete", member);
return;
}
if (excluded != null)
return excluded == TRUE ? true : false;
+ if (TypeManager.conditional_attribute_type == null)
+ return false;
+
ConditionalAttribute[] attrs = mb.GetCustomAttributes (TypeManager.conditional_attribute_type, true)
as ConditionalAttribute[];
if (attrs.Length == 0) {
// TODO: add caching
// TODO: merge all Type bases attribute caching to one cache to save memory
- if (class_decl == null) {
+ if (class_decl == null && TypeManager.conditional_attribute_type != null) {
object[] attributes = type.GetCustomAttributes (TypeManager.conditional_attribute_type, false);
foreach (ConditionalAttribute ca in attributes) {
if (RootContext.AllDefines.Contains (ca.ConditionString))
{
TypeContainer tc = TypeManager.LookupInterface (type);
if (tc == null) {
+ if (TypeManager.coclass_attr_type == null)
+ return null;
+
object[] o = type.GetCustomAttributes (TypeManager.coclass_attr_type, false);
if (o.Length < 1)
return null;
return ((System.Runtime.InteropServices.CoClassAttribute)o[0]).CoClass;
}
- if (tc.OptAttributes == null)
+ if (tc.OptAttributes == null || TypeManager.coclass_attr_type == null)
return null;
Attribute a = tc.OptAttributes.Search (TypeManager.coclass_attr_type);