Skip to content

Commit

Permalink
[fix] #106
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonXuDeveloper committed Nov 17, 2023
1 parent 0fbe0ca commit 6f3fb94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions Nino_Unity/Assets/Nino/Serialization/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,6 @@ internal static TypeModel CreateModel(Type type)
if (ig.Length > 0) continue;
}

//has to have getter and setter
if (!(p.CanRead && p.CanWrite))
{
if (model.IncludeAll) continue;
throw new InvalidOperationException(
$"Cannot read or write property {p.Name} in {type.FullName}, cannot Serialize or Deserialize this property");
}

if (model.IncludeAll)
{
index++;
Expand All @@ -306,6 +298,14 @@ internal static TypeModel CreateModel(Type type)
ns = p.GetCustomAttributes(NinoMemberType, true);
//not fetch all and no attribute => skip this member
if (ns.Length != 1) continue;

//has to have getter and setter
if (!(p.CanRead && p.CanWrite))
{
if (model.IncludeAll) continue;
throw new InvalidOperationException(
$"Cannot read or write property {p.Name} in {type.FullName}, cannot Serialize or Deserialize this property");
}
index = ((NinoMemberAttribute)ns[0]).Index;
}

Expand Down
16 changes: 8 additions & 8 deletions src/Nino.Serialization/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,6 @@ internal static TypeModel CreateModel(Type type)
if (ig.Length > 0) continue;
}

//has to have getter and setter
if (!(p.CanRead && p.CanWrite))
{
if (model.IncludeAll) continue;
throw new InvalidOperationException(
$"Cannot read or write property {p.Name} in {type.FullName}, cannot Serialize or Deserialize this property");
}

if (model.IncludeAll)
{
index++;
Expand All @@ -306,6 +298,14 @@ internal static TypeModel CreateModel(Type type)
ns = p.GetCustomAttributes(NinoMemberType, true);
//not fetch all and no attribute => skip this member
if (ns.Length != 1) continue;

//has to have getter and setter
if (!(p.CanRead && p.CanWrite))
{
if (model.IncludeAll) continue;
throw new InvalidOperationException(
$"Cannot read or write property {p.Name} in {type.FullName}, cannot Serialize or Deserialize this property");
}
index = ((NinoMemberAttribute)ns[0]).Index;
}

Expand Down

0 comments on commit 6f3fb94

Please sign in to comment.