Skip to content

Commit

Permalink
refactor(SerializedProperty): invert the hidden-in-inspector setting
Browse files Browse the repository at this point in the history
Boolean members should be written in a way that they are positive,
not negative. This changes the attribute constructor and the field
to adhere to that convention.

BREAKING CHANGE: The argument passed in the `SerializedProperty`
attribute constructor to hide the field in the inspector is now
negated. Uses need to be updated to pass the negation of what they
previously passed. The default value of the parameter has been
updated which means the default constructor call doesn't need to be
changed to upgrade to this change.
  • Loading branch information
Christopher-Marcel Böddecker committed Jan 7, 2019
1 parent dfbefc5 commit 2d04301
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Sources/SerializedProperty.Fody/ModuleWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ private static FieldDefinition GetBackingField(PropertyDefinition propertyDefini
LogInfo($"Changed the name of the field '{previousFieldName}' to '{backingFieldDefinition.Name}'.");
}

bool hidesFieldInInspector = (bool)attribute.ConstructorArguments.Single().Value;
if (!hidesFieldInInspector)
bool isFieldVisibleInInspector = (bool)attribute.ConstructorArguments.Single().Value;
if (isFieldVisibleInInspector)
{
return;
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/SerializedProperty/SerializedPropertyAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
[AttributeUsage(AttributeTargets.Property)]
public sealed class SerializedPropertyAttribute : Attribute
{
public readonly bool HidesFieldInInspector;
public readonly bool IsFieldVisibleInInspector;

public SerializedPropertyAttribute(bool hideFieldInInspector = false) =>
HidesFieldInInspector = hideFieldInInspector;
public SerializedPropertyAttribute(bool isFieldVisibleInInspector = true) =>
IsFieldVisibleInInspector = isFieldVisibleInInspector;
}
}

0 comments on commit 2d04301

Please sign in to comment.