ProjectStarlight / StarlightRiver

Starlight River mod
https://discord.gg/snWQ3QE
GNU General Public License v3.0
146 stars 44 forks source link

Address cloneable warnings in logs #695

Open Chicken-Bones opened 7 months ago

Chicken-Bones commented 7 months ago

Issue Description

These warnings indicate potential issues or bugs, and can be silenced with a review. It's always good to keep your logs clean.

Note the recommended action is

For deep-cloning, add a custom Clone override and make proper copies of these fields. If shallow (memberwise) cloning is acceptable, mark the fields with [CloneByReference] or properties with [field: CloneByReference]

Item cloning happens when splitting a stack, so it's mostly a non-issue for non-stackable items, but that's not the only place it can ever happen. You don't want two items sharing a mutable field. Let me know if you'd like some help with any specific item in the list.

StarlightRiver.Content.Abilities.InfusionItem has reference fields (ability, <AbilityType>k__BackingField) that may not be safe to share between clones.
StarlightRiver.Content.Items.BaseTypes.SmartAccessory has reference fields (parents) that may not be safe to share between clones.
StarlightRiver.Content.Items.Breacher.Scrapshot has reference fields (hook) that may not be safe to share between clones.
StarlightRiver.Content.Items.BaseTypes.CursedAccessory has reference fields (Glow, parents) that may not be safe to share between clones.
StarlightRiver.Content.Items.Dungeon.StarlightPendant has reference fields (manaConsumed) that may not be safe to share between clones.
StarlightRiver.Core.Systems.CombatMountSystem.CombatMountItem has reference fields (mount) that may not be safe to share between clones.
StarlightRiver.Content.Items.Food.Meal has reference fields (<Ingredients>k__BackingField) that may not be safe to share between clones.
StarlightRiver.Content.Items.Forest.SlimePrinceHead has reference fields (prince) that may not be safe to share between clones.
StarlightRiver.Content.Items.Haunted.PoltergeistHead has reference fields (minions) that may not be safe to share between clones.
StarlightRiver.Content.Items.Jungle.Corpseflower has reference fields (maxTimeLefts, Glow, parents) that may not be safe to share between clones.
StarlightRiver.Content.Items.Magnet.Thunderbuss has reference fields (ball) that may not be safe to share between clones.
StarlightRiver.Content.Items.BaseTypes.MultiAmmoWeapon has reference fields (<ValidAmmos>k__BackingField, ammoItem) that may not be safe to share between clones.
StarlightRiver.Content.Items.Misc.MagmaGun has reference fields (proj) that may not be safe to share between clones.
StarlightRiver.Content.Items.Misc.SoilgunFiles.SoilgunGlobalItem has reference fields (ammoTooltip) that may not be safe to share between clones.
StarlightRiver.Content.Items.Misc.Sorcerwrench has reference fields (proj) that may not be safe to share between clones.
StarlightRiver.Core.InworldItem has reference fields (inWorldNPC) that may not be safe to share between clones.
StarlightRiver.Content.Items.Starwood.StarwoodItem has reference fields (EmpoweredTexture) that may not be safe to share between clones.
StarlightRiver.Core.Systems.KeywordSystem.KeywordScanner has reference fields (thisKeywords) that may not be safe to share between clones.
ScalarVector1 commented 7 months ago

https://github.com/ProjectStarlight/StarlightRiver/pull/697 Currently looking at this to address these. Please tell me if anything there looks incorrect.