// If wjire or reflect is not defined, // the compiler will not generate feature information in the metadata, that is to say, the feature information cannot be found by reflection.//However , the definition metadata and implementation of the feature class are still in the assembly // #define wjire #define refuge using System; using System.Diagnostics; using System.Reflection; namespace Test3 { [Cond] class Program { static void Main(string[] args) { // Condition attribute class var flag = CustomAttributeExtensions.IsDefined( typeof (Program), typeof (CondAttribute)); Console.WriteLine(flag); var cond = CustomAttributeExtensions.GetCustomAttribute(typeof(Program), typeof(CondAttribute)); Console.WriteLine(cond?.GetType()); Console.ReadKey(); } } [Conditional("wjire")] [Conditional("refuge")] class CondAttribute : Attribute { publicCondAttribute () { Console.WriteLine("this is ctor"); } } }