public abstract string[] ValidAttributeTargets { get; }
};
- public class Attribute {
+ public class Attribute : Expression
+ {
public readonly string ExplicitTarget;
public AttributeTargets Target;
readonly ArrayList PosArguments;
ArrayList NamedArguments;
- public readonly Location Location;
-
- public Type Type;
-
bool resolve_error;
readonly bool nameEscaped;
PosArguments = (ArrayList)args [0];
NamedArguments = (ArrayList)args [1];
}
- Location = loc;
+ this.loc = loc;
ExplicitTarget = target;
this.nameEscaped = nameEscaped;
}
return Type;
}
- public string GetSignatureForError ()
+ public override string GetSignatureForError ()
{
if (Type != null)
return TypeManager.CSharpName (Type);
}
Attributable owner = Owner;
- EmitContext ec = new EmitContext (owner.ResolveContext, owner.ResolveContext.DeclContainer, owner.ResolveContext.DeclContainer,
+ DeclSpace ds = owner.ResolveContext as DeclSpace;
+ if (ds == null)
+ ds = owner.ResolveContext.DeclContainer;
+
+ EmitContext ec = new EmitContext (owner.ResolveContext, ds, owner.ResolveContext.DeclContainer,
Location, null, typeof (Attribute), owner.ResolveContext.DeclContainer.ModFlags, false);
ec.IsAnonymousMethodAllowed = false;
CustomAttributeBuilder cb;
try {
+ // SRE does not allow private ctor but we want to report all source code errors
+ if (ctor.IsPrivate)
+ return null;
+
if (NamedArguments == null) {
cb = new CustomAttributeBuilder (ctor, pos_values);
return null;
}
}
-
- MethodGroupExpr mg = Expression.MemberLookup (ec.ContainerType,
+
+ MethodGroupExpr mg = MemberLookupFinal (ec, ec.ContainerType,
Type, ".ctor", MemberTypes.Constructor,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
Location) as MethodGroupExpr;
public string GetString ()
{
Expression e = GetValue ();
- if (e is StringLiteral)
- return (e as StringLiteral).Value;
+ if (e is StringConstant)
+ return ((StringConstant)e).Value;
return null;
}
public bool GetBoolean ()
{
Expression e = GetValue ();
- if (e is BoolLiteral)
- return (e as BoolLiteral).Value;
+ if (e is BoolConstant)
+ return ((BoolConstant)e).Value;
return false;
}
return null;
return e.TypeArgument;
}
+
+ public override Expression DoResolve (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void Emit (EmitContext ec)
+ {
+ throw new NotImplementedException ();
+ }
}
}
bool result;
- if (type.IsArray || type.IsByRef) {
+ if (type.IsArray || type.IsByRef) {
result = IsClsCompliant (TypeManager.GetElementType (type));
+ } else if (TypeManager.IsNullableType (type)) {
+ result = IsClsCompliant (TypeManager.GetTypeArguments (type) [0]);
} else {
result = AnalyzeTypeCompliance (type);
}
return;
}
- if (oa.Message == null) {
+ if (oa.Message == null || oa.Message.Length == 0) {
Report.Warning (612, 1, loc, "`{0}' is obsolete", member);
return;
}
public static bool IsConditionalMethodExcluded (MethodBase mb)
{
- mb = TypeManager.DropGenericMethodArguments (mb);
- // TODO: Has to be fixed for partial methods
- if ((mb is MethodBuilder) || (mb is ConstructorBuilder))
- return false;
-
object excluded = analyzed_method_excluded [mb];
if (excluded != null)
return excluded == TRUE ? true : false;