Works with NetJsonPipeSerializer

This commit is contained in:
Matthias Heil
2026-04-07 13:38:08 +02:00
parent 7b4bbd28a1
commit 6f7a3a5e31
5 changed files with 14 additions and 50 deletions
+5 -3
View File
@@ -1,15 +1,17 @@
using System;
using PipeMethodCalls;
using PipeMethodCalls.NetJson;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using PipeMethodCalls;
namespace NamedPipes;
public class NamedPipeClient (string pipeName,string? serverLocation = null, string? serverName = null,Action<string>? logger = null): IDebugVisualizer, IDisposable
{
private bool IsConnected => PipeClient.State == PipeState.Connected;
private PipeClient<IDebugVisualizer> PipeClient { get; } = new(new PipeSerializer(), pipeName);
private PipeClient<IDebugVisualizer> PipeClient { get; } = new(new NetJsonPipeSerializer(), pipeName);
private string ServerLocation { get; } = serverLocation ?? Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Visual Studio 2026\Visualizers\Server\NrxVisualizer\";
private string ServerName { get; } = serverName ?? "Num.Roto.Nrx.VisualizerServer";
private Action<string> Logger { get;} = logger ??((m) => Trace.WriteLine(m));
+6 -4
View File
@@ -1,8 +1,10 @@
using System;
using CommunityToolkit.Mvvm.ComponentModel;
using PipeMethodCalls;
using PipeMethodCalls.NetJson;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using PipeMethodCalls;
namespace NamedPipes;
public partial class NamedPipesServer(string pipeName,Action<string>? logger = null) : ObservableObject,IDebugVisualizer, IDisposable
@@ -23,7 +25,7 @@ public partial class NamedPipesServer(string pipeName,Action<string>? logger = n
if (PipeServer == null || PipeServer.State != PipeState.Connected)
{
PipeServer?.Dispose();
PipeServer = new PipeServer<IDebugVisualizer>(new PipeSerializer(), PipeName, () => this);
PipeServer = new PipeServer<IDebugVisualizer>(new NetJsonPipeSerializer(), PipeName, () => this);
PipeServer.SetLogger((m) => Trace.WriteLine(m));
}
Logger("Waiting for client connection...");
+1 -2
View File
@@ -7,10 +7,9 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="3.1.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="PipeMethodCalls" Version="4.0.3" />
<PackageReference Include="PipeMethodCalls.NetJson" Version="3.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.6.1" />
</ItemGroup>
</Project>
-38
View File
@@ -1,38 +0,0 @@
using System;
using MessagePack;
using PipeMethodCalls;
namespace NamedPipes
{
public class PipeSerializer : IPipeSerializer
{
public object? Deserialize(byte[] data, Type type)
{
if (data.Length == 0) return null;
//Log.Trace("PipeSerializer.Deserialize: type = " + type + " , data.length = " + data.Length);
var obj = MessagePackSerializer.Typeless.Deserialize(data);
//if (obj is DebugObject debugObject)
//{
// var length = debugObject.Data?.Length ?? 0;
// var debugObjectType = debugObject.Type ?? "null";
// Log.Trace("PipeSerializer.Deserialize: debugObject.Type = " + debugObjectType + " , debugObject.Data.Length = " + length);
//}
return obj;
}
public byte[] Serialize(object o)
{
if (o.GetType().FullName == "System.Threading.Tasks.VoidTaskResult") return [];
//if (o is DebugObject debugObject)
//{
// var length = debugObject.Data?.Length ?? 0;
// Log.Trace("PipeSerializer.Deserialize: debugObject.Type = " + debugObject.Type + " , debugObject.Data.Length = " + length);
//}
var bytearray = MessagePackSerializer.Typeless.Serialize(o);
//var xxx = Deserialize(bytearray, o.GetType());
//Log.Trace("PipeSerializer.Serialize: type = " + o.GetType() + " , bytearray.length = " + bytearray.Length);
return bytearray;
}
}
}
@@ -17,8 +17,7 @@
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\net8.0-windows8.0\NrxVisualizerObjectSource.dll" Link="netstandard2.0\NrxVisualizerObjectSource.dll" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\net8.0-windows8.0\NamedPipes.dll" Link="netstandard2.0\NamedPipes.dll" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\net8.0-windows8.0\PipeMethodCalls.dll" Link="netstandard2.0\PipeMethodCalls.dll" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\net8.0-windows8.0\MessagePack.dll" Link="netstandard2.0\MessagePack.dll" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\net8.0-windows8.0\MessagePack.Annotations.dll" Link="netstandard2.0\MessagePack.Annotations.dll" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\net8.0-windows8.0\PipeMethodCalls.NetJson.dll" Link="netstandard2.0\PipeMethodCalls.NetJson.dll" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\net8.0-windows8.0\CommunityToolkit.Mvvm.dll" Link="netstandard2.0\CommunityToolkit.Mvvm.dll" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>