Skip to content

Version 9.0: List<int> seems to always be nulled in transit #4680

@rsemparnell

Description

@rsemparnell

Describe the bug
One of my business objects has a List property. It appears to always be lost by the serializer - while my Create() method is RunLocal, the call to Insert() results in a null reference exception when the property is encountered. Even explicitly initializing and optionally setting a test value still results in a null.

The upgrading to v9 document seems to imply that List is explicitly supported?

Version and Platform
CSLA version: 9.0.0
OS: Windows
Platform: ASP.NET Core MVC

Code that Fails

public static readonly PropertyInfo<List<int>> AllowedPurposeIdsProperty = 
    RegisterProperty<List<int>>(c => c.AllowedPurposeIds);

public List<int> AllowedPurposeIds
{
    get => GetProperty(AllowedPurposeIdsProperty);
    set => SetProperty(AllowedPurposeIdsProperty, value);
}

Then the code that sets it:

var NewFolderObj = dataPortalFactory.GetPortal<FileFolder>().Create();
NewFolderObj.FolderName = entry.Name;
NewFolderObj.ModuleID = ModuleID;
NewFolderObj.GroupID = GroupID;
NewFolderObj.Deleted = false;
NewFolderObj.FolderOwnerID = FolderOwnerID;
NewFolderObj.AllowedPurposeIds = AllowedPurposeIds.ToList(); // stored locally as an array for annoying reasons

if (NewFolderObj.IsSavable)
{
    await NewFolderObj.SaveAndMergeAsync();
...

Stack Trace or Exception Detail
When I replaced the object with a string property, it works, but this is not ideal for type safety.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions