-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Consider the following scenario:
public class MyOrder: Order<MyXp>{}
public class MyXp
{
public string Color { get; set; }
}
var order = new MyOrder();
order = (Order)order;
order.xp = 5;
order = (MyOrder)order;
var color = order.xp.Color; // 'myOrder.xp.Color' threw an exception of type 'System.InvalidCastException'The expectation would be that when I use the instance as MyOrder everything will be fine, but it cannot be fine since it is backed by the same dictionary instance and the implementation of ordercloud models does not handle this scenario.
This may seem a bit contrived but I came across this when trying to use AutoFixture to automatically mock ordercloud models with typed xp. AutoFixture cannot ignore the hidden properties, since the hidden property values can always be used, while its lower instance is cast to it's base type.
Metadata
Metadata
Assignees
Labels
No labels