I have an abstract class for POs.
public abstract class PO
{
public abstract Dictionary<string, object> InvalidFields { get; }
public abstract string PONumber { get; set; }
}
Which is inherited by two different types of PO: CPO and POR.
public class CPO
{
private string poNumber;
public override Dictionary<string, object> InvalidFields => new Dictionary<string, object>();
public override string PONumber
{
get
{
return poNumber;
}
set
{
if (!ValidatePONumber(value)) InvalidFields.Add("CPO Number", value);
poNumber = value;
}
}
}
When ValidatePONumber(value)
returns false
, it correctly executes InvalidFields.Add()
but the dictionary is never actually added to. In the Locals window, a new variable is created named Namespace.PO.InvalidFields.get returned
and I can see the new key that is added. However, this.InvalidFields
has no values.
So it looks like the dict in the abstract base class PO
is being created and added to instead of the derived class CPO
.