Skip to content

Commit

Permalink
Save public-get-private-set properties by default
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyCushnie committed Oct 29, 2024
1 parent 986412d commit 3a2d472
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* `GetAsObject` and `SetAsObject` now fully support all JECS types
* All written files now end with a newline
* Add `ReadableWritableDataFile.DeleteKeyAtPath`
* Changed default property saving behavior: properties with public get are now saved by default, even if set is private

todo update the docs for 1.2

Expand Down
6 changes: 1 addition & 5 deletions JECS/Parsing Logic/ParsingLogicExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ internal static bool IsNullOrEmpty(this string s)
=> String.IsNullOrEmpty(s);


// this is just to enable params
// this extension is just to enable params
internal static object Invoke(this MethodInfo method, object obj, params object[] parameters)
=> method.Invoke(obj, parameters);


internal static bool GetOrSetIsPrivate(this PropertyInfo p)
=> p.GetMethod.IsPrivate || p.SetMethod.IsPrivate;


/// <summary>
/// Like C#'s `default` keyword, but it works on `Type` variables.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion JECS/Parsing Logic/Types/Complex Types/ComplexTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal static IEnumerable<ClassMember> GetValidMembers(this Type type)
if (!p.CanRead || !p.CanWrite || p.GetIndexParameters().Length > 0) continue;
if (Attribute.IsDefined(p, typeof(DontSaveThisAttribute))) continue;
if (ComplexTypeOverrides.IsNeverSaved(p)) continue;
if (p.GetOrSetIsPrivate() && !Attribute.IsDefined(p, typeof(SaveThisAttribute)) && !ComplexTypeOverrides.IsAlwaysSaved(p)) continue;
if (p.GetMethod.IsPrivate && !Attribute.IsDefined(p, typeof(SaveThisAttribute)) && !ComplexTypeOverrides.IsAlwaysSaved(p)) continue;

members.Add(p);
}
Expand Down

0 comments on commit 3a2d472

Please sign in to comment.