Benchmark kaput

This commit is contained in:
2025-08-16 12:14:03 +03:00
parent 8c137115f4
commit 24d346795d
9 changed files with 219 additions and 21 deletions
+25 -5
View File
@@ -58,7 +58,7 @@ namespace mROA.Cbor
WriteData(objectToSerialize, _writer, context);
result = _writer.Encode();
}
return result;
}
@@ -99,7 +99,6 @@ namespace mROA.Cbor
Console.WriteLine($"Bad deserialization. Bytes: {rawMemory.ToArray().Select(b => $"{b:X}")}");
throw;
}
}
public T Cast<T>(object nonCasted, IEndPointContext? context)
@@ -128,7 +127,7 @@ namespace mROA.Cbor
{
return ReadSharedShell(type, context, (ulong)nonCasted);
}
return Convert.ChangeType(nonCasted, type);
}
@@ -196,9 +195,20 @@ namespace mROA.Cbor
WriteObject(sharedObject, writer, context);
break;
default:
if (obj.GetType().IsEnum)
var objType = obj.GetType();
if (objType.IsEnum)
{
writer.WriteInt32((int)obj);
var basicType = Enum.GetUnderlyingType(obj.GetType());
if (basicType == typeof(byte))
{
writer.WriteInt32((byte)obj);
}
else if (basicType == typeof(int))
{
writer.WriteInt32((byte)obj);
}
break;
}
@@ -283,6 +293,7 @@ namespace mROA.Cbor
{
return ReadSharedShell(type, context, reader.ReadUInt64());
}
return reader.ReadUInt64();
case CborReaderState.ByteString:
if (type == typeof(RequestId))
@@ -446,6 +457,15 @@ namespace mROA.Cbor
{
var property = properties[index];
var value = ReadData(reader, property.PropertyType, context);
if (property.PropertyType.IsEnum)
{
if (property.PropertyType.GetEnumUnderlyingType() == typeof(byte))
{
value = Convert.ChangeType(value, typeof(byte));
}
}
property.SetValue(obj, value);
}
+2 -2
View File
@@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.0.7</Version>
<Version>3.0.3</Version>
<LangVersion>9</LangVersion>
<PackageIcon>mroaLogo.png</PackageIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -31,6 +31,6 @@
<ItemGroup>
<PackageReference Include="System.Formats.Cbor" Version="9.0.7" />
<PackageReference Include="System.Formats.Cbor" Version="9.0.8" />
</ItemGroup>
</Project>