Many rules throw InvalidCastException when they meet a generic method with some generic interfaces around etc.
Unable to cast object of type 'Microsoft.Cci.ClassParameter' to type 'Microsoft.Cci.Interface'.
at Microsoft.Cci.StandardVisitor.VisitInterfaceReference(Interface Interface)
at Microsoft.Cci.StandardVisitor.VisitInterfaceReferenceList(InterfaceList interfaceReferences)
at Microsoft.Cci.Specializer.VisitTypeParameter(TypeNode typeParameter)
at Microsoft.Cci.StandardVisitor.VisitTypeParameterList(TypeNodeList typeParameters)
at Microsoft.Cci.Specializer.VisitMethod(Method method)
…
Test case:
public abstract class Obj
{
}
public interface ITypeFactory<TBase> where TBase : class
{
T CreateInstance<T>() where T : TBase;
}
public class ObjFactory<TObj> : ITypeFactory<TObj> where TObj : Obj
{
public T CreateInstance<T>() where T : TObj
{
return null;
}
}

InvalidCastException in many rules on generic method
dzimmy
Petr,
Thanks for the great repro. You are right, FxCop 1.35 fails to analyze the above members, however, this has been fixed in the latest build of Visual Studio/FxCop and should appear in the next version.
Regards
David