3

In other words, is there an Attribute that marks a segment of code as not too old, but too new and therefore not quite ready for widespread use?

If I'd have to create a custom Attribute to accomplish this, that's fine. I just wanted to make sure first.

William
  • 423
  • 4
  • 15

2 Answers2

4

No, there's nothing standardized around this. You might want to consider just not exposing code like that though - or only exposing it in beta builds etc.

Jon Skeet
  • 1,335,956
  • 823
  • 8,931
  • 9,049
1

Not an attribute, but there are preprocessor directives (https://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx) which we can use to mark a region of code as "too new" to run. Basically you can define a flag to indicate that piece of code is ready.

Here is an example:

#define FOREST_CAN_RUN
//undef FOREST_CAN_RUN --> disable that feature
using System;
namespace Test
{
    public class Forest
    {
        public void Run()
        {
#if FOREST_CAN_RUN
            Console.Write("Run Forest, Run !");
#else
            Console.Write("Sorry, Jenny");
#endif
        }
    }

    public class Program
    {
        static void Main(string[] args)
        {
            Forest f= new Forest ();
            f.Run();
        }
    }
}
Dio Phung
  • 5,455
  • 4
  • 36
  • 53