Cbor bug fixes

This commit is contained in:
2025-05-14 12:58:14 +03:00
parent bc74a97b14
commit d48ac20f7d
6 changed files with 35 additions and 0 deletions
+6
View File
@@ -15,6 +15,12 @@ namespace Example.Backend
Console.WriteLine(humanName + " is approaching"); Console.WriteLine(humanName + " is approaching");
} }
public Task SetFingerPrint(int[] fingerPrint)
{
Console.WriteLine(fingerPrint.Length);
return Task.CompletedTask;
}
public void OnPrintExternal(IPage p0, RequestContext ro) public void OnPrintExternal(IPage p0, RequestContext ro)
{ {
OnPrint?.Invoke(p0, ro); OnPrint?.Invoke(p0, ro);
+5
View File
@@ -13,6 +13,11 @@ namespace Example.Frontend
return Task.CompletedTask; return Task.CompletedTask;
} }
public Task SetFingerPrint(int[] fingerPrint)
{
return Task.CompletedTask;
}
public void OnPrintExternal(IPage p0, RequestContext ro) public void OnPrintExternal(IPage p0, RequestContext ro)
{ {
} }
+5
View File
@@ -51,6 +51,11 @@ class Program
using (var disposingPrinter = factory.Create("Test")) using (var disposingPrinter = factory.Create("Test"))
{ {
disposingPrinter.SetFingerPrint(new[] { 1, 2, 3 }).ContinueWith(r =>
{
Console.WriteLine(r.Status);
});
DemoCheck.CreatingPrinter = true; DemoCheck.CreatingPrinter = true;
disposingPrinter.OnPrint += (_, _) => disposingPrinter.OnPrint += (_, _) =>
{ {
+1
View File
@@ -15,5 +15,6 @@ namespace Example.Shared
event Action<IPage, RequestContext> OnPrint; event Action<IPage, RequestContext> OnPrint;
[Untrusted] [Untrusted]
Task SomeoneIsApproaching(string humanName); Task SomeoneIsApproaching(string humanName);
Task SetFingerPrint(int[] fingerPrint);
} }
} }
+15
View File
@@ -1,5 +1,7 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using mROA.Abstract; using mROA.Abstract;
using mROA.Implementation; using mROA.Implementation;
@@ -34,6 +36,19 @@ namespace mROA.Cbor
return so.UniversalValue; return so.UniversalValue;
} }
if (type is { IsArray: true })
{
var elementType = type.GetElementType();
var array = Array.CreateInstance(elementType, _properties.Count);
Array.Copy(_properties.Select(i => Convert.ChangeType(i,elementType)).ToArray(), array, _properties.Count);
return array;
}
if (typeof(IList).IsAssignableFrom(type))
return Convert.ChangeType(_properties.Select(i => Convert.ChangeType(i, type.GetElementType())).ToList(), type);
var instance = Activator.CreateInstance(type); var instance = Activator.CreateInstance(type);
if (instance == null) if (instance == null)
return null; return null;
+3
View File
@@ -3,6 +3,9 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.0.1</Version>
<LangVersion>9</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">