title: FxCop fails to analyze an Assembly
body: <p>I'm having a problem with some of the Assemblies in my FxCop analasys.
  Most of the assemblies from our project work fine except those for the Api. FxCop just stops analyzing them after 135 messages, with an Exception.</p>
  
  <p>This is the exception details I get.</p>
  
  <blockquote>
    <p>The following error was encountered while reading module
    'TenForce.Execution.Api2.Implementation': Could not resolve member
    reference: [TenForce.Execution.Api2.Implementation, Version=1.0.0.0,
    Culture=neutral,
    PublicKeyToken=null]TenForce.Execution.Api2.Implementation.Helpers.IdGenerator<code>1&lt;type
    parameter.T&gt;+Wrapper</code>1::Object.</p>
  </blockquote>
  
  <p>I've made sure that all needed assemblies are together and part of the project, but I don't know how to solve this problem.
  Anyone encountered this before?</p>
  
  <ul>
  <li>FxCop 10.0</li>
  <li>Visual Studio 2010</li>
  <li>.NET Framework 4</li>
  <li>TeamCity Test Server</li>
  </ul>
  
  <p><strong>EDIT</strong>
  Adding the source code for the class that's causing the problem:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Reflection;
  using System.Collections.ObjectModel;
  
  namespace TenForce.Execution.Api2.Implementation.Helpers
  {
      /// &lt;summary&gt;
      /// &lt;para&gt;This class is responsible for generating the various Ids for the Ts.&lt;/para&gt;
      /// &lt;/summary&gt;
      public static class IdGenerator&lt;T&gt; where T : class, IEquatable&lt;T&gt;, new()
      {
          /// &lt;summary&gt;
          /// Wraps underlying object. Requires object to have int Id property.
          /// &lt;/summary&gt;
          /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
          public class Wrapper&lt;T&gt; : IEquatable&lt;Wrapper&lt;T&gt;&gt;
          {
              private PropertyInfo piId;
  
              /// &lt;summary&gt;
              /// Wrapper constructor
              /// &lt;/summary&gt;
              /// &lt;param name="instance"&gt;&lt;/param&gt;
              public Wrapper(T instance)
              {
                  Object = instance;
                  Created = DateTime.Now;
                  foreach (var pi in instance.GetType().GetProperties())
                  {
                      if (pi.Name.Equals("id", StringComparison.OrdinalIgnoreCase))
                      {
                          piId = pi;
                      }
                  }
  
                  if (piId == null)
                  {
                      var fullName = instance.GetType().FullName;
                      throw new TypeInitializationException(fullName,
                          new Exception(string.Format("{0} is not compatible with IdGenerator. It requires int Id property to be present", fullName)));
                  }
              }
  
              /// &lt;summary&gt;
              /// Gets or sets wrapped instance Id
              /// &lt;/summary&gt;
              public int Id
              {
                  get
                  {
                      return (int)piId.GetValue(Object, null);
                  }
                  set
                  {
                      piId.SetValue(Object, value, null);
                  }
              }
  
              /// &lt;summary&gt;
              /// Creation date
              /// &lt;/summary&gt;
              public DateTime Created;
  
              /// &lt;summary&gt;
              /// Wrapped instance
              /// &lt;/summary&gt;
              public T Object;
  
              /// &lt;summary&gt;
              /// Implements IEquatable interface
              /// &lt;/summary&gt;
              /// &lt;param name="other"&gt;&lt;/param&gt;
              /// &lt;returns&gt;&lt;/returns&gt;
              public bool Equals(Wrapper&lt;T&gt; other)
              {
                  return Object.Equals(other.Object);
              }
          }
  
          #region Private Fields
  
          private static Wrapper&lt;T&gt;[] _mWrappers = new Wrapper&lt;T&gt;[10];
          private static readonly object MPadLock = new object();
  
          #endregion
  
          #region Public Members
  
          /// &lt;summary&gt;
          /// &lt;para&gt;Generates a new Id for the T and assigns it to the T.&lt;/para&gt;
          /// &lt;/summary&gt;
          /// &lt;param name="obj"&gt;The T that needs a new Id generated.&lt;/param&gt;
          /// &lt;remarks&gt;The T will be stored inside the generator to keep track of the Id and availability.&lt;/remarks&gt;
          public static void GenerateId(T obj)
          {
              lock (MPadLock)
              {
                  // Search the array for an empty spot or an expired T.
                  int index = Array.FindIndex(_mWrappers, s =&gt; s == null || DateTime.Now.Subtract(s.Created).Minutes &gt; 10);
  
                  var wrapper = new Wrapper&lt;T&gt;(obj);
  
                  // If we found such a spot, store the new T in that location,
                  // If we did not find such a spot, expand the array and the T at the end.
                  if (index &gt; -1) _mWrappers[index] = wrapper;
                  else
                  {
                      Array.Resize(ref _mWrappers, _mWrappers.Length + 1);
                      _mWrappers[_mWrappers.Length - 1] = wrapper;
                  }
  
                  // Always update the Id of the T entity with the negative index of the entity's location.
                  wrapper.Id = CalculateId(Array.IndexOf(_mWrappers, wrapper));
              }
          }
  
          /// &lt;summary&gt;
          /// &lt;para&gt;Releases the Id generated for the T and releases the location that was held by the T.&lt;/para&gt;
          /// &lt;/summary&gt;
          /// &lt;param name="obj"&gt;The T that needs to be released.&lt;/param&gt;
          /// &lt;remarks&gt;The T will be removed from the generator and it's Id will be reset to zero !!!&lt;/remarks&gt;
          public static void ReleaseId(T obj)
          {
              lock (MPadLock)
              {
                  var wrapper = new Wrapper&lt;T&gt;(obj);
                  if (wrapper.Id &gt;= 0) return;
                  int index = Array.IndexOf(_mWrappers, wrapper);
                  Array.Clear(_mWrappers, index, 1);
                  wrapper.Id = 0;
              }
          }
  
          /// &lt;summary&gt;
          /// &lt;para&gt;Fetches the specified T from the IdGenerator.&lt;/para&gt;
          /// &lt;/summary&gt;
          /// &lt;param name="id"&gt;The unique identifier of the T.&lt;/param&gt;
          /// &lt;returns&gt;The T with the matching Id or the default instance if not found.&lt;/returns&gt;
          public static T Fetch(int id)
          {
              lock (MPadLock)
              {
                  var found = Array.Find(_mWrappers, s =&gt; s != null &amp;&amp; s.Id == id);
                  return found == null ? new T() : found.Object;
              }
          }
  
          /// &lt;summary&gt;
          /// &lt;para&gt;Updates the matching T entity inside the Generator with the new one.&lt;/para&gt;
          /// &lt;/summary&gt;
          /// &lt;param name="obj"&gt;The T that needs to be updated.&lt;/param&gt;
          public static void Update(T obj)
          {
              lock (MPadLock)
              {
                  int index = Array.IndexOf(_mWrappers, obj);
                  if (index == -1) return;
                  var wrapped = new Wrapper&lt;T&gt;(obj);
                  _mWrappers[index] = wrapped;
                  wrapped.Id = CalculateId(index);
                  wrapped.Created = DateTime.Now;
              }
          }
  
          /// &lt;summary&gt;
          /// &lt;para&gt;Retrieves all the Ts currently available in the application.&lt;/para&gt;
          /// &lt;/summary&gt;
          /// &lt;returns&gt;An enumerable collection containing all the T entities.&lt;/returns&gt;
          public static IEnumerable&lt;T&gt; ListAll()
          {
              lock (MPadLock)
              {
                  return new ReadOnlyCollection&lt;T&gt;(_mWrappers.Select(s =&gt; s == null ? null : s.Object).Where(o =&gt; o != null).ToList());
              }
          }
  
          #endregion
  
          #region Private Members
  
          /// &lt;summary&gt;
          /// &lt;para&gt;Calculates the negative id for an entity based upon the zero-based index.&lt;/para&gt;
          /// &lt;/summary&gt;
          /// &lt;param name="index"&gt;The zero-based index of the entity who's Id needs to be calculated.&lt;/param&gt;
          /// &lt;returns&gt;The new Id for the entity.&lt;/returns&gt;
          private static int CalculateId(int index)
          {
              return (index * -1) - 1;
          }
          #endregion
      }
  }
  </code></pre>