diff --git a/YamlDotNet.Analyzers.StaticGenerator/SerializableSyntaxReceiver.cs b/YamlDotNet.Analyzers.StaticGenerator/SerializableSyntaxReceiver.cs
index 3ec37637..50a0a751 100644
--- a/YamlDotNet.Analyzers.StaticGenerator/SerializableSyntaxReceiver.cs
+++ b/YamlDotNet.Analyzers.StaticGenerator/SerializableSyntaxReceiver.cs
@@ -210,7 +210,7 @@ private void HandleEnum(ITypeSymbol type)
if (enumMember != null)
{
var argument = enumMember.NamedArguments.FirstOrDefault(x => x.Key == "Value");
- if (!string.IsNullOrWhiteSpace(argument.Value.Value as string))
+ if ((argument.Value.Value as string) != null)
{
memberValue = (string)argument.Value.Value!;
}
diff --git a/YamlDotNet.Test/Analyzers/StaticGenerator/ObjectTests.cs b/YamlDotNet.Test/Analyzers/StaticGenerator/ObjectTests.cs
index 9128cf62..0fd73e8c 100644
--- a/YamlDotNet.Test/Analyzers/StaticGenerator/ObjectTests.cs
+++ b/YamlDotNet.Test/Analyzers/StaticGenerator/ObjectTests.cs
@@ -231,8 +231,8 @@ public void EnumSerializationUsesEnumMemberAttribute()
public void EnumSerializationUsesEnumMemberAttributeWithEmptyValue()
{
var serializer = new StaticSerializerBuilder(new StaticContext()).Build();
- var actual = serializer.Serialize(EnumMemberedEnum.EmptyValue);
- Assert.Equal("EmptyValue", actual.TrimNewLines());
+ var actual = serializer.Serialize(new EnumMemberedEnumHarness { Test = EnumMemberedEnum.EmptyValue });
+ Assert.Equal("Test: ''", actual.TrimNewLines());
}
[Fact]
@@ -243,6 +243,12 @@ public void EnumSerializationUsesEnumMemberAttributeWithNullValue()
Assert.Equal("NullValue", actual.TrimNewLines());
}
+ [YamlSerializable]
+ public class EnumMemberedEnumHarness
+ {
+ public EnumMemberedEnum Test { get; set; }
+ }
+
[YamlSerializable]
public enum EnumMemberedEnum
{
diff --git a/YamlDotNet.Test/Serialization/SerializationTests.cs b/YamlDotNet.Test/Serialization/SerializationTests.cs
index 3da25ab8..7bff67b1 100644
--- a/YamlDotNet.Test/Serialization/SerializationTests.cs
+++ b/YamlDotNet.Test/Serialization/SerializationTests.cs
@@ -1500,8 +1500,8 @@ public void EnumSerializationUsesEnumMemberAttribute()
public void EnumSerializationUsesEnumMemberAttributeWithEmptyValue()
{
var serializer = new SerializerBuilder().Build();
- var actual = serializer.Serialize(EnumMemberedEnum.EmptyValue);
- Assert.Equal("EmptyValue", actual.TrimNewLines());
+ var actual = serializer.Serialize(new { Test = EnumMemberedEnum.EmptyValue });
+ Assert.Equal("Test: ''", actual.TrimNewLines());
}
[Fact]
diff --git a/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs b/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs
index b5b0ec6b..7ded332b 100644
--- a/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs
+++ b/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs
@@ -32,7 +32,7 @@ namespace YamlDotNet.Serialization.ObjectFactories
///
/// Creates objects using Activator.CreateInstance.
///
- public sealed class DefaultObjectFactory : ObjectFactoryBase
+ public class DefaultObjectFactory : ObjectFactoryBase
{
private readonly Dictionary> stateMethods = new()
{
diff --git a/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs
index 743b3b55..80cbe5ef 100644
--- a/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs
@@ -30,7 +30,7 @@ namespace YamlDotNet.Serialization.TypeInspectors
///
/// Wraps another and applies caching.
///
- public sealed class CachedTypeInspector : TypeInspectorSkeleton
+ public class CachedTypeInspector : TypeInspectorSkeleton
{
private readonly ITypeInspector innerTypeDescriptor;
private readonly ConcurrentDictionary> cache = new ConcurrentDictionary>();
diff --git a/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs
index af366e69..53c1c80b 100644
--- a/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs
@@ -28,7 +28,7 @@ namespace YamlDotNet.Serialization.TypeInspectors
///
/// Aggregates the results from multiple into a single one.
///
- public sealed class CompositeTypeInspector : TypeInspectorSkeleton
+ public class CompositeTypeInspector : TypeInspectorSkeleton
{
private readonly IEnumerable typeInspectors;
diff --git a/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs
index 5a4356ab..c77bd003 100644
--- a/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs
@@ -29,7 +29,7 @@ namespace YamlDotNet.Serialization.TypeInspectors
/// Wraps another and applies a
/// naming convention to the names of the properties.
///
- public sealed class NamingConventionTypeInspector : TypeInspectorSkeleton
+ public class NamingConventionTypeInspector : TypeInspectorSkeleton
{
private readonly ITypeInspector innerTypeDescriptor;
private readonly INamingConvention namingConvention;
diff --git a/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs
index d2418af6..9eac967c 100644
--- a/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs
@@ -28,7 +28,7 @@ namespace YamlDotNet.Serialization.TypeInspectors
///
/// Returns the properties of a type that are both readable and writable.
///
- public sealed class ReadableAndWritablePropertiesTypeInspector : TypeInspectorSkeleton
+ public class ReadableAndWritablePropertiesTypeInspector : TypeInspectorSkeleton
{
private readonly ITypeInspector innerTypeDescriptor;
diff --git a/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs
index 51fbb3d0..e779f2aa 100644
--- a/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs
@@ -30,7 +30,7 @@ namespace YamlDotNet.Serialization.TypeInspectors
///
/// Returns the properties and fields of a type that are readable.
///
- public sealed class ReadableFieldsTypeInspector : ReflectionTypeInspector
+ public class ReadableFieldsTypeInspector : ReflectionTypeInspector
{
private readonly ITypeResolver typeResolver;
@@ -46,7 +46,7 @@ public override IEnumerable GetProperties(Type type, object
.Select(p => (IPropertyDescriptor)new ReflectionFieldDescriptor(p, typeResolver));
}
- private sealed class ReflectionFieldDescriptor : IPropertyDescriptor
+ protected class ReflectionFieldDescriptor : IPropertyDescriptor
{
private readonly FieldInfo fieldInfo;
private readonly ITypeResolver typeResolver;
diff --git a/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs
index 903781e4..e578d522 100644
--- a/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs
@@ -30,7 +30,7 @@ namespace YamlDotNet.Serialization.TypeInspectors
///
/// Returns the properties of a type that are readable.
///
- public sealed class ReadablePropertiesTypeInspector : ReflectionTypeInspector
+ public class ReadablePropertiesTypeInspector : ReflectionTypeInspector
{
private readonly ITypeResolver typeResolver;
private readonly bool includeNonPublicProperties;
@@ -60,7 +60,7 @@ public override IEnumerable GetProperties(Type type, object
.Select(p => (IPropertyDescriptor)new ReflectionPropertyDescriptor(p, typeResolver));
}
- private sealed class ReflectionPropertyDescriptor : IPropertyDescriptor
+ protected class ReflectionPropertyDescriptor : IPropertyDescriptor
{
private readonly PropertyInfo propertyInfo;
private readonly ITypeResolver typeResolver;
diff --git a/YamlDotNet/Serialization/TypeInspectors/ReflectionTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/ReflectionTypeInspector.cs
index 00273f8f..23eade34 100644
--- a/YamlDotNet/Serialization/TypeInspectors/ReflectionTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/ReflectionTypeInspector.cs
@@ -59,7 +59,7 @@ public override string GetEnumValue(object enumValue)
if (enumMembers.Length > 0)
{
var attribute = enumMembers[0].GetCustomAttribute();
- if (!string.IsNullOrWhiteSpace(attribute?.Value))
+ if (attribute?.Value != null)
{
result = attribute.Value;
}
diff --git a/YamlDotNet/Serialization/TypeInspectors/WritablePropertiesTypeInspector.cs b/YamlDotNet/Serialization/TypeInspectors/WritablePropertiesTypeInspector.cs
index 2111f059..2b9a6897 100644
--- a/YamlDotNet/Serialization/TypeInspectors/WritablePropertiesTypeInspector.cs
+++ b/YamlDotNet/Serialization/TypeInspectors/WritablePropertiesTypeInspector.cs
@@ -30,7 +30,7 @@ namespace YamlDotNet.Serialization.TypeInspectors
///
/// Returns the properties of a type that are writable.
///
- public sealed class WritablePropertiesTypeInspector : ReflectionTypeInspector
+ public class WritablePropertiesTypeInspector : ReflectionTypeInspector
{
private readonly ITypeResolver typeResolver;
private readonly bool includeNonPublicProperties;
@@ -61,7 +61,7 @@ public override IEnumerable GetProperties(Type type, object
.ToArray();
}
- private sealed class ReflectionPropertyDescriptor : IPropertyDescriptor
+ protected class ReflectionPropertyDescriptor : IPropertyDescriptor
{
private readonly PropertyInfo propertyInfo;
private readonly ITypeResolver typeResolver;