Does D have a nice way to add annotations or custom attributes to entities?<div><br></div><div>In Java/C# for example, it is common to annotate things with useful compile time information. I'd like to be able to do that in D on occasion.</div>
<div><br></div><div>For instance, I'm serialising some struct/class using reflection to some text format, but there are a couple of members in a particular class that I don't want to be written.</div><div>A nice solution might be that I could annotate various members: @DoNotSerialise int thing; ... or something along those lines, whatever concept you want to apply, which I could then inspect in static if() logic to produce some requested additional behaviour.</div>
<div><br></div><div>This is a trivial example, but looking at C#/Java, you can see how many useful things can be done with this sort of system.</div><div>How would it be done currently?</div>