Sometimes here on the forum I read that TNet can serialize everything, but it seems I have run into a few limitations. I did only use text-mode though. Am I doing something wrong or is that TNet? Pseudo-code follows ...
(1)
When you add a child a la
dn.AddChild ( "MyString", string.Empty )
the file creation on the server silently fails. Do
dn.AddChild ( "MyString", "" )
and it works. Interestingly the log claims that the file was created, but it's just not there. I am not 100% sure of this though. Have to do more tests.
(2)
Dictionaries. This
using System.Collections.Generic;
public static struct MySaveStruct () {
Dictionary
<int,
string> myCargo
= new Dictionary
<int,
string>() {"Food" = 10 };
ends up as:
Cargo = System.Collections.Generic.Dictionary`2[System.String,System.Int32]
Same thing for a Dictionary<int,int> which becomes
Standings = System.Collections.Generic.Dictionary`2[System.Int32,System.Int32]
My guess is that you are not supposed to use Dicts? Instead add a lot of child nodes? Like, AddChild ( "Food", 10) ), AddChild ( "Industrial", 20 )? And then iterate through
dn.GetChild<DataNode>("Cargo").children
right?
(3)
TNet has problems with namespaces? The MySaveStructs works if the props are just ints and strings etc. But
namespace MyNameSpace {
public static struct MySaveStruct () {
List
<WeapStruct
> weapons
= new List
<WeapStruct
>();}
public static struct WeapStruct () {
string name = "MyWeapon";
}
}
|
will result in a hard failure and an entry in Debug/TNetErrors.txt:
[2016/04/27 00:04:05] ERROR: Unable to resolve type 'MyNameSpace.WeapSave'
(... Error Stack ...)
Again, same resolution as above?
Or just throw my complex struct of structs into the BinaryFormatter and send that to the server?
( bonus round )
System.Collections.Generic.List vs TNet.List caught be off guard. And you can't do
BetterList.AddRange ( anotherList );
and
BetterList
<string> myBetterList
= new BetterList
<string> { "First",
"Second" };
and the error talks about IEnumerator?
Is there something I am not seeing here? Design decision you regret now?