title: Custom Attribute is executed at compile time
body: <p>I'm trying to create a custom attribute that will work in a sort-of AOP way (I don't have access to postsharp, unfortunately and I'm not very familiar with Unity). It has AttributeUsage.Method and in its constructor it configures some parts of the test environment (pulls some info out of app.config and calls some exes that config the environment).</p>
  
  <p>It works, except that right now, when I build the solution, the attribute is executed - which is undesireable. </p>
  
  <p>Is there a way to create a custom attribute that isn't executed at compile time?</p>
  
  <p>edit> I guess an example usage might help:</p>
  
  <pre><code>public void Scenario1Tests
  {
      [Test]
      [Environment(Environments.A)]
      public void Scenario1TestA()
      {
          Assert.Something();
      }
  
      [Test]
      [Environment(Environments.Any)]
      public void Scenario1TestB()
      {
          Assert.SomethingElse();
      }
  }
  
  // Most tests will be written environment independent, some must not
  public enum Environments
  {
      A, 
      B, 
      Any
  };
  
  [AtrributeUsage(AttributeTargets.Method)]
  public void Environment : Attribute
  {
      public Environment(Environments env)
      {
          // lots of test can have this attribute, requirement is 
          // that it is only configured once as it is a lengthy configuration
          if (this.EnvironmentIsAlreadyConfigured())
              return;
  
          this.GetSettingsFromAppConfig();
          Process.Start(/* ... */); // can take 20 mins+
      }        
  
      public Environment()
          : this(Environments.Any)
      {
      }
  }
  </code></pre>