Page MenuHomeFeedback Tracker

NonSerialized isn't honoured from a parent class when serialising the class
Closed, ResolvedPublic

Description

Say the two classes below exist as follows

class ExpansionMissionEventBase
{
	bool Enabled;

	float Weight;
	int MissionMaxTime;

	[NonSerialized()]
	protected string m_EventName;

	[NonSerialized()]
	protected string m_FileName;

	[NonSerialized()]
	protected float m_CurrentMissionTime;
}
class ExpansionMissionEventAirdrop extends ExpansionMissionEventBase
{
	int Items;
	int Infected;

	[NonSerialized()]
	private bool m_LootHasSpawned;
}

The expected output would be something like this

{
    "Enabled": 1,
    "Weight": 20,
    "MissionMaxTime": 1200,
    "Items": 20,
    "Infected": 50
}

but we get this

{
    "Enabled": 1,
    "Weight": 20,
    "MissionMaxTime": 1200,
    "m_EventName": "Airdrop",
    "m_FileName": "$profile:ExpansionMod\\Missions\\Airdrop_Balota.json",
    "m_CurrentMissionTime": 0,
    "Items": 20,
    "Infected": 50
}

Do note how m_LootHasSpawned is not serialised in both examples but the fields marked with NonSerialized from ExpansionMissionEventBase are serialised in the scenario when it shouldn't be.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Category
General

Event Timeline

Jacob_Mango updated the task description. (Show Details)Sep 30 2019, 10:09 AM

This has to be a user error. Works fine for me. vars markers with [NonSerialized()] behave as they should.

try declare them as: const

eg: private const string PATH = "$profile:no/stop/juststop.json";

They can't be declared as const.

NiiRoZz added a comment.EditedSep 30 2019, 10:31 AM

Looks like serializer not taking [NonSerialized()] variable into account from parent

Ok found the problem. You can't have a ScriptInvoker as a member variable within the class.

Geez closed this task as Resolved.Sep 30 2019, 1:59 PM
Geez claimed this task.