mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
Created dual solution (.NET Standard 2.0 + .NET Core 2.1)
This commit is contained in:
parent
82b569ede6
commit
97eb340261
98
Capnp.Net.Runtime.Core21/Capnp.Net.Runtime.Core21.csproj
Normal file
98
Capnp.Net.Runtime.Core21/Capnp.Net.Runtime.Core21.csproj
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\AnyPointer.cs" Link="AnyPointer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\CapnpSerializable.cs" Link="CapnpSerializable.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\DeserializationException.cs" Link="DeserializationException.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\DeserializerState.cs" Link="DeserializerState.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\DynamicSerializerState.cs" Link="DynamicSerializerState.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\EmptyList.cs" Link="EmptyList.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\EmptyListDeserializer.cs" Link="EmptyListDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\FramePump.cs" Link="FramePump.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Framing.cs" Link="Framing.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ICapnpSerializable.cs" Link="ICapnpSerializable.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ISegmentAllocator.cs" Link="ISegmentAllocator.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\IStructDeserializer.cs" Link="IStructDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\IStructSerializer.cs" Link="IStructSerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListDeserializer.cs" Link="ListDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListKind.cs" Link="ListKind.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfBitsDeserializer.cs" Link="ListOfBitsDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfBitsSerializer.cs" Link="ListOfBitsSerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfCapsDeserializer.cs" Link="ListOfCapsDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfCapsSerializer.cs" Link="ListOfCapsSerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfEmptyDeserializer.cs" Link="ListOfEmptyDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfEmptySerializer.cs" Link="ListOfEmptySerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfPointersDeserializer.cs" Link="ListOfPointersDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfPointersSerializer.cs" Link="ListOfPointersSerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfPrimitivesDeserializer.cs" Link="ListOfPrimitivesDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfPrimitivesSerializer.cs" Link="ListOfPrimitivesSerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfStructsDeserializer.cs" Link="ListOfStructsDeserializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfStructsSerializer.cs" Link="ListOfStructsSerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ListOfTextSerializer.cs" Link="ListOfTextSerializer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Logging.cs" Link="Logging.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\MessageBuilder.cs" Link="MessageBuilder.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ObjectKind.cs" Link="ObjectKind.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\PrimitiveCoder.cs" Link="PrimitiveCoder.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\ReadOnlyListExtensions.cs" Link="ReadOnlyListExtensions.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Reserializing.cs" Link="Reserializing.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\AnswerOrCounterquestion.cs" Link="Rpc\AnswerOrCounterquestion.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\BareProxy.cs" Link="Rpc\BareProxy.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\CapabilityReflection.cs" Link="Rpc\CapabilityReflection.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\ConsumedCapability.cs" Link="Rpc\ConsumedCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\IEndpoint.cs" Link="Rpc\IEndpoint.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\IMonoSkeleton.cs" Link="Rpc\IMonoSkeleton.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\Impatient.cs" Link="Rpc\Impatient.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\ImportedCapability.cs" Link="Rpc\ImportedCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\InvalidCapabilityInterfaceException.cs" Link="Rpc\InvalidCapabilityInterfaceException.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\IPromisedAnswer.cs" Link="Rpc\IPromisedAnswer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\IProvidedCapability.cs" Link="Rpc\IProvidedCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\IResolvingCapability.cs" Link="Rpc\IResolvingCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\IRpcEndpoint.cs" Link="Rpc\IRpcEndpoint.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\LazyCapability.cs" Link="Rpc\LazyCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\LocalAnswer.cs" Link="Rpc\LocalAnswer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\LocalAnswerCapability.cs" Link="Rpc\LocalAnswerCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\LocalCapability.cs" Link="Rpc\LocalCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\MemberAccessPath.cs" Link="Rpc\MemberAccessPath.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\PendingAnswer.cs" Link="Rpc\PendingAnswer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\PendingQuestion.cs" Link="Rpc\PendingQuestion.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\PolySkeleton.cs" Link="Rpc\PolySkeleton.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\PromisedCapability.cs" Link="Rpc\PromisedCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\Proxy.cs" Link="Rpc\Proxy.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\ProxyAttribute.cs" Link="Rpc\ProxyAttribute.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\RefCountingCapability.cs" Link="Rpc\RefCountingCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\RemoteAnswerCapability.cs" Link="Rpc\RemoteAnswerCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\RemoteCapability.cs" Link="Rpc\RemoteCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\RemoteResolvingCapability.cs" Link="Rpc\RemoteResolvingCapability.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\ResolvingCapabilityExtensions.cs" Link="Rpc\ResolvingCapabilityExtensions.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\rpc.cs" Link="Rpc\rpc.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\RpcEngine.cs" Link="Rpc\RpcEngine.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\RpcException.cs" Link="Rpc\RpcException.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\RpcUnimplementedException.cs" Link="Rpc\RpcUnimplementedException.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\Skeleton.cs" Link="Rpc\Skeleton.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\SkeletonAttribute.cs" Link="Rpc\SkeletonAttribute.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\TcpRpcClient.cs" Link="Rpc\TcpRpcClient.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\TcpRpcServer.cs" Link="Rpc\TcpRpcServer.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\Rpc\Vine.cs" Link="Rpc\Vine.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\SecurityOptions.cs" Link="SecurityOptions.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\SegmentAllocator.cs" Link="SegmentAllocator.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\SegmentSlice.cs" Link="SegmentSlice.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\SerializerExtensions.cs" Link="SerializerExtensions.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\SerializerState.cs" Link="SerializerState.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\UtilityExtensions.cs" Link="UtilityExtensions.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\WireFrame.cs" Link="WireFrame.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime\WirePointer.cs" Link="WirePointer.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Rpc\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,44 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\CallContext.cs" Link="CallContext.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\DeserializationTests.cs" Link="DeserializationTests.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\DynamicSerializerStateTests.cs" Link="DynamicSerializerStateTests.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\FramePumpTests.cs" Link="FramePumpTests.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\General.cs" Link="General.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\JobUtil.cs" Link="JobUtil.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\MessageBuilderTests.cs" Link="MessageBuilderTests.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\ProvidedCapabilityMock.cs" Link="ProvidedCapabilityMock.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\ProvidedCapabilityMultiCallMock.cs" Link="ProvidedCapabilityMultiCallMock.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\RpcSchemaTests.cs" Link="RpcSchemaTests.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\SegmentAllocatorTests.cs" Link="SegmentAllocatorTests.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TcpRpc.cs" Link="TcpRpc.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TcpRpcAdvancedStuff.cs" Link="TcpRpcAdvancedStuff.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TcpRpcInterop.cs" Link="TcpRpcInterop.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TcpRpcPorted.cs" Link="TcpRpcPorted.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TcpRpcStress.cs" Link="TcpRpcStress.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\test.cs" Link="test.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TestBase.cs" Link="TestBase.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TestCapImplementations.cs" Link="TestCapImplementations.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\TestInterfaces.cs" Link="TestInterfaces.cs" />
|
||||||
|
<Compile Include="..\Capnp.Net.Runtime.Tests\WirePointerTests.cs" Link="WirePointerTests.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Capnp.Net.Runtime.Core21\Capnp.Net.Runtime.Core21.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -22,7 +22,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Capnp.Net.Runtime\Capnp.Net.Runtime.csproj" />
|
<ProjectReference Include="..\Capnp.Net.Runtime\Capnp.Net.Runtime.Std20.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -7,7 +7,6 @@ using Capnp.Rpc;
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Exception = Capnp.Rpc.Exception;
|
|
||||||
|
|
||||||
namespace Capnp.Net.Runtime.Tests
|
namespace Capnp.Net.Runtime.Tests
|
||||||
{
|
{
|
||||||
@ -68,7 +67,7 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
SpinWait.SpinUntil(() => server.ConnectionCount > 0, MediumTimeout);
|
SpinWait.SpinUntil(() => server.ConnectionCount > 0, MediumTimeout);
|
||||||
Assert.AreEqual(1, server.ConnectionCount);
|
Assert.AreEqual(1, server.ConnectionCount);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
throw;
|
throw;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<RootNamespace>Capnp</RootNamespace>
|
<RootNamespace>Capnp</RootNamespace>
|
||||||
<LangVersion>7.2</LangVersion>
|
<LangVersion>7.2</LangVersion>
|
||||||
|
<AssemblyName>Capnp.Net.Runtime.Std20</AssemblyName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
@ -81,8 +81,6 @@ namespace Capnp
|
|||||||
if (segment.Length == 0)
|
if (segment.Length == 0)
|
||||||
throw new ArgumentException("Segment must not have zero length");
|
throw new ArgumentException("Segment must not have zero length");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lock (_writeLock)
|
lock (_writeLock)
|
||||||
{
|
{
|
||||||
@ -101,7 +99,11 @@ namespace Capnp
|
|||||||
|
|
||||||
foreach (var segment in frame.Segments)
|
foreach (var segment in frame.Segments)
|
||||||
{
|
{
|
||||||
|
#if NETSTANDARD2_0
|
||||||
var bytes = MemoryMarshal.Cast<ulong, byte>(segment.Span).ToArray();
|
var bytes = MemoryMarshal.Cast<ulong, byte>(segment.Span).ToArray();
|
||||||
|
#else
|
||||||
|
var bytes = MemoryMarshal.Cast<ulong, byte>(segment.Span);
|
||||||
|
#endif
|
||||||
_writer.Write(bytes);
|
_writer.Write(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,20 @@ namespace Capnp
|
|||||||
public static WireFrame ReadWireFrame(this BinaryReader reader)
|
public static WireFrame ReadWireFrame(this BinaryReader reader)
|
||||||
{
|
{
|
||||||
uint scount = reader.ReadUInt32();
|
uint scount = reader.ReadUInt32();
|
||||||
if(scount++ == UInt32.MaxValue) throw new InvalidDataException("Encountered Invalid Framing Data");
|
if (scount++ == uint.MaxValue)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Encountered invalid framing data");
|
||||||
|
}
|
||||||
|
|
||||||
var buffers = new Memory<ulong>[scount];
|
var buffers = new Memory<ulong>[scount];
|
||||||
|
|
||||||
for (uint i = 0; i < scount; i++)
|
for (uint i = 0; i < scount; i++)
|
||||||
{
|
{
|
||||||
uint size = reader.ReadUInt32();
|
uint size = reader.ReadUInt32();
|
||||||
if(size==0) throw new EndOfStreamException("Stream Closed");
|
if (size == 0)
|
||||||
|
{
|
||||||
|
throw new EndOfStreamException("Stream closed");
|
||||||
|
}
|
||||||
buffers[i] = new Memory<ulong>(new ulong[size]);
|
buffers[i] = new Memory<ulong>(new ulong[size]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,10 +62,11 @@ namespace Capnp
|
|||||||
return new WireFrame(buffers);
|
return new WireFrame(buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FillBuffersFromFrames(Memory<ulong>[] buffers, uint segmentCount, BinaryReader reader)
|
static void FillBuffersFromFrames(Memory<ulong>[] buffers, uint segmentCount, BinaryReader reader)
|
||||||
{
|
{
|
||||||
for (uint i = 0; i < segmentCount; i++)
|
for (uint i = 0; i < segmentCount; i++)
|
||||||
{
|
{
|
||||||
|
#if NETSTANDARD2_0
|
||||||
var buffer = MemoryMarshal.Cast<ulong, byte>(buffers[i].Span.ToArray());
|
var buffer = MemoryMarshal.Cast<ulong, byte>(buffers[i].Span.ToArray());
|
||||||
var tmpBuffer = reader.ReadBytes(buffer.Length);
|
var tmpBuffer = reader.ReadBytes(buffer.Length);
|
||||||
|
|
||||||
@ -73,6 +81,10 @@ namespace Capnp
|
|||||||
var value = BitConverter.ToUInt64(tmpBuffer, j*8);
|
var value = BitConverter.ToUInt64(tmpBuffer, j*8);
|
||||||
buffers[i].Span[j] = value;
|
buffers[i].Span[j] = value;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
var buffer = MemoryMarshal.Cast<ulong, byte>(buffers[i].Span);
|
||||||
|
reader.Read(buffer);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ namespace Capnp
|
|||||||
Coder<ulong>.Fn = (x, y) => x ^ y;
|
Coder<ulong>.Fn = (x, y) => x ^ y;
|
||||||
Coder<float>.Fn = (x, y) =>
|
Coder<float>.Fn = (x, y) =>
|
||||||
{
|
{
|
||||||
int xi = x.SingleToInt32();
|
int xi = x.ReplacementSingleToInt32Bits();
|
||||||
int yi = y.SingleToInt32();
|
int yi = y.ReplacementSingleToInt32Bits();
|
||||||
int zi = xi ^ yi;
|
int zi = xi ^ yi;
|
||||||
return BitConverter.ToSingle(BitConverter.GetBytes(zi), 0);
|
return BitConverter.ToSingle(BitConverter.GetBytes(zi), 0);
|
||||||
};
|
};
|
||||||
|
@ -179,9 +179,7 @@ namespace Capnp.Rpc
|
|||||||
|
|
||||||
uint RandId()
|
uint RandId()
|
||||||
{
|
{
|
||||||
var holder = new byte[4];
|
return unchecked((uint)_random.Next(int.MinValue, int.MaxValue));
|
||||||
_random.NextBytes(holder);
|
|
||||||
return BitConverter.ToUInt32(holder,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint AllocateExport(Skeleton providedCapability, out bool first)
|
uint AllocateExport(Skeleton providedCapability, out bool first)
|
||||||
|
@ -63,12 +63,8 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
throw new RpcException("TcpRpcClient is unable to connect", exception);
|
throw new RpcException("TcpRpcClient is unable to connect", exception);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logger.LogError("UNHANDLED EXCEPTION");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task Connect(string host, int port)
|
async Task Connect(string host, int port)
|
||||||
{
|
{
|
||||||
await ConnectAsync(host, port);
|
await ConnectAsync(host, port);
|
||||||
|
@ -2528,7 +2528,7 @@ namespace Capnp.Rpc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Exception : System.Exception, ICapnpSerializable
|
public class Exception : ICapnpSerializable
|
||||||
{
|
{
|
||||||
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
void ICapnpSerializable.Deserialize(DeserializerState arg_)
|
||||||
{
|
{
|
||||||
|
@ -285,9 +285,9 @@ namespace Capnp
|
|||||||
public static float ReadDataFloat<T>(this T d, ulong bitOffset, float defaultValue = 0)
|
public static float ReadDataFloat<T>(this T d, ulong bitOffset, float defaultValue = 0)
|
||||||
where T : IStructDeserializer
|
where T : IStructDeserializer
|
||||||
{
|
{
|
||||||
int defaultBits = defaultValue.SingleToInt32();
|
int defaultBits = defaultValue.ReplacementSingleToInt32Bits();
|
||||||
int bits = (int)d.StructReadData(bitOffset, 32) ^ defaultBits;
|
int bits = (int)d.StructReadData(bitOffset, 32) ^ defaultBits;
|
||||||
return bits.Int32ToSingle();
|
return bits.ReplacementInt32ToSingleBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -301,8 +301,8 @@ namespace Capnp
|
|||||||
public static void WriteData<T>(this T d, ulong bitOffset, float value, float defaultValue = 0.0f)
|
public static void WriteData<T>(this T d, ulong bitOffset, float value, float defaultValue = 0.0f)
|
||||||
where T : IStructSerializer
|
where T : IStructSerializer
|
||||||
{
|
{
|
||||||
int bits = value.SingleToInt32();
|
int bits = value.ReplacementSingleToInt32Bits();
|
||||||
int defaultBits = defaultValue.SingleToInt32();
|
int defaultBits = defaultValue.ReplacementSingleToInt32Bits();
|
||||||
WriteData(d, bitOffset, bits, defaultBits);
|
WriteData(d, bitOffset, bits, defaultBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,7 +1068,11 @@ namespace Capnp
|
|||||||
{
|
{
|
||||||
var bytes = ListGetBytes();
|
var bytes = ListGetBytes();
|
||||||
if (bytes.Length == 0) return string.Empty;
|
if (bytes.Length == 0) return string.Empty;
|
||||||
|
#if NETSTANDARD2_0
|
||||||
return Encoding.UTF8.GetString(bytes.Slice(0, bytes.Length - 1).ToArray());
|
return Encoding.UTF8.GetString(bytes.Slice(0, bytes.Length - 1).ToArray());
|
||||||
|
#else
|
||||||
|
return Encoding.UTF8.GetString(bytes.Slice(0, bytes.Length - 1));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1164,8 +1168,8 @@ namespace Capnp
|
|||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is out of bounds.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is out of bounds.</exception>
|
||||||
public void ListWriteValue(int index, float value, float defaultValue = 0)
|
public void ListWriteValue(int index, float value, float defaultValue = 0)
|
||||||
{
|
{
|
||||||
int rcastValue = value.SingleToInt32();
|
int rcastValue = value.ReplacementSingleToInt32Bits();
|
||||||
int rcastDefaultValue = defaultValue.SingleToInt32();
|
int rcastDefaultValue = defaultValue.ReplacementSingleToInt32Bits();
|
||||||
ListWriteValue(index, rcastValue, rcastDefaultValue);
|
ListWriteValue(index, rcastValue, rcastDefaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,63 +5,77 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Capnp
|
namespace Capnp
|
||||||
{
|
{
|
||||||
public static class UtilityExtensions
|
internal static class UtilityExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method exists until NET Standard 2.1 is released
|
/// This method exists until NET Standard 2.1 is released
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="thisDict"></param>
|
/// <param name="thisDict"></param>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <typeparam name="K"></typeparam>
|
/// <typeparam name="K"></typeparam>
|
||||||
/// <typeparam name="V"></typeparam>
|
/// <typeparam name="V"></typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool ReplacementTryAdd<K, V>(this Dictionary<K, V> thisDict, K key, V value)
|
#if NETSTANDARD2_0
|
||||||
{
|
public static bool ReplacementTryAdd<K, V>(this Dictionary<K, V> thisDict, K key, V value)
|
||||||
if (thisDict.ContainsKey(key))
|
{
|
||||||
return false;
|
if (thisDict.ContainsKey(key)) return false;
|
||||||
thisDict.Add(key, value);
|
thisDict.Add(key, value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
/// <summary>
|
public static bool ReplacementTryAdd<K, V>(this Dictionary<K, V> thisDict, K key, V value) => thisDict.TryAdd(key, value);
|
||||||
/// This method exists until NET Standard 2.1 is released
|
#endif
|
||||||
/// </summary>
|
|
||||||
/// <param name="thisDict"></param>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
/// <typeparam name="K"></typeparam>
|
|
||||||
/// <typeparam name="V"></typeparam>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool ReplacementTryRemove<K, V>(this Dictionary<K, V> thisDict, K key, out V value)
|
|
||||||
{
|
|
||||||
if (!thisDict.ContainsKey(key))
|
|
||||||
{
|
|
||||||
value = default;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
value = thisDict[key];
|
|
||||||
return thisDict.Remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method exists until NET Standard 2.1 is released
|
/// This method exists until NET Standard 2.1 is released
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="task"></param>
|
/// <param name="thisDict"></param>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <param name="key"></param>
|
||||||
/// <returns></returns>
|
/// <param name="value"></param>
|
||||||
public static bool ReplacementTaskIsCompletedSuccessfully(this Task task)
|
/// <typeparam name="K"></typeparam>
|
||||||
{
|
/// <typeparam name="V"></typeparam>
|
||||||
return task.IsCompleted && !task.IsCanceled && !task.IsFaulted;
|
/// <returns></returns>
|
||||||
}
|
#if NETSTANDARD2_0
|
||||||
|
public static bool ReplacementTryRemove<K, V>(this Dictionary<K, V> thisDict, K key, out V value)
|
||||||
|
{
|
||||||
|
if (!thisDict.ContainsKey(key))
|
||||||
|
{
|
||||||
|
value = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
value = thisDict[key];
|
||||||
|
return thisDict.Remove(key);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public static bool ReplacementTryRemove<K, V>(this Dictionary<K, V> thisDict, K key, out V value) => thisDict.Remove(key, out value);
|
||||||
|
#endif
|
||||||
|
|
||||||
public static int SingleToInt32(this float value)
|
/// <summary>
|
||||||
{
|
/// This method exists until NET Standard 2.1 is released
|
||||||
var valueBytes = BitConverter.GetBytes(value);
|
/// </summary>
|
||||||
return BitConverter.ToInt32(valueBytes,0);
|
/// <param name="task"></param>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
#if NETSTANDARD2_0
|
||||||
|
public static bool ReplacementTaskIsCompletedSuccessfully(this Task task)
|
||||||
|
{
|
||||||
|
return task.IsCompleted && !task.IsCanceled && !task.IsFaulted;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public static bool ReplacementTaskIsCompletedSuccessfully(this Task task) => task.IsCompletedSuccessfully;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NETSTANDARD2_0
|
||||||
|
public static int ReplacementSingleToInt32Bits(this float value) => BitConverter.ToInt32(BitConverter.GetBytes(value), 0);
|
||||||
|
#else
|
||||||
|
public static int ReplacementSingleToInt32Bits(this float value) => BitConverter.SingleToInt32Bits(value);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NETSTANDARD2_0
|
||||||
|
public static float ReplacementInt32ToSingleBits(this int value) => BitConverter.ToSingle(BitConverter.GetBytes(value), 0);
|
||||||
|
#else
|
||||||
|
public static float ReplacementInt32ToSingleBits(this int value) => BitConverter.Int32BitsToSingle(value);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float Int32ToSingle(this int value) =>
|
|
||||||
BitConverter.ToSingle(BitConverter.GetBytes(value),0);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,11 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.29001.49
|
VisualStudioVersion = 16.0.29001.49
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime", "Capnp.Net.Runtime\Capnp.Net.Runtime.csproj", "{D4326221-63C9-4AC5-805A-B4D8CA47546A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime.Std20", "Capnp.Net.Runtime\Capnp.Net.Runtime.Std20.csproj", "{D4326221-63C9-4AC5-805A-B4D8CA47546A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "capnpc-csharp", "capnpc-csharp\capnpc-csharp.csproj", "{D19E5EA7-D35B-4A1F-99CB-ED136316B577}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "capnpc-csharp", "capnpc-csharp\capnpc-csharp.csproj", "{D19E5EA7-D35B-4A1F-99CB-ED136316B577}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime.Tests", "Capnp.Net.Runtime.Tests\Capnp.Net.Runtime.Tests.csproj", "{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime.Tests.Std20", "Capnp.Net.Runtime.Tests\Capnp.Net.Runtime.Tests.Std20.csproj", "{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Capnp.Net.Runtime.Core21", "Capnp.Net.Runtime.Core21\Capnp.Net.Runtime.Core21.csproj", "{B9EE68D1-0474-4697-A121-D21D1B76DB47}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Capnp.Net.Runtime.Tests.Core21", "Capnp.Net.Runtime.Tests.Core21\Capnp.Net.Runtime.Tests.Core21.csproj", "{58E8FFC8-D207-4B0F-842A-58ED9D3D9EEF}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -23,14 +27,18 @@ Global
|
|||||||
{D19E5EA7-D35B-4A1F-99CB-ED136316B577}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D19E5EA7-D35B-4A1F-99CB-ED136316B577}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D19E5EA7-D35B-4A1F-99CB-ED136316B577}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D19E5EA7-D35B-4A1F-99CB-ED136316B577}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D19E5EA7-D35B-4A1F-99CB-ED136316B577}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D19E5EA7-D35B-4A1F-99CB-ED136316B577}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{8C17F147-D784-4584-80FF-21BE03AC0D17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{8C17F147-D784-4584-80FF-21BE03AC0D17}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{8C17F147-D784-4584-80FF-21BE03AC0D17}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{8C17F147-D784-4584-80FF-21BE03AC0D17}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9ED38750-F83F-4B10-B3A3-4FD6183F9E86}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B9EE68D1-0474-4697-A121-D21D1B76DB47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B9EE68D1-0474-4697-A121-D21D1B76DB47}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B9EE68D1-0474-4697-A121-D21D1B76DB47}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B9EE68D1-0474-4697-A121-D21D1B76DB47}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{58E8FFC8-D207-4B0F-842A-58ED9D3D9EEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{58E8FFC8-D207-4B0F-842A-58ED9D3D9EEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{58E8FFC8-D207-4B0F-842A-58ED9D3D9EEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{58E8FFC8-D207-4B0F-842A-58ED9D3D9EEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Capnp.Net.Runtime\Capnp.Net.Runtime.csproj" />
|
<ProjectReference Include="..\Capnp.Net.Runtime\Capnp.Net.Runtime.Std20.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user