Skip to content

Instantly share code, notes, and snippets.

@waf
Created May 8, 2015 02:18
Show Gist options
  • Save waf/2a4f0140a4fd5491ef1b to your computer and use it in GitHub Desktop.
Save waf/2a4f0140a4fd5491ef1b to your computer and use it in GitHub Desktop.
Expiring TODOs in C#
namespace ExpiringTodos
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
Todo.By(2015, 04, 15, "A general hello is good enough, but we're including 'World' here for compatibility reasons.");
Console.WriteLine("World");
Console.ReadKey();
}
}
class Todo
{
[Conditional("DEBUG")] // only run in DEBUG mode, calls to this method are removed by the compiler in RELEASE mode.
internal static void By(int year, int month, int day, string message)
{
if (DateTime.Now.Date > new DateTime(year, month, day))
{
throw new Exception("A TODO needs to be addressed: " + message);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment