Test projects are working.
This commit is contained in:
15
.idea/.idea.VisualizerExtensionExample/.idea/.gitignore
generated
vendored
Normal file
15
.idea/.idea.VisualizerExtensionExample/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/projectSettingsUpdater.xml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/.idea.VisualizerExtensionExample.iml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
4
.idea/.idea.VisualizerExtensionExample/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.VisualizerExtensionExample/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
.idea/.idea.VisualizerExtensionExample/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.VisualizerExtensionExample/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/.idea.VisualizerExtensionExample/.idea/vcs.xml
generated
Normal file
7
.idea/.idea.VisualizerExtensionExample/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
17
Directory.Build.props
Normal file
17
Directory.Build.props
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<AnalysisLevel>latest-recommended</AnalysisLevel>
|
||||
<BinDir>$(MSBuildThisFileDirectory)bin</BinDir>
|
||||
<RestorePackagesPath>$(MSBuildThisFileDirectory)packages</RestorePackagesPath>
|
||||
<OutputDirectory>$(MSBuildProjectName)</OutputDirectory>
|
||||
<OutputDirectory Condition=" '$(AssemblyName)' != '' ">$(AssemblyName)</OutputDirectory>
|
||||
<OutputPath>$(BinDir)\$(Configuration)\</OutputPath>
|
||||
<BaseIntermediateOutputPath>$(BinDir)\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
|
||||
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
22
NamedPipes/IVisualizerKontract.cs
Normal file
22
NamedPipes/IVisualizerKontract.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Threading.Tasks;
|
||||
namespace NamedPipes;
|
||||
|
||||
[Serializable]
|
||||
public struct Frame(Vector3 translation, Quaternion orientation)
|
||||
{
|
||||
public Vector3 Translation => translation;
|
||||
public Quaternion Orientation => orientation;
|
||||
}
|
||||
[Serializable]
|
||||
public class DebugObject
|
||||
{
|
||||
public string? Type { get; set; }
|
||||
public byte[]? Data { get; set; }
|
||||
}
|
||||
public interface IDebugVisualizer
|
||||
{
|
||||
Task<bool> SetDebugObjectAsync(DebugObject debugObject);
|
||||
Task<bool> SetMessageAsync(string message);
|
||||
}
|
||||
54
NamedPipes/NamedPipeClient.cs
Normal file
54
NamedPipes/NamedPipeClient.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
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 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));
|
||||
|
||||
private async Task StartServerAsync()
|
||||
{
|
||||
if (IsConnected) return;
|
||||
PipeClient.SetLogger((m) => Trace.WriteLine(m));
|
||||
var serverAvailable = Process.GetProcessesByName(ServerName).Length > 0;
|
||||
if (!serverAvailable)
|
||||
{
|
||||
var serverPath = ServerLocation + ServerName + ".exe";
|
||||
if (!File.Exists(serverPath)) throw new FileNotFoundException(serverPath);
|
||||
var server = new Process { StartInfo = { FileName = serverPath } };
|
||||
server.Start();
|
||||
}
|
||||
await PipeClient.ConnectAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> SetDebugObjectAsync(DebugObject debugObject)
|
||||
{
|
||||
await StartServerAsync();
|
||||
var result = PipeClient.InvokeAsync(server => server.SetDebugObjectAsync(debugObject)).Result;
|
||||
Logger("NamedPipeClient.SetDebugObject: result = " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> SetMessageAsync(string message)
|
||||
{
|
||||
await StartServerAsync();
|
||||
var result = PipeClient.InvokeAsync(server => server.SetMessageAsync(message)).Result;
|
||||
Logger("NamedPipeClient.SetMessage: result = " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
PipeClient.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
52
NamedPipes/NamedPipeServer.cs
Normal file
52
NamedPipes/NamedPipeServer.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
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
|
||||
{
|
||||
public bool IsConnected => PipeServer is { State: PipeState.Connected };
|
||||
private PipeServer<IDebugVisualizer>? PipeServer {get; set;}
|
||||
private string PipeName { get; } = pipeName;
|
||||
private Action<string> Logger { get; } = logger ?? ((m) => Trace.WriteLine(m));
|
||||
|
||||
public async Task WaitForConnectionAsync()
|
||||
{
|
||||
if(IsConnected) return;
|
||||
if (PipeServer == null || PipeServer.State == PipeState.Closed)
|
||||
{
|
||||
PipeServer?.Dispose();
|
||||
PipeServer = new PipeServer<IDebugVisualizer>(new PipeSerializer(), PipeName, () => this);
|
||||
PipeServer.SetLogger((m) => Trace.WriteLine(m));
|
||||
}
|
||||
await PipeServer.WaitForConnectionAsync();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public partial DebugObject? DebugObject { get; private set; }
|
||||
|
||||
public async Task<bool> SetDebugObjectAsync(DebugObject debugObject)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
DebugObject = debugObject;
|
||||
Logger("Received DebugObject of type: " + DebugObject.Type);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> SetMessageAsync(string message)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
Logger("Received message: " + message);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
PipeServer?.Dispose();
|
||||
PipeServer = null;
|
||||
}
|
||||
}
|
||||
|
||||
16
NamedPipes/NamedPipes.csproj
Normal file
16
NamedPipes/NamedPipes.csproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<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="System.Numerics.Vectors" Version="4.6.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
38
NamedPipes/PipeSerializer.cs
Normal file
38
NamedPipes/PipeSerializer.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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.Deserialize(type, data, MessagePack.Resolvers.ContractlessStandardResolver.Options);
|
||||
//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.Serialize(o.GetType(), o, MessagePack.Resolvers.ContractlessStandardResolver.Options);
|
||||
//var xxx = Deserialize(bytearray, o.GetType());
|
||||
//Log.Trace("PipeSerializer.Serialize: type = " + o.GetType() + " , bytearray.length = " + bytearray.Length);
|
||||
return bytearray;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
TestClient/Program.cs
Normal file
12
TestClient/Program.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text;
|
||||
using NamedPipes;
|
||||
var count = 0;
|
||||
var message = "Hello World!".ToCharArray();
|
||||
while (true)
|
||||
{
|
||||
var pipeClient = new NamedPipeClient("testPipe",@".\","TestServer");
|
||||
Thread.Sleep(100);
|
||||
pipeClient.SetMessageAsync($"Hello from TestClient " + count++).GetAwaiter().GetResult();
|
||||
pipeClient.SetDebugObjectAsync(new DebugObject{Type = typeof(string).FullName,Data = Encoding.GetEncoding("UTF-8").GetBytes(message)}).GetAwaiter().GetResult();
|
||||
pipeClient.Dispose();
|
||||
}
|
||||
14
TestClient/TestClient.csproj
Normal file
14
TestClient/TestClient.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NamedPipes\NamedPipes.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
7
TestServer/Program.cs
Normal file
7
TestServer/Program.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
var pipeServer = new NamedPipes.NamedPipesServer("testPipe",Console.WriteLine);
|
||||
pipeServer.WaitForConnectionAsync().GetAwaiter().GetResult();
|
||||
while (pipeServer.IsConnected) Thread.Sleep(100);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -1,2 +0,0 @@
|
||||
var pipeServer = new NamedPipes.Receiver();
|
||||
pipeServer.Start();
|
||||
@@ -1,14 +0,0 @@
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<RepoRootPath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRootPath>
|
||||
<BaseIntermediateOutputPath>$(RepoRootPath)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
|
||||
<BaseOutputPath Condition=" '$(BaseOutputPath)' == '' ">$(RepoRootPath)bin\$(MSBuildProjectName)\</BaseOutputPath>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<IsPackable>false</IsPackable>
|
||||
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
|
||||
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
|
||||
<EnableNETAnalyzers>false</EnableNETAnalyzers>
|
||||
<AnalysisLevel>latest</AnalysisLevel>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -7,7 +7,7 @@ namespace Vector3Visualizer
|
||||
/// Extension entrypoint for the VisualStudio.Extensibility extension.
|
||||
/// </summary>
|
||||
[VisualStudioContribution]
|
||||
internal class ExtensionEntrypoint : Extension
|
||||
internal sealed class ExtensionEntrypoint : Extension
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override ExtensionConfiguration ExtensionConfiguration => new()
|
||||
@@ -1,7 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,23 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace NamedPipes
|
||||
{
|
||||
// Contains the method executed in the context of the impersonated user
|
||||
public class ReadFileToStream
|
||||
{
|
||||
private readonly string fn;
|
||||
private readonly StreamString ss;
|
||||
|
||||
public ReadFileToStream(StreamString str, string filename)
|
||||
{
|
||||
fn = filename;
|
||||
ss = str;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
string contents = File.ReadAllText(fn);
|
||||
ss.WriteString(contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace NamedPipes
|
||||
{
|
||||
|
||||
public class Receiver
|
||||
{
|
||||
public readonly static string PipeName = "testpipe";
|
||||
public Receiver()
|
||||
{
|
||||
}
|
||||
~Receiver()
|
||||
{
|
||||
}
|
||||
public void Start()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var pipeServer = new NamedPipeServerStream(PipeName, PipeDirection.InOut);
|
||||
int threadId = Thread.CurrentThread.ManagedThreadId;
|
||||
|
||||
// Wait for a client to connect
|
||||
pipeServer.WaitForConnection();
|
||||
Console.WriteLine($"Client connected on thread[{threadId}].");
|
||||
try
|
||||
{
|
||||
// Read the request from the client. Once the client has
|
||||
// written to the pipe its security token will be available.
|
||||
|
||||
StreamString stream = new StreamString(pipeServer);
|
||||
|
||||
// Verify our identity to the connected client using a
|
||||
// string that the client anticipates.
|
||||
|
||||
stream.WriteString("I am the one true server!");
|
||||
string message = stream.ReadString();
|
||||
Console.WriteLine($"Received: {message}");
|
||||
|
||||
|
||||
// Read in the contents of the file while impersonating the client.
|
||||
//ReadFileToStream fileReader = new ReadFileToStream(ss, filename);
|
||||
|
||||
// Display the name of the user we are impersonating.
|
||||
//Console.WriteLine($"Reading file: {filename} on thread[{threadId}] as user: {pipeServer.GetImpersonationUserName()}.");
|
||||
//pipeServer.RunAsClient(fileReader.Start);
|
||||
}
|
||||
// Catch the IOException that is raised if the pipe is broken
|
||||
// or disconnected.
|
||||
catch (IOException e)
|
||||
{
|
||||
Console.WriteLine($"ERROR: {e.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
pipeServer.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.IO.Pipes;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
namespace NamedPipes
|
||||
{
|
||||
public class Sender
|
||||
{
|
||||
public Sender() { }
|
||||
public void SendMessage(string message)
|
||||
{
|
||||
var pipeClient = new NamedPipeClientStream(".", Receiver.PipeName, PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation);
|
||||
Console.WriteLine("Connecting to server...\n");
|
||||
pipeClient.Connect(5000);
|
||||
Console.WriteLine("Connected.\n");
|
||||
|
||||
var ss = new StreamString(pipeClient);
|
||||
// Validate the server's signature string.
|
||||
if (ss.ReadString() == "I am the one true server!")
|
||||
{
|
||||
// The client security token is sent with the first write.
|
||||
// Send the name of the file whose contents are returned
|
||||
// by the server.
|
||||
ss.WriteString(message);
|
||||
|
||||
// Print the file to the screen.
|
||||
Console.Write(ss.ReadString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Server could not be verified.");
|
||||
}
|
||||
pipeClient.Dispose();
|
||||
// Give the client process some time to display results before exiting.
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace NamedPipes
|
||||
{
|
||||
// Defines the data protocol for reading and writing strings on our stream.
|
||||
public class StreamString
|
||||
{
|
||||
private readonly Stream ioStream;
|
||||
private readonly UnicodeEncoding streamEncoding;
|
||||
|
||||
public StreamString(Stream ioStream)
|
||||
{
|
||||
this.ioStream = ioStream;
|
||||
streamEncoding = new UnicodeEncoding();
|
||||
}
|
||||
|
||||
public string ReadString()
|
||||
{
|
||||
int len;
|
||||
len = ioStream.ReadByte() * 256;
|
||||
len += ioStream.ReadByte();
|
||||
var inBuffer = new byte[len];
|
||||
ioStream.Read(inBuffer, 0, len);
|
||||
|
||||
return streamEncoding.GetString(inBuffer);
|
||||
}
|
||||
|
||||
public int WriteString(string outString)
|
||||
{
|
||||
byte[] outBuffer = streamEncoding.GetBytes(outString);
|
||||
int len = outBuffer.Length;
|
||||
if (len > UInt16.MaxValue)
|
||||
{
|
||||
len = (int)UInt16.MaxValue;
|
||||
}
|
||||
ioStream.WriteByte((byte)(len / 256));
|
||||
ioStream.WriteByte((byte)(len & 255));
|
||||
ioStream.Write(outBuffer, 0, len);
|
||||
ioStream.Flush();
|
||||
|
||||
return outBuffer.Length + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using Vector3VisualizerSource;
|
||||
namespace Vector3Visualizer;
|
||||
|
||||
[VisualStudioContribution]
|
||||
internal class Vector3DebuggerVisualizerProvider : DebuggerVisualizerProvider
|
||||
internal sealed class Vector3DebuggerVisualizerProvider : DebuggerVisualizerProvider
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("ConstantExpressionEvaluator", "CEE0027:String not localized", Justification = "<Pending>")]
|
||||
public override DebuggerVisualizerProviderConfiguration DebuggerVisualizerProviderConfiguration => new(
|
||||
@@ -14,8 +14,8 @@
|
||||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.14.40608" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="$(RepoRootPath)bin\Vector3VisualizerSource\$(Configuration)\netstandard2.0\Vector3VisualizerSource.dll" Link="netstandard2.0\Vector3VisualizerSource.dll" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="$(RepoRootPath)bin\NamedPipes\$(Configuration)\netstandard2.0\NamedPipes.dll" Link="netstandard2.0\NamedPipes.dll" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\netstandard2.0\Vector3VisualizerSource.dll" Link="netstandard2.0\Vector3VisualizerSource.dll" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="$(MSBuildThisFileDirectory)..\bin\$(Configuration)\netstandard2.0\NamedPipes.dll" Link="netstandard2.0\NamedPipes.dll" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Vector3VisualizerUserControl.xaml" />
|
||||
@@ -1,42 +0,0 @@
|
||||
using Microsoft.VisualStudio.DebuggerVisualizers;
|
||||
using NamedPipes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Vector3VisualizerSource;
|
||||
|
||||
public class Vector3ObjectSource : VisualizerObjectSource
|
||||
{
|
||||
public static void Send(Vector3Model vector3Model)
|
||||
{
|
||||
var pipeClient = new Sender();
|
||||
|
||||
pipeClient.SendMessage($"Hello from {nameof(Vector3ObjectSource)}");
|
||||
}
|
||||
public Vector3ObjectSource():base()
|
||||
{
|
||||
Debug.WriteLine("new Vector3ObjectSource");
|
||||
}
|
||||
public override void GetData(object target, Stream outgoingData)
|
||||
{
|
||||
Vector3Model vector3Model = new();
|
||||
if (target is Vector3 vector3)
|
||||
{
|
||||
vector3Model.Vector3 = vector3.ToString();
|
||||
}
|
||||
if (target is IEnumerable<Vector3> vector3List)
|
||||
{
|
||||
vector3Model.Vector3 = vector3List.Last().ToString();
|
||||
}
|
||||
|
||||
if (target is Quaternion quaternion)
|
||||
{
|
||||
vector3Model.Quaternion = quaternion.ToString();
|
||||
}
|
||||
Send(vector3Model);
|
||||
SerializeAsJson(outgoingData, vector3Model);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
using System.Numerics;
|
||||
|
||||
var a = new Vector3(1,2,3);
|
||||
var typeName = a.GetType().AssemblyQualifiedName;
|
||||
|
||||
var b = new Vector3(5, 6, 7);
|
||||
Vector3[] v3Array = [a, b];
|
||||
List<Vector3> v3List = v3Array.ToList();
|
||||
|
||||
var quaternion = new Quaternion(1,2,3,4);
|
||||
return;
|
||||
@@ -1,10 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,3 +0,0 @@
|
||||
<Solution>
|
||||
<Project Path="Test.csproj" />
|
||||
</Solution>
|
||||
@@ -3,7 +3,7 @@ using Microsoft.VisualStudio.Extensibility.UI;
|
||||
|
||||
namespace Vector3Visualizer;
|
||||
|
||||
internal class Vector3VisualizerUserControl : RemoteUserControl
|
||||
internal sealed class Vector3VisualizerUserControl : RemoteUserControl
|
||||
{
|
||||
public Vector3VisualizerUserControl(Vector3Model? dataContext) : base(dataContext)
|
||||
{
|
||||
42
Vector3VisualizerSource/Vector3ObjectSource.cs
Normal file
42
Vector3VisualizerSource/Vector3ObjectSource.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.VisualStudio.DebuggerVisualizers;
|
||||
using NamedPipes;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Vector3VisualizerSource;
|
||||
|
||||
public class Vector3ObjectSource : VisualizerObjectSource
|
||||
{
|
||||
private static NamedPipeClient? PipeClient { get; set; }
|
||||
private static void Send(Vector3Model vector3Model)
|
||||
{
|
||||
PipeClient ??= new NamedPipeClient("testPipe");
|
||||
PipeClient.SetMessageAsync($"Hello from {nameof(Vector3ObjectSource)}").GetAwaiter().GetResult();
|
||||
}
|
||||
public Vector3ObjectSource()
|
||||
{
|
||||
Debug.WriteLine("new Vector3ObjectSource");
|
||||
}
|
||||
public override void GetData(object target, Stream outgoingData)
|
||||
{
|
||||
Vector3Model vector3Model = new();
|
||||
switch (target)
|
||||
{
|
||||
case Vector3 vector3:
|
||||
vector3Model.Vector3 = vector3.ToString();
|
||||
break;
|
||||
case IEnumerable<Vector3> vector3List:
|
||||
vector3Model.Vector3 = vector3List.Last().ToString();
|
||||
break;
|
||||
case Quaternion quaternion:
|
||||
vector3Model.Quaternion = quaternion.ToString();
|
||||
break;
|
||||
}
|
||||
|
||||
Send(vector3Model);
|
||||
SerializeAsJson(outgoingData, vector3Model);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<Solution>
|
||||
<Folder Name="/NamedPipes/">
|
||||
<Project Path="DebugVisualizer/DebugVisualizer.csproj" Id="c81154ef-d854-4f1e-9d14-2cf674885291" />
|
||||
<Project Path="NamedPipes/NamedPipes.csproj" Id="8d7b1151-8b57-4411-a361-47ed9c504a22" />
|
||||
<Project Path="TestClient/TestClient.csproj" />
|
||||
<Project Path="TestServer/TestServer.csproj" Id="c81154ef-d854-4f1e-9d14-2cf674885291" />
|
||||
</Folder>
|
||||
<Project Path="Vector3Visualizer/Vector3Visualizer.csproj" />
|
||||
<Project Path="Vector3VisualizerSource/Vector3VisualizerSource.csproj" />
|
||||
<Project Path="Vector3VisualizerTest/Test.csproj" />
|
||||
</Solution>
|
||||
Reference in New Issue
Block a user