bool t1_is_attr = false;
Type t1 = ResolvePossibleAttributeType (ec, Identifier, true, ref t1_is_attr);
- // FIXME: Shouldn't do this for quoted attributes: [@A]
bool t2_is_attr = false;
- Type t2 = ResolvePossibleAttributeType (ec, Identifier + "Attribute", true, ref t2_is_attr);
+ Type t2 = nameEscaped ? null :
+ ResolvePossibleAttributeType (ec, Identifier + "Attribute", true, ref t2_is_attr);
- if (t1_is_attr && t2_is_attr && !nameEscaped) {
+ if (t1_is_attr && t2_is_attr) {
Report.Error (1614, Location, "`{0}' is ambiguous between `{0}' and `{0}Attribute'. Use either `@{0}' or `{0}Attribute'", GetSignatureForError ());
resolve_error = true;
return;
} else if (e is EmptyCast) {
Expression child = ((EmptyCast)e).Child;
return GetAttributeArgumentExpression (child, loc, child.Type, out result);
+ } else if (e is As) {
+ As as_e = (As) e;
+ return GetAttributeArgumentExpression (as_e.Expr, loc, as_e.ProbeType.Type, out result);
}
result = null;
bool IsValidArgumentType (Type t)
{
+ if (t.IsArray)
+ t = t.GetElementType ();
+
return TypeManager.IsPrimitiveType (t) ||
- (t.IsArray && TypeManager.IsPrimitiveType (t.GetElementType ())) ||
TypeManager.IsEnumType (t) ||
t == TypeManager.string_type ||
t == TypeManager.object_type ||
return null;
}
+ //
+ // Theoretically, we can get rid of this, since FieldBuilder.SetCustomAttribute()
+ // and ParameterBuilder.SetCustomAttribute() are supposed to handle this attribute.
+ // However, we can't, since it appears that the .NET 1.1 SRE hangs when given a MarshalAsAttribute.
+ //
public UnmanagedMarshal GetMarshal (Attributable attr)
{
UnmanagedType UnmanagedType;
if (!RootContext.StdLib || pos_values [0].GetType () != typeof (UnmanagedType))
- UnmanagedType = (UnmanagedType)System.Enum.ToObject (typeof (UnmanagedType), pos_values [0]);
+ UnmanagedType = (UnmanagedType) System.Enum.ToObject (typeof (UnmanagedType), pos_values [0]);
else
UnmanagedType = (UnmanagedType) pos_values [0];
}
object o = GetFieldValue ("ArraySubType");
- UnmanagedType array_sub_type = o == null ? UnmanagedType.I4 : (UnmanagedType) o;
-
+ UnmanagedType array_sub_type = o == null ? (UnmanagedType) 0x50 /* NATIVE_MAX */ : (UnmanagedType) o;
+
switch (UnmanagedType) {
case UnmanagedType.CustomMarshaler: {
MethodInfo define_custom = typeof (UnmanagedMarshal).GetMethod ("DefineCustom",
- BindingFlags.Static | BindingFlags.Public);
+ BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (define_custom == null) {
Report.RuntimeMissingSupport (Location, "set marshal info");
return null;
object size_param_index = GetFieldValue ("SizeParamIndex");
if ((size_const != null) || (size_param_index != null)) {
- MethodInfo define_array = typeof (UnmanagedMarshal).GetMethod ("DefineLPArrayInternal", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
+ MethodInfo define_array = typeof (UnmanagedMarshal).GetMethod ("DefineLPArrayInternal",
+ BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (define_array == null) {
Report.RuntimeMissingSupport (Location, "set marshal info");
return null;
}
case UnmanagedType.SafeArray:
return UnmanagedMarshal.DefineSafeArray (array_sub_type);
-
+
case UnmanagedType.ByValArray:
FieldMember fm = attr as FieldMember;
if (fm == null) {
return null;
}
return UnmanagedMarshal.DefineByValArray ((int) GetFieldValue ("SizeConst"));
-
+
case UnmanagedType.ByValTStr:
return UnmanagedMarshal.DefineByValTStr ((int) GetFieldValue ("SizeConst"));
-
+
default:
return UnmanagedMarshal.DefineUnmanagedMarshal (UnmanagedType);
}