using System;
using SystemCollectionsGeneric;
using SystemLinq;
using SystemText;
using SystemReflection;
namespace attribute
{
class Program
{
static void Main(string[] args)
{
Tester t = new Tester();
tCannotRun();
Type tp = typeof(Tester);
MethodInfo methodinfo = tpGetMethod(CannotRun);
TestAttribute myatt = (TestAttribute)AttributeGetCustomAttribute(methodinfo typeof(TestAttribute));
myattRunTest();
}
}
class Tester
{
[Test(Error Here)]
public void CannotRun()
{
ConsoleWriteLine(fuck this is a error);
}
}
[AttributeUsage(AttributeTargetsClass | AttributeTargetsMethod Inherited = true)]
public class TestAttribute : SystemAttribute
{
public TestAttribute(string name)
{
ConsoleWriteLine(name);
}
public void RunTest()
{
ConsoleWriteLine(test here);
}
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13702.html