title: Cannot prevent "Code Analysis" warnings for
body: <p>I am using T4 to generate some code. The code will be in a class called "MyClass.generated.cs" and typical output will look like this.</p>
  
  <pre><code>//&lt;autogenerated/&gt;
  namespace MyNamespace
  {
      using System;
      using System.CodeDom.Compiler;
  
      [GeneratedCode("T4", "1.0.0.0")]
      public partial class MyClass: SomeBaseClass
      {
          private SomeBaseClass myBackingField;
      }
  }
  </code></pre>
  
  <p>However, even though the class is decorated with the <a href="http://msdn.microsoft.com/en-us/library/system.codedom.compiler.generatedcodeattribute.aspx" rel="nofollow noreferrer">GeneratedCodeAttribute</a>, I still get a Code Analysis warning as follows:</p>
  
  <blockquote>
    <p>Field 'MyNamespace.MyClass.myBackingField' is never assigned to, and will always have its default value null</p>
  </blockquote>
  
  <p>I have ensure that the <strong>Project Properties</strong> &rarr; <strong>Code Analysis</strong> &rarr; "Suppress results from generated code (managed only)" checkbox is checked. </p>
  
  <p>Please note that I understand the meaning of the warning - I just want to know how to suppress it :)</p>
  
  <p><strong>Possible solutions</strong>
  I could modify my generator to use Suppressions to suppress specific warnings, but this is extra work that I shouldn't have to do (as generated code should be ignored by Code Analysis).</p>
  
  <p><strong>Related Questions</strong></p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/6299583/visual-studio-code-analysis-for-generated-files">Visual studio code analysis for generated files</a></li>
  </ul>
  
  <p><strong>EDIT with background context</strong>
  The actual generated code is essentially a wrapper around <code>SomeBaseClass</code>. There are 100+ types in a namespace, and I want to change the behaviour of a subset of those. There are other warnings being generated as well - I just used this one as an example. Consider for example, if there is a property <code>SomeBaseClass.MyObsoleteProperty</code>, which is decorated with the <code>ObsoleteAttribute</code>. My code generater would still create a <code>MyClass.MyObsoleteProperty</code> which would raise a Code Analysis warning.</p>
  
  <p>Another example would be where the <code>SomeBaseClass</code> (which is from a 3rd-party) would itself raise Code Analysis warnings if they had bothered to check for them (maybe the class is not CLS-compliant, for example). My wrapper will recreate any errors they have (and that would actually be the desired behaviour).</p>