Skip to content

Commit

Permalink
fix(json): prevent user editing of deprecated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed Oct 16, 2024
1 parent ab4358e commit 022b3cb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
1 change: 0 additions & 1 deletion Runtime/ArenaClientScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,6 @@ private IEnumerator ExportGLTF(string name, GameObject[] gameObjects, ExportSett
Debug.LogError($"Filestore login failed!");
yield break;
}
;
}

// determine if we should update the local position
Expand Down
12 changes: 6 additions & 6 deletions Runtime/Schemas/ArenaCubeJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ArenaCubeJson
private static float defDepth = 1f;
[JsonProperty(PropertyName = "depth")]
[Obsolete("depth")]
public float Depth = defDepth;
public float Depth { get; protected set; } = defDepth;
public bool ShouldSerializeDepth()
{
return false; // deprecated in json schema
Expand All @@ -39,7 +39,7 @@ public bool ShouldSerializeDepth()
private static float defHeight = 1f;
[JsonProperty(PropertyName = "height")]
[Obsolete("height")]
public float Height = defHeight;
public float Height { get; protected set; } = defHeight;
public bool ShouldSerializeHeight()
{
return false; // deprecated in json schema
Expand All @@ -48,7 +48,7 @@ public bool ShouldSerializeHeight()
private static int defSegmentsDepth = 1;
[JsonProperty(PropertyName = "segmentsDepth")]
[Obsolete("segments depth")]
public int SegmentsDepth = defSegmentsDepth;
public int SegmentsDepth { get; protected set; } = defSegmentsDepth;
public bool ShouldSerializeSegmentsDepth()
{
return false; // deprecated in json schema
Expand All @@ -57,7 +57,7 @@ public bool ShouldSerializeSegmentsDepth()
private static int defSegmentsHeight = 1;
[JsonProperty(PropertyName = "segmentsHeight")]
[Obsolete("segments height")]
public int SegmentsHeight = defSegmentsHeight;
public int SegmentsHeight { get; protected set; } = defSegmentsHeight;
public bool ShouldSerializeSegmentsHeight()
{
return false; // deprecated in json schema
Expand All @@ -66,7 +66,7 @@ public bool ShouldSerializeSegmentsHeight()
private static int defSegmentsWidth = 1;
[JsonProperty(PropertyName = "segmentsWidth")]
[Obsolete("segments width")]
public int SegmentsWidth = defSegmentsWidth;
public int SegmentsWidth { get; protected set; } = defSegmentsWidth;
public bool ShouldSerializeSegmentsWidth()
{
return false; // deprecated in json schema
Expand All @@ -75,7 +75,7 @@ public bool ShouldSerializeSegmentsWidth()
private static float defWidth = 1f;
[JsonProperty(PropertyName = "width")]
[Obsolete("width")]
public float Width = defWidth;
public float Width { get; protected set; } = defWidth;
public bool ShouldSerializeWidth()
{
return false; // deprecated in json schema
Expand Down
15 changes: 9 additions & 6 deletions Runtime/Schemas/ArenaDataJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
namespace ArenaUnity.Schemas
{
/// <summary>
/// The data object .
/// Wraps all attributes in JSON.
/// </summary>
[Serializable]
public class ArenaDataJson
{
[JsonIgnore]
public readonly string componentName = "data";

// data member-fields

[JsonProperty(PropertyName = "object_type")]
[Tooltip("3D object type.")]
public string object_type = null;
Expand All @@ -31,8 +36,6 @@ public bool ShouldSerializeobject_type()
return (object_type != null);
}

// data member-fields

private static string defParent = null;
[JsonProperty(PropertyName = "parent")]
[Tooltip("Parent's object_id. Child objects inherit attributes of their parent, for example scale and translation.")]
Expand Down Expand Up @@ -303,7 +306,7 @@ public bool ShouldSerializeRemoteRender()
return (RemoteRender != defRemoteRender);
}

private static ArenaVideoControlJson defVideoControl = null;
private static object defVideoControl = null;
[JsonProperty(PropertyName = "video-control")]
[Tooltip("Adds a video to an entity and controls its playback.")]
public ArenaVideoControlJson VideoControl = defVideoControl;
Expand Down Expand Up @@ -356,7 +359,7 @@ public bool ShouldSerializeBuffer()
private static string defColor = null;
[JsonProperty(PropertyName = "color")]
[Obsolete("DEPRECATED: data.color is deprecated for primitive geometry, use data.material.color instead.")]
public string Color = defColor;
public string Color { get; protected set; } = defColor;
public bool ShouldSerializeColor()
{
return false; // deprecated in json schema
Expand Down Expand Up @@ -482,7 +485,7 @@ public bool ShouldSerializeSrc()
private static object defLight = null;
[JsonProperty(PropertyName = "light")]
[Obsolete("DEPRECATED: data.light.[property] is deprecated, use object_type: light and data.[property] instead.")]
public object Light = defLight;
public object Light { get; protected set; } = defLight;
public bool ShouldSerializeLight()
{
return false; // deprecated in json schema
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Schemas/ArenaLightJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public bool ShouldSerializeIntensity()
private static object defLight = null;
[JsonProperty(PropertyName = "light")]
[Obsolete("DEPRECATED: data.light.[property] is deprecated, use object_type: light and data.[property] instead.")]
public object Light = defLight;
public object Light { get; protected set; } = defLight;
public bool ShouldSerializeLight()
{
return false; // deprecated in json schema
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Schemas/ArenaTextJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public bool ShouldSerializeTabSize()
private static string defText = null;
[JsonProperty(PropertyName = "text")]
[Obsolete("DEPRECATED: data.text is deprecated for object_type: text, use data.value instead.")]
public string Text = defText;
public string Text { get; protected set; } = defText;
public bool ShouldSerializeText()
{
return false; // deprecated in json schema
Expand Down

0 comments on commit 022b3cb

Please sign in to comment.