This seems strange unless I am missing something...
public static string ToDomainSolarSystemCelestial(this TypeMapper<string> m)
{
// Does not reference any other assemblies - straight string to string mapping.
return m.Source
}
public static Universe.SolarSystemCelestial ToDomainSolarSystemCelestial(this TypeMapper<Db.SolarSystemCelestial> m)
{
// Maps between a database and business object.
// Requires a reference to the Db assembly.
return new Universe.SolarSystemCelestial()
{
Id = m.Source.Id,
// etc
}
}
Both of these extension methods are defined in the same class. The second override needs to know what a Db.SolarSystemCelestial is so it needs a reference to the containing assembly. However the first is a straight string to string mapping.
Yet if I do this...
var x = Mapper.Map("x").ToDomainSolarSystemCelestial();
.. using the overload that has no dependencies, Visual Studio will complain with the following message:
The type Db.SolarSystemCelestial is not defined in an assembly that is referenced. You must add a reference to assembly Db, Version 1.0.0.0...
If I change the name of one of the methods the problem goes away. Is there a work around to this apart from changing the name? Ideally I would like the overrides to have the same name but deal with different types.
Thanks.
Note: There are questions about finding assemblies that are not referenced but in this case I am asking about the compilation of extension methods and not just a missing assembly reference.