Skip to content

Commit

Permalink
fix private setter handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cathei committed Oct 9, 2020
1 parent 9a8c099 commit 758f604
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions BakingSheet/Src/SheetRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Cathei.BakingSheet
{
public abstract class SheetRow<TKey>
{
public TKey Id { get; set; }
public TKey Id { get; internal set; }

public virtual void ConvertFromRaw(SheetConvertingContext context, RawSheetRow row)
{
Expand All @@ -31,7 +31,7 @@ public virtual void VerifyAssets(SheetConvertingContext context)
public abstract class SheetRowElem
{
[JsonIgnore]
public int Index { get; set; }
public int Index { get; internal set; }

public virtual void PostLoad(SheetConvertingContext context)
{
Expand All @@ -51,7 +51,7 @@ public abstract class SheetRowArray<TKey, TElem> : SheetRow<TKey>, IEnumerable<T
where TElem : SheetRowElem, new()
{
[JsonProperty]
protected List<TElem> Arr { get; set; }
protected List<TElem> Arr { get; private set; }

[JsonIgnore]
public int Count => Arr.Count;
Expand Down
4 changes: 3 additions & 1 deletion BakingSheet/Src/SheetUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ

if (member is PropertyInfo pi)
{
var hasSetMethod = pi.SetMethod != null;
var hasSetMethod = pi.GetSetMethod(true) != null;

property.Writable = hasSetMethod;
property.ShouldSerialize = property.ShouldDeserialize = _ => hasSetMethod;
}

Expand Down
Binary file modified UnityProject/Assets/Plugins/BakingSheet/BakingSheet.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;

namespace Cathei.BakingSheet.Examples
Expand All @@ -9,12 +10,14 @@ public class SheetLoader : MonoBehaviour
{
public SheetContainer Sheet { get; private set; }

private void Start()
private async void Start()
{
Sheet = new SheetContainer(new UnityLogger());
Sheet.Load(Path.Combine(Application.streamingAssetsPath, "Excel"));
}
await Sheet.Load(Path.Combine(Application.streamingAssetsPath, "Excel"));

Debug.Log(Sheet.Constants.Count);
Debug.Log(Sheet.Heroes["HERO001"].Count);
Debug.Log(Sheet.Items["ITEM_POTION001"].Name);
}
}

}

0 comments on commit 758f604

Please sign in to comment.