Skip to content

Commit

Permalink
fix PrimitiveConverterProvider
Browse files Browse the repository at this point in the history
fix confusion between Int32 and Enum
  • Loading branch information
mcatanzariti committed Apr 7, 2024
1 parent 26190f7 commit 2661276
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ public class PrimitiveConverterProvider : CborConverterProviderBase
case TypeCode.Int16:
return new Int16Converter();
case TypeCode.Int32:
return new Int32Converter();
if (type.IsEnum)

This comment has been minimized.

Copy link
@Odonno

Odonno Apr 7, 2024

Contributor

Well, enum is not necessarily an int. Maybe put the type.IsEnum block first?

This comment has been minimized.

Copy link
@Odonno

Odonno Apr 7, 2024

Contributor
{
return CreateGenericConverter(options, typeof(EnumConverter<>), type);
}
else if (type == typeof(int))
{
return new Int32Converter();
}
break;
case TypeCode.Int64:
return new Int64Converter();
case TypeCode.SByte:
Expand Down

0 comments on commit 2661276

Please sign in to comment.