Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.
Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.
Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.
Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.
Created attachment 3158 [details] The source file used to reproduce the problem. When using a conditional attribute on an attribute class, the attribute is being created even if the condition isn't met. The following code prints "Hello World!" in Mono and "Attribute not found." in Visual Studio. using System; using System.Reflection; using System.Diagnostics; namespace ConditionalAttributeTesting { class MainClass { public static void Main (string[] args) { UtilityClass.HelloWorld(); } } class UtilityClass { [Some("Hello World!")] public static void HelloWorld () { MethodInfo methodInfo = typeof(UtilityClass).GetMethod ("HelloWorld"); if (methodInfo != null) { SomeAttribute someAttribute = Attribute.GetCustomAttribute (methodInfo, typeof(SomeAttribute)) as SomeAttribute; if (someAttribute != null) { Console.WriteLine (someAttribute.myString); } else { Console.WriteLine("Attribute not found."); } } } } [AttributeUsage(AttributeTargets.All)] [Conditional("NOT_DEFINED")] public sealed class SomeAttribute : Attribute { public string myString { get; private set; } public SomeAttribute (string someText) { myString = someText; } } }
Fixed in master