I am having difficulty persuading FxCop 10.0 to analyse assemblies that reference AutoMapper.
I have created a simple class library, referenced AutoMapper via NuGet, and added the following code:
using System;
namespace ClassLibrary4
{
public class Class1
{
public void Foo()
{
AutoMapper.Mapper.CreateMap<Obj1, Obj2>()
.ForMember(x => x.Name, opt => opt.Ignore());
}
}
public class Obj1
{
public string Name { get; set; }
}
public class Obj2
{
public string Name { get; set; }
}
}
I then tried to use FxCop 10.0 to analyse the assembly via the command line, and receive the message:
Could not load C:\Users\inelson\Documents\Visual Studio 2013\Projects\ClassLibrary4\ClassLibrary4\bin\Debug\ClassLibrary4.dll.
NOTE: One or more referenced assemblies could not be found. Use the '/directory' or '/reference' switch to specify additional assembly reference search paths.
Unresolved reference is to System.Core Version 2.0.5.0.
In an effort to isolate the issue, I removed the .ForMember method call, leaving Foo() as simply:
public void Foo()
{
AutoMapper.Mapper.CreateMap<Obj1, Obj2>();
}
and FxCop 10.0 now happily analyses the assembly!
What is it with the .ForMember method that is causing the FxCop analysis to fail?
Note that I am experiencing the same behaviour with .NET Framework versions 4.0, 4.5 or 4.5.1, and AutoMapper 3.0.0 and 3.1.0.