Page 1 of 1

Non-generic Read methods for ES3Types

Posted: Fri Sep 16, 2022 11:17 am
by Joel
Status

Requested

Complexity

6/10

Description

Sometimes it is necessary to to get a field via reflection within an ES3Type (e.g. when working with internal classes from outside of their assembly).

Anecdote from Falondrian in the Unity thread:
6. ES3Reader provides the following function
Code (CSharp):
public virtual T Read<T>()
{
return Read<T>(ES3TypeMgr.GetOrCreateES3Type(typeof(T)));
}
I would like to have a non-generic version. When serializing internal classes their Type has to be acquired via reflection so a generic method cannot be used.
Code (CSharp):
public virtual object Read(Type type)
{
return Read(ES3TypeMgr.GetOrCreateES3Type(type));
}

reader.SetPrivateField("m_ID", reader.Read(Type.GetType("OtherAssembly.SomeInternalIDClass")), instance);