It is not clear what you need.
Firstly, @Ignore means that the JUnit tester ignores the test. You did not mention testing in your question, but it should be clear to us that @Ignore exists for this. Test testers in .NET have similar attributes (for example, in xUnit, the [Ignore] attribute).
So, if you are using a test runner, find the appropriate attribute for this test runner. If you are not using a test runner, what exactly did you indicate after that that @Ignore is native only to test work?
Do you write your own test runner? What for? many really > good affordable test runners. Use them!
I want the attribute to suppress execution, even if the method is called .
Well that smell of code if I ever saw it.
You have several options.
Paste the code in each method that you apply [Ignore] to:
[AttributeUsage(AttributeTargets.Method)] public class Ignore : Attribute { } [Ignore] public static void M() { var ignoreAttributes = MethodBase.GetCurrentMethod().GetCustomAttributes(typeof(Ignore), true); if (ignoreAttributes.Any()) { return; }
Or you can use the interception method.
Or you can use the framework after compilation .
ALL of them have very serious problems. They have problems because what you do is the smell of code.
jason source share