Broken scripts (And workaround(
Latest update broke scripts that use interfaces and/abstract classes
This fails:
public abstract class AbtractTest
{
//Fails with "'return type must be List<string>..'"
public abstract List<string> getStrings();
//Fails with "'return type must be Dictionary<string, string>..'"
public abstract Dictionary<string, string> getStringDict();
//Fails with no error message (blank popup)
public abstract System.Collections.Generic.List<IMyTerminalBlock> getBlocks();
}
public interface InterfaceTest
{
//Fails with "'return type must be List<string>..'"
List<string> getStrings();
//Fails with "'return type must be Dictionary<string, string>..'"
Dictionary<string, string> getStringDict();
//Fails with no error message (blank popup)
System.Collections.Generic.List<IMyTerminalBlock> getBlocks();
}
Workaround:
Implement wrapper class for all returntypes of interface/abstract class
public class WrapperStringList : List<string> { }
public class WrapperDictionary : Dictionary<string, string> { }
public class WrapperIMyTerminalBlockList : List<IMyTerminalBlock> { }
public abstract class AbtractWorkaroundTest
{
public abstract WrapperStringList getStrings();
public abstract WrapperDictionary getStringDict();
public abstract WrapperIMyTerminalBlockList getBlocks();
}
public interface InterfaceWorkaroundTest
{
WrapperStringList getStrings();
WrapperDictionary getStringDict();
WrapperIMyTerminalBlockList getBlocks();
}
public class AbtractWorkaroundTestImpl : AbtractWorkaroundTest
{
public override WrapperIMyTerminalBlockList getBlocks()
{
return new WrapperIMyTerminalBlockList { { default(IMyTerminalBlock) } };
}
public override WrapperDictionary getStringDict()
{
return new WrapperDictionary { { "test", "test" } };
}
public override WrapperStringList getStrings()
{
return new WrapperStringList { "test" };
}
}
public class InterfaceWorkaroundTestImpl : InterfaceWorkaroundTest
{
public WrapperIMyTerminalBlockList getBlocks()
{
return new WrapperIMyTerminalBlockList { { default(IMyTerminalBlock) } };
}
public WrapperDictionary getStringDict()
{
return new WrapperDictionary { { "test", "test" } };
}
public WrapperStringList getStrings()
{
return new WrapperStringList { "test" };
}
}
public void Main(string argument, UpdateType updateType)
{
var abstracttest = new AbtractWorkaroundTestImpl();
List<string> list = abstracttest.getStrings();
Echo(list[0]);
Dictionary<string, string> dict = abstracttest.getStringDict();
Echo(dict["test"]);
List<IMyTerminalBlock> blocklist = abstracttest.getBlocks();
Echo("isdefault:"+(blocklist[0] == default(IMyTerminalBlock)));
var interfacetest = new InterfaceWorkaroundTestImpl();
List<string> list2 = abstracttest.getStrings();
Echo(list2[0]);
Dictionary<string, string> dict2 = abstracttest.getStringDict();
Echo(dict2["test"]);
List<IMyTerminalBlock> blocklist2 = abstracttest.getBlocks();
Echo("isdefault:" + (blocklist2[0] == default(IMyTerminalBlock)));
}
I have more that 388000 lines of code. Either i will stop playing SE until Keen fixes this, or I will return with a Parser that parses script and fixes this.
Please paste your code in code blocks. This is a mess to try and read.
Please paste your code in code blocks. This is a mess to try and read.
Hello, Engineer!
Thank you for the provided script.
We've added your report it to our internal ticket on this topic.
We will update this thread when we have more information.
Kind Regards
Keen Software House
Hello, Engineer!
Thank you for the provided script.
We've added your report it to our internal ticket on this topic.
We will update this thread when we have more information.
Kind Regards
Keen Software House
I think we are having the same issue. One of our most-used scripts broke after the update. I ablated the code and narrowed it down to operations on Dictionaries, but had no idea how to fix it. Thanks for posting the workaround! Hopefully, this will get fixed properly.
I think we are having the same issue. One of our most-used scripts broke after the update. I ablated the code and narrowed it down to operations on Dictionaries, but had no idea how to fix it. Thanks for posting the workaround! Hopefully, this will get fixed properly.
Replies have been locked on this page!