How to use PostSharp to warn if a property is accessed before it has been initialized?
问题 How would I use PostSharp to replace this: [WarnIfGetButUninitialized] public int MyProperty {get; set; } With this: /// <summary> /// Property which warns you if its value is fetched before it has been specifically instantiated. /// </summary> private bool backingFieldIsPopulated = false; private int backingField; public int MyProperty { get { if (backingFieldIsPopulated == false) { Console.WriteLine("Error: cannot fetch property before it has been initialized properly.\n"); return 0; }