You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The serializer throws a Null Exception when serializing enums that have the EnumMember attribute without a Value being specified. Exception details:
Name
Value
Type
Message
Object reference not set to an instance of an object.
string
StackTrace
" at YamlDotNet.Core.Emitter.AnalyzeScalar(Scalar scalar)\r\n at YamlDotNet.Core.Emitter.AnalyzeEvent(ParsingEvent evt)\r\n at YamlDotNet.Core.Emitter.Emit(ParsingEvent event)\r\n at YamlDotNet.Serialization.EventEmitters.WriterEventEmitter.YamlDotNet.Serialization.IEventEmitter.Emit(MappingEndEventInfo eventInfo, IEmitter emitter)\r\n at YamlDotNet.Serialization.EventEmitters.ChainedEventEmitter.Emit(MappingEndEventInfo eventInfo, IEmitter emitter)\r\n at YamlDotNet.Serialization.ObjectGraphVisitors.EmittingObjectGraphVisitor.YamlDotNet.Serialization.IObjectGraphVisitor<YamlDotNet.Core.IEmitter>.VisitMappingEnd(IObjectDescriptor mapping, IEmitter context, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphVisitors.ChainedObjectGraphVisitor.VisitMappingEnd(IObjectDescriptor mapping, IEmitter context, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphVisitors.ChainedObjectGraphVisitor.VisitMappingEnd(IObjectDescriptor mapping, IEmitter context, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphVisitors.ChainedObjectGraphVisitor.VisitMappingEnd(IObjectDescriptor mapping, IEmitter context, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphVisitors.ChainedObjectGraphVisitor.VisitMappingEnd(IObjectDescriptor mapping, IEmitter context, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.TraverseProperties[TContext](IObjectDescriptor value, IObjectGraphVisitor1 visitor, TContext context, Stack1 path, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.TraverseObject[TContext](IPropertyDescriptor propertyDescriptor, IObjectDescriptor value, IObjectGraphVisitor1 visitor, TContext context, Stack1 path, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.Traverse[TContext](IPropertyDescriptor propertyDescriptor, Object name, IObjectDescriptor value, IObjectGraphVisitor1 visitor, TContext context, Stack1 path, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.YamlDotNet.Serialization.IObjectGraphTraversalStrategy.Traverse[TContext](IObjectDescriptor graph, IObjectGraphVisitor`1 visitor, TContext context, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.SerializerBuilder.ValueSerializer.SerializeValue(IEmitter emitter, Object value, Type type)\r\n at YamlDotNet.Serialization.Serializer.EmitDocument(IEmitter emitter, Object graph, Type type)\r\n at YamlDotNet.Serialization.Serializer.Serialize(IEmitter emitter, Object graph)\r\n at YamlDotNet.Serialization.Serializer.Serialize(TextWriter writer, Object graph)\r\n at YamlDotNet.Serialization.Serializer.Serialize(Object graph)\r\n at Program.$(String[] args) in C:\Users\...\ConsoleApp1\ConsoleApp1\Program.cs:line 10"
Thanks for the easy reproduction code. I'll have a fix out in a bit. If there is no name set for the EnumMember I'm planning on just using the name of the enum value.
Describe the bug
The serializer throws a Null Exception when serializing enums that have the
EnumMember
attribute without aValue
being specified. Exception details:1 visitor, TContext context, Stack
1 path, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.TraverseObject[TContext](IPropertyDescriptor propertyDescriptor, IObjectDescriptor value, IObjectGraphVisitor1 visitor, TContext context, Stack
1 path, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.Traverse[TContext](IPropertyDescriptor propertyDescriptor, Object name, IObjectDescriptor value, IObjectGraphVisitor1 visitor, TContext context, Stack
1 path, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.ObjectGraphTraversalStrategies.FullObjectGraphTraversalStrategy.YamlDotNet.Serialization.IObjectGraphTraversalStrategy.Traverse[TContext](IObjectDescriptor graph, IObjectGraphVisitor`1 visitor, TContext context, ObjectSerializer serializer)\r\n at YamlDotNet.Serialization.SerializerBuilder.ValueSerializer.SerializeValue(IEmitter emitter, Object value, Type type)\r\n at YamlDotNet.Serialization.Serializer.EmitDocument(IEmitter emitter, Object graph, Type type)\r\n at YamlDotNet.Serialization.Serializer.Serialize(IEmitter emitter, Object graph)\r\n at YamlDotNet.Serialization.Serializer.Serialize(TextWriter writer, Object graph)\r\n at YamlDotNet.Serialization.Serializer.Serialize(Object graph)\r\n at Program.$(String[] args) in C:\Users\...\ConsoleApp1\ConsoleApp1\Program.cs:line 10"To Reproduce
The code below reproduces the issue:
Basically, create any enum with the
[EnumMember]
attribute and try to serialize an object with that.The text was updated successfully, but these errors were encountered: