headstart icon indicating copy to clipboard operation
headstart copied to clipboard

Enforce strongly typed xp on extended resource classes

Open ArchitectedDev opened this issue 3 years ago • 0 comments

Custom classes that extend a resource with a specified strongly-typed xp require the xp to be assigned in the constructor to enforce the strongly-typed xp. Currently no extended resource class adheres to this, allowing any xp to be used in code.

Prior to making the change to each class, we will need to validate that we don't introduce any data corruption to existing usages of the extended resource class or any instance of the base resource class.

The example provided in ordercloud-dotnet-sdk: Strongly Typed xp:

public class MyUser : User<MyUserXp> (
    public MyUser() {
        xp = new MyUserXp();
    }
)

public class MyUserXp
{
    public string Gender { get; set; }
}

var user = new MyUser();
user.xp.Gender = "male"; // strongly typed!

ArchitectedDev avatar Jun 02 '22 03:06 ArchitectedDev