cdata = encoder.ToArray ();
}
- if (!ctor.DeclaringType.IsConditionallyExcluded (context)) {
+ if (!IsConditionallyExcluded (ctor.DeclaringType)) {
try {
foreach (Attributable target in targets)
target.ApplyAttributeBuilder (this, ctor, cdata, predefined);
}
}
+ bool IsConditionallyExcluded (TypeSpec type)
+ {
+ do {
+ if (type.IsConditionallyExcluded (context))
+ return true;
+
+ type = type.BaseType;
+ } while (type != null);
+
+ return false;
+ }
+
private Expression GetValue ()
{
if (pos_args == null || pos_args.Count < 1)
--- /dev/null
+using System;
+using System.Reflection;
+using System.Diagnostics;
+
+namespace ConditionalAttributeTesting
+{
+ class MainClass
+ {
+ public static int Main ()
+ {
+ return HelloWorld ();
+ }
+
+ [Some ("Test")]
+ public static int HelloWorld ()
+ {
+ var methodInfo = MethodBase.GetCurrentMethod ();
+ SomeAttribute someAttribute = Attribute.GetCustomAttribute (methodInfo, typeof (SomeAttribute)) as SomeAttribute;
+ if (someAttribute != null) {
+ return 1;
+ }
+
+ return 0;
+ }
+ }
+
+ [AttributeUsage (AttributeTargets.All)]
+ [Conditional ("NOT_DEFINED")]
+ public abstract class BaseAttribute : Attribute
+ {
+ }
+
+ public class SomeAttribute : BaseAttribute
+ {
+ public SomeAttribute (string someText)
+ {
+ }
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
+ <test name="test-942.cs">
+ <type name="ConditionalAttributeTesting.MainClass">
+ <method name="Int32 Main()" attrs="150">
+ <size>14</size>
+ </method>
+ <method name="Int32 HelloWorld()" attrs="150">
+ <size>52</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="ConditionalAttributeTesting.BaseAttribute">
+ <method name="Void .ctor()" attrs="6276">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="ConditionalAttributeTesting.SomeAttribute">
+ <method name="Void .ctor(String)" attrs="6278">
+ <size>8</size>
+ </method>
+ </type>
+ </test>
<test name="test-95.cs">
<type name="X">
<method name="Int32 Main()" attrs="150">