Start a new topic

Type passed in attribute is turned into Delegate with DuoCode

Getting type via typeof(ITestB) and via typeof(ITestB) as a parameter to attribute results in different results.

The second one results in some weird type, which looks like Delegete type. Anyway, it does not contain any of the properties of Type.

You assistance please. 


public class MyAttribute : Attribute
 public Type MyType { get; set; }
 public MyAttribute(Type myType)
 Console.WriteLine("MyAttribute - " + myType + " | " + myType.GetType());
 MyType = myType;
 }  }
 public class TestB : ITestB
MyAttribute - My.ITestB | System.Type: System.Delegate

Just to clarify:

myType != typeof(ITestB)

when the actual value in myType is ITestB

Also, when executing 


the result is

System.Type, which is as expected.

Thanks we reproduced this bug and already fixed it in the coming DuoCode 2.2.

Just to let you know in resulted JS instead of

[new MyAttribute.ctor(ITestB)]

should be

[new MyAttribute.ctor($d.typeOf(ITestB))]

I've been able to overcome this with:

public MyAttribute(Type serviceInterface)
 var isValidType = serviceInterface.GetType() == typeof(Type);
 if (isValidType)
 ServiceInterfaceType = (Type)serviceInterface;
 string serviceInterfaceFullName = ((dynamic)serviceInterface).toString(); // In order to overcome DuoCode's bug (the type transformed into Delegate). So just comapre FullName of types instead...
  ServiceInterfaceType = System.Type.GetType(serviceInterfaceFullName);
 ServiceInterfaceType = serviceInterface;
Login or Signup to post a comment