0

I'm making a videogame in Unity using the C# language and VS Code as the editor. Since I often have temporary code laying around that I have to comment and remember to remove afterwards, it would be nice to have some kind of [Temp] attribute to apply to anything. It would work exactly like [Obsolete], in the sense that it gives a compiler warning so that I don't forget about it, but instead of printing "This thing is obsolete" it prints something like "There's a temporary thing you still haven't removed".

Now, my questions are:

  1. Does something like that already exist? Because I haven't found anything
  2. If it doesn't exist, I guess I could define my own custom attribute class. But I have no idea of how to cause a compiler warning manually in VS Code. Is it possible?
  • 1
    how about you just `[Obsolete("add your own message?")]` – Franz Gleichmann Oct 04 '21 at 17:41
  • It might be even easier to use `#if DEBUG` ... your Temp code ... `#endif`, or `[Conditional("DEBUG")]` attributes on such methods (which will automatically remove *calls* to those methods if the *methods are removed by the compiler*). – Peter B Oct 04 '21 at 17:44
  • I use Visual Studio, rather than VS Code, but perhaps it will work the same way. You can set up Tasks by using special comments like // TODO: blah. Then you can find those comments by using the Task List window. It keeps track of all the different things you want to do. TODO, UNDONE, HACK, etc. are supported, and you can add more. – Beska Oct 04 '21 at 17:44
  • Using a `//TODO: Fix this code` style comment is pretty common and many IDEs will highlight that for you too. – DavidG Oct 04 '21 at 17:52

0 Answers0