X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mcs%2Fmcs%2Fattribute.cs;h=a145c37211fd58b2441b23dd32ec5b35a6a12a7a;hb=3e40c70cf4510a02e8deb6ca3076a07df1a3aab2;hp=f05e513ef4a366aa559a640b26d5d31676c2456c;hpb=40c30b5288c16f0590827292e062e59b5a1f2b8c;p=mono.git
diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs
index f05e513ef4a..a145c37211f 100644
--- a/mcs/mcs/attribute.cs
+++ b/mcs/mcs/attribute.cs
@@ -282,6 +282,11 @@ namespace Mono.CSharp {
}
}
+ public void SetOwner (Attributable owner)
+ {
+ targets [0] = owner;
+ }
+
///
/// Tries to resolve the type of the attribute. Flags an error if it can't, and complain is true.
///
@@ -477,10 +482,7 @@ namespace Mono.CSharp {
return null;
}
- ObsoleteAttribute obsolete_attr = Type.GetAttributeObsolete ();
- if (obsolete_attr != null) {
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, Type.GetSignatureForError (), Location, Report);
- }
+ Type.CheckObsoleteness (context, expression.StartLocation);
ResolveContext rc = null;
@@ -574,8 +576,6 @@ namespace Mono.CSharp {
return false;
}
- ObsoleteAttribute obsolete_attr;
-
if (member is PropertyExpr) {
var pi = ((PropertyExpr) member).PropertyInfo;
@@ -591,7 +591,9 @@ namespace Mono.CSharp {
return false;
}
- obsolete_attr = pi.GetAttributeObsolete ();
+// if (!context.IsObsolete)
+ pi.CheckObsoleteness (ec, member.StartLocation);
+
pi.MemberDefinition.SetIsAssigned ();
} else {
var fi = ((FieldExpr) member).Spec;
@@ -607,13 +609,12 @@ namespace Mono.CSharp {
return false;
}
- obsolete_attr = fi.GetAttributeObsolete ();
+// if (!context.IsObsolete)
+ fi.CheckObsoleteness (ec, member.StartLocation);
+
fi.MemberDefinition.SetIsAssigned ();
}
- if (obsolete_attr != null && !context.IsObsolete)
- AttributeTester.Report_ObsoleteMessage (obsolete_attr, member.GetSignatureForError (), member.Location, Report);
-
if (a.Type != member.Type) {
a.Expr = Convert.ImplicitConversionRequired (ec, a.Expr, member.Type, a.Expr.Location);
}
@@ -832,9 +833,9 @@ namespace Mono.CSharp {
///
bool IsSecurityActionValid ()
{
- SecurityAction action = GetSecurityActionValue ();
+ Constant c = null;
+ var action = GetSecurityActionValue (ref c);
bool for_assembly = Target == AttributeTargets.Assembly || Target == AttributeTargets.Module;
- var c = (Constant)pos_args [0].Expr;
switch (action) {
#pragma warning disable 618
@@ -855,6 +856,10 @@ namespace Mono.CSharp {
return true;
break;
#pragma warning restore 618
+ case null:
+ Report.Error (7048, loc, "First argument of a security attribute `{0}' must be a valid SecurityAction",
+ Type.GetSignatureForError ());
+ return false;
default:
Report.Error (7049, c.Location, "Security attribute `{0}' has an invalid SecurityAction value `{1}'",
@@ -876,9 +881,25 @@ namespace Mono.CSharp {
return false;
}
- System.Security.Permissions.SecurityAction GetSecurityActionValue ()
+ SecurityAction? GetSecurityActionValue (ref Constant value)
{
- return (SecurityAction) ((Constant) pos_args[0].Expr).GetValue ();
+ if (pos_args == null) {
+ var predefined = context.Module.PredefinedAttributes;
+
+ //
+ // BCL defines System.Security.Permissions.HostProtectionAttribute with parameterless
+ // contructor which should not be valid but it's already part of the framework
+ //
+ if (Type == predefined.HostProtection.TypeSpec) {
+ value = new IntConstant (context.Module.Compiler.BuiltinTypes, (int)SecurityAction.LinkDemand, loc);
+ return SecurityAction.LinkDemand;
+ }
+
+ return null;
+ }
+
+ value = (Constant) pos_args [0].Expr;
+ return (SecurityAction) value.GetValue ();
}
///
@@ -888,9 +909,14 @@ namespace Mono.CSharp {
public void ExtractSecurityPermissionSet (MethodSpec ctor, ref SecurityType permissions)
{
#if STATIC
- object[] values = new object[pos_args.Count];
- for (int i = 0; i < values.Length; ++i)
- values[i] = ((Constant) pos_args[i].Expr).GetValue ();
+ object[] values;
+ if (pos_args != null) {
+ values = new object[pos_args.Count];
+ for (int i = 0; i < values.Length; ++i)
+ values[i] = ((Constant) pos_args[i].Expr).GetValue ();
+ } else {
+ values = null;
+ }
PropertyInfo[] prop;
object[] prop_values;
@@ -1198,6 +1224,19 @@ namespace Mono.CSharp {
Attrs.AddRange (attrs);
}
+ public static void AttachFromPartial (Attributable target, Attributable partialSrc)
+ {
+ if (target.OptAttributes == null) {
+ target.OptAttributes = partialSrc.OptAttributes;
+ } else {
+ target.OptAttributes.Attrs.AddRange (partialSrc.OptAttributes.Attrs);
+ }
+
+ foreach (var attr in partialSrc.OptAttributes.Attrs) {
+ attr.SetOwner (target);
+ }
+ }
+
public void AttachTo (Attributable attributable, IMemberContext context)
{
foreach (Attribute a in Attrs)
@@ -1679,6 +1718,7 @@ namespace Mono.CSharp {
public readonly PredefinedDebuggerBrowsableAttribute DebuggerBrowsable;
public readonly PredefinedAttribute DebuggerStepThrough;
public readonly PredefinedDebuggableAttribute Debuggable;
+ public readonly PredefinedAttribute HostProtection;
// New in .NET 3.5
public readonly PredefinedAttribute Extension;
@@ -1733,6 +1773,7 @@ namespace Mono.CSharp {
DefaultParameterValue = new PredefinedAttribute (module, "System.Runtime.InteropServices", "DefaultParameterValueAttribute");
OptionalParameter = new PredefinedAttribute (module, "System.Runtime.InteropServices", "OptionalAttribute");
UnverifiableCode = new PredefinedAttribute (module, "System.Security", "UnverifiableCodeAttribute");
+ HostProtection = new PredefinedAttribute (module, "System.Security.Permissions", "HostProtectionAttribute");
DefaultCharset = new PredefinedAttribute (module, "System.Runtime.InteropServices", "DefaultCharSetAttribute");
TypeForwarder = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "TypeForwardedToAttribute");
@@ -1972,8 +2013,8 @@ namespace Mono.CSharp {
int[] bits = decimal.GetBits (value);
AttributeEncoder encoder = new AttributeEncoder ();
- encoder.Encode ((byte) (bits[3] >> 16));
- encoder.Encode ((byte) (bits[3] >> 31));
+ encoder.Encode ((byte) ((bits[3] & 0xFF0000) >> 16)); // Scale
+ encoder.Encode ((byte) ((bits[3] >> 31) << 7)); // Sign encoded as 0x80 for negative, 0x0 for possitive
encoder.Encode ((uint) bits[2]);
encoder.Encode ((uint) bits[1]);
encoder.Encode ((uint) bits[0]);