title: Generate code with Custom Attribute in C#
body: <p>I'm making a game using C# and I've been using A LOT of the following property definition:</p>
  
  <pre><code>private Prop&lt;int&gt; _attack;
  public int Attack
  {
      get { return _attack.Get(); }
      set { _attack.Set(value); }
  }
  </code></pre>
  
  <p>The "Prop" class implementation is not relevant, but the "Get" is a simpler way of returning the property, and the "Set" sets the property AND sends an event to however is listening (if the value is different than the previous one)</p>
  
  <p>This way, I can easily change the property and still get a notification of the change.</p>
  
  <p>So far so good. But this way of implementing these "auto event-listener properties" makes a definition be 5~6 lines worth.</p>
  
  <p>-- 10 properties = 50~60 lines of code. There's got to be a better way. --</p>
  
  <p>My question is... Is there a way to generate code during compile time, using Custom Attributes that writes these lines of code for me?</p>
  
  <p>For example:</p>
  
  <pre><code>[AutoProp]
  public int Attack;
  </code></pre>
  
  <p>Turns into...</p>
  
  <pre><code>private Prop&lt;int&gt; _attack;
  public int Attack
  {
      get { return _attack.Get(); }
      set { _attack.Set(value); }
  }
  </code></pre>
  
  <p>Is there such a thing?</p>
  
  <p>Thanks</p>