@RicardoPontual's comment gave me an idea.
I did this:
[Conditional("DEBUG")]
public class FooAttribute : Attribute { }
[Foo]
public class Bar { }
I compiled in debug mode, and loaded the DLL in ILSpy (it's a disassembler). This is what I found, as expected:
[Foo]
public class Bar { }
Then I compiled in release mode, and loaded that DLL in ILSpy. This is what I found:
public class Bar { }
The Bar class was not decorated this time!
So, the answer is that when you decorate some custom attribute with Conditional, then that attribute itself becomes conditional in the same way.
That's the behavior I wanted. I initially thought to derive from ConditionalAttribute, but it's sealed. Instead you need to decorate your custom attribute.