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.

Interface implemented class mappings generates proxy types

See original GitHub issue
public interface IMyInterface
{
    int MyProperty { get; set; }
}

public class ImplementedClass : IMyInterface
{
    public int MyProperty
    {
        get;
        set;
    }
}

public class MyClass
{
    public int MyProperty { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        Mapper.CreateMap<MyClass, IMyInterface>();
        Mapper.AssertConfigurationIsValid();

        var myClassInstance = new MyClass { MyProperty = 3 };

        var obj = Mapper.Map(myClassInstance, typeof(MyClass), typeof(ImplementedClass));

        Debug.Assert(!obj.GetType().Assembly.IsDynamic);
    }
}

This generates Automapper’s interface proxy class types but I think it should create ImplementedClass 's instance.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jbogardcommented, Oct 21, 2015

This isn’t configured properly. In order to achieve this (remember AutoMapper has no idea about ImplementedClass) You have two options:

  • Create a map MyClass -> ImplementedClass and include the base using IncludeBase
  • Configure the IMyInterface mapping to construct your ImplementedClass, .ConstructUsing
0reactions
lock[bot]commented, May 8, 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

Java Mapping for Interfaces - Ice
Proxy objects implement the java.io.Serializable interface that enables serialization of proxies to and from a byte stream. You can use the standard class...
Read more >
java - Getting implemented interfaces from the proxy
Should I memorize interface classes along with the proxy list or there is a way to map proxy to its implementing interfaces, likewise...
Read more >
Java Mapping for Interfaces - Ice
Java Classes Generated for an Interface. The compiler generates quite a few source ... This source file defines the helper type for the...
Read more >
Auto-generating implementation of interface (proxy without ...
1 Answer. So after some research and trial & error i've found out, that the Unity. Interception does not support proxies of interfaces...
Read more >
Proxy (Java Platform SE 8 )
Each proxy class has one public constructor that takes one argument, an implementation of the interface InvocationHandler , to set the invocation handler...
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