List resolving to MemorySafeList when no alternative is found

Jouster500 shared this bug 9 days ago
Submitted

What is the subject of your issue?: Scripting/ModAPI changes

When did this issue first occur?: May 2nd, 2025, version 1.206.030

Has this issue occurred in the past?: No. This script has worked in previous versions as far back as November 30th of 2020.

Describe the issue:


In a script of mine (attached as a text), I receive the following error when compiling;

Program(1004, 72): Error: Argument 1: cannot convert from 'Sandbox.ModAPI.Ingame.IMyShipController' to 'Program.dir
'Program(1004, 85): Error: Argument 3: cannot convert from 'System.Collections.Generic.List<Program.BlockHandle<T>>' to 'int'
According to the recent patch on May 2nd, 2025, a change was made that changed list behind the scenes to point to MemorySafeList instead. In the following code segment;


// This will attempt to parse out the various versions of enact
public virtual void enact(IMyShipController ctrl, int group, List<Object> list) {
    if (list is List<BlockHandle<T>>) {
            enact(ctrl, group, list as List<BlockHandle<T>>);
    }
}
/** To be overrided */
public void enact(IMyShipController ctrl, int group, List<BlockHandle<T>> list) { }


It appears that List behind the scenes is converted to MemorySafeList. But in this case, it doesnt know how to map `new MemorySafeList<Object>` and is stuck at the first instance of enact. Changing the `List` to `MemorySafeList` of the shared section does allow the code to compile.

Leave a Comment
 
Attach a file