question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

4.2.0 .Include<DerivedSourceType, DerivedTargetType> throws exception with base type names

See original GitHub issue

Creating a map and including a map which doesn’t exist throws an exception that doesn’t really help find the missing map.

Consider the following:

`

    public class SourceDerived
    {
    }

    public interface IMyInterface
    {
    }

    public class TargetDerived : IMyInterface
    {
    }

    [TestMethod]
    public void MyTestMethod()
    {
        var config = new MapperConfiguration(cfg =>
            cfg.CreateMap<object, IMyInterface>()
                .Include<SourceDerived, TargetDerived>()
            );
    }

` The test throws an exception with message :

System.InvalidOperationException: Missing map from Object to IMyInterface. Create using Mapper.CreateMap<Object, IMyInterface>.

It is right to throw because I have not defined a map from SourceDerived to TargetDerived.

In my opinion it would be much more helpful if the message read:

System.InvalidOperationException: Missing map from SourceDerived to TargetDerived. Create using Mapper.CreateMap<SourceDerived , TargetDerived>.

@jbogard If you agree, I would happily provide a PR

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
PehrGitcommented, Feb 3, 2016

Yay I helped!

0reactions
lock[bot]commented, May 7, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception Class (System)
When an error occurs, either the system or the currently executing application reports it by throwing an exception that contains information about the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found