Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PrimitiveConverterProvider #131

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ public class PrimitiveConverterProvider : CborConverterProviderBase
{
public override ICborConverter? GetConverter(Type type, CborOptions options)
{
if (type.IsEnum)
{
return CreateGenericConverter(options, typeof(EnumConverter<>), type);
}

switch (Type.GetTypeCode(type))
{
case TypeCode.Boolean:
Expand All @@ -24,15 +29,7 @@ public class PrimitiveConverterProvider : CborConverterProviderBase
case TypeCode.Int16:
return new Int16Converter();
case TypeCode.Int32:
if (type.IsEnum)
{
return CreateGenericConverter(options, typeof(EnumConverter<>), type);
}
else if (type == typeof(int))
{
return new Int32Converter();
}
break;
return new Int32Converter();
case TypeCode.Int64:
return new Int64Converter();
case TypeCode.SByte:
Expand Down
Loading