Syntax Errors on Saving Dictionary of Lists

Discussion and help for Easy Save 3
Post Reply
User avatar
Cranktrain
Posts: 16
Joined: Thu Nov 09, 2017 7:15 pm

Syntax Errors on Saving Dictionary of Lists

Post by Cranktrain »

Hi there, on the supported types page for ES3 it says that we can save:
Arrays, Lists, Dictionaries, Queues, Stacks and HashSets of supported types
But a field like this:

Code: Select all

private Dictionary<int, List<string>> saveMeIfYouCan;
generates an unusable ES3Type due to some mangled syntax:

Code: Select all

					case "saveMeIfYouCan":
					reader.SetPrivateField("saveMeIfYouCan", reader.Read<System.Collections.Generic.Dictionary<System.Int32,System.Collections.Generic.List`1[System.String]>>(), instance);
					break;
Lots of 'unexpected character' errors there. I'm not an expert in all of C#'s syntax, but the backtick in the List bit is surprising to me? I was expecting to see this get generated:

Code: Select all

					case "saveMeIfYouCan":
					reader.SetPrivateField("saveMeIfYouCan", reader.Read<System.Collections.Generic.Dictionary<System.Int32,System.Collections.Generic.List<System.String>>>(), instance);
					break;
Last edited by Cranktrain on Mon Jun 25, 2018 2:49 pm, edited 1 time in total.
User avatar
Cranktrain
Posts: 16
Joined: Thu Nov 09, 2017 7:15 pm

Re: Syntax Errors on Saving Dictionary of Lists

Post by Cranktrain »

Just had a similar error on a list of enum values:

Code: Select all

public List<Portal.SpawnableTypes> ItemsToSpawn;
Generates this in the ES3Type:

Code: Select all

					case "ItemsToSpawn":
						instance.ItemsToSpawn = reader.Read<System.Collections.Generic.List<Portal+SpawnableTypes>>();
						break;
A misplaced '+' there, instead of a full-stop. I was expecting:

Code: Select all

					case "ItemsToSpawn":
						instance.ItemsToSpawn = reader.Read<System.Collections.Generic.List<Portal.SpawnableTypes>>();
						break;
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Syntax Errors on Saving Dictionary of Lists

Post by Joel »

Hi there,

These were supposed to be fixed in the last update, but it looks like the fixes were not pushed to the release version in time.

If you PM me your invoice number I'll send you over the update.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
PandMEntertm
Posts: 1
Joined: Thu Jun 06, 2019 12:12 pm

Re: Syntax Errors on Saving Dictionary of Lists

Post by PandMEntertm »

Hi, maybe I have the same problem.

I tried to save data as below code.

Code: Select all

if (ES3.KeyExists("MyData"))
 {
   object = ES3.Load<Dictionary<string, MyClass>>("MyData", new Dictionary<string, MyClass>());
 }

public class MyClass
{
    public DateTime time;
    public int to;
    public int price;

    public MyClass(DateTime time, int to, int price)
    {
        this.time = time;
        this.to = to;
        this.price = price;
    }
}
But the below error is shown.

Code: Select all

NotSupportedException: ES3Type.type is null when trying to create an ES3Type for System.Collections.Generic.Dictionary`2[System.String,UmeHistory], possibly because the element type is not supported.
ES3Internal.ES3TypeMgr.CreateES3Type (System.Type type, System.Boolean throwException) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3TypeMgr.cs:109)
ES3Internal.ES3TypeMgr.GetOrCreateES3Type (System.Type type, System.Boolean throwException) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3TypeMgr.cs:23)
ES3Writer.Write[T] (System.String key, System.Object value) (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:86)
ES3.Save[T] (System.String key, System.Object value) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:30)
DataManager.EasySave () (at Assets/Scripts/DataManager.cs:87)
KuraManager.AddMaterial (System.Int32 type) (at Assets/Scripts/KuraManager.cs:372)
UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:207)
UnityEngine.Events.CachedInvokableCall`1[T].Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:345)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_0.cs:70)
UnityEngine.UI.Button.Press () (at C:/Program Files/Unity/Hub/Editor/2019.3.0a4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.3.0a4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.3.0a4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2019.3.0a4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update()
Does it not be supported Dictionary including original defined Class?
Post Reply