Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2.0
8.3.0
22 changes: 14 additions & 8 deletions src/Moryx/Serialization/DefaultSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,8 @@ public EntryUnitType GetUnitTypeByAttributes(ICustomAttributeProvider property)
{
var unitType = EntryUnitType.None;

// Check if the property is an enum and has the <see cref="System.FlagsAttribute"/>
if (property is PropertyInfo propertyInfo && propertyInfo.PropertyType.IsEnum)
{
if (propertyInfo.PropertyType.GetCustomAttributes(typeof(System.FlagsAttribute), false).Any())
{
unitType = EntryUnitType.Flags;
}
}
if (HasFlagsAttribute(property))
unitType = EntryUnitType.Flags;

var passwordAttr = property.GetCustomAttribute<PasswordAttribute>();
if (passwordAttr != null)
Expand Down Expand Up @@ -327,5 +321,17 @@ protected static object CollectionBuilder(Type collectionType, object currentVal
// Other collections are not supported
return null;
}

/// <summary>
/// Checks if the given property is an enum and has the <see cref="System.FlagsAttribute"/>.
/// </summary>
/// <param name="property">The property to inspect for attributes.</param>
/// <returns>True if the property has the Flags attribute; otherwise, false.</returns>
private bool HasFlagsAttribute(ICustomAttributeProvider property)
{
return property is PropertyInfo propertyInfo &&
propertyInfo.PropertyType.IsEnum &&
propertyInfo.PropertyType.GetCustomAttributes(typeof(System.FlagsAttribute), false).Any();
}
}
}
Loading