Determines whether any custom attributes of a specified type are applied to a module.
using System;
using System.Diagnostics;
[module:Debuggable(true, false)]
public class DemoClass
{
static void Main(string[] args)
{
Type clsType = typeof(DemoClass);
bool isDef = Attribute.IsDefined(clsType.Module, typeof(DebuggableAttribute));
Console.WriteLine(isDef);
if (isDef)
{
DebuggableAttribute dbgAttr = (DebuggableAttribute)Attribute.GetCustomAttribute(clsType.Module, typeof(DebuggableAttribute));
if (dbgAttr != null)
{
Console.WriteLine("JITTrackingEnabled is {0}.",dbgAttr.IsJITTrackingEnabled);
Console.WriteLine("JITOptimizerDisabled is {0}.",dbgAttr.IsJITOptimizerDisabled);
}
}
}
}
Related examples in the same category