Test projects are working.

This commit is contained in:
Matthias Heil
2026-04-01 12:46:48 +02:00
parent 83f8031862
commit cce0740f72
36 changed files with 472 additions and 431 deletions

View File

@@ -1,14 +0,0 @@
<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>

View File

@@ -1,2 +0,0 @@
var pipeServer = new NamedPipes.Receiver();
pipeServer.Start();

View File

@@ -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>

View File

@@ -1,31 +1,31 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.Extensibility;
namespace Vector3Visualizer
{
/// <summary>
/// Extension entrypoint for the VisualStudio.Extensibility extension.
/// </summary>
[VisualStudioContribution]
internal class ExtensionEntrypoint : Extension
{
/// <inheritdoc/>
public override ExtensionConfiguration ExtensionConfiguration => new()
{
Metadata = new(
id: "Vector3Visualizer.3c0400c3-acec-4b09-b561-c11fac7b10a7",
version: this.ExtensionAssemblyVersion,
publisherName: "Nrx Visualizer",
displayName: "Vector3Visualizer",
description: "Visualizer for MailAdress"),
};
/// <inheritdoc />
protected override void InitializeServices(IServiceCollection serviceCollection)
{
base.InitializeServices(serviceCollection);
// You can configure dependency injection here by adding services to the serviceCollection.
}
}
}
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.Extensibility;
namespace Vector3Visualizer
{
/// <summary>
/// Extension entrypoint for the VisualStudio.Extensibility extension.
/// </summary>
[VisualStudioContribution]
internal sealed class ExtensionEntrypoint : Extension
{
/// <inheritdoc/>
public override ExtensionConfiguration ExtensionConfiguration => new()
{
Metadata = new(
id: "Vector3Visualizer.3c0400c3-acec-4b09-b561-c11fac7b10a7",
version: this.ExtensionAssemblyVersion,
publisherName: "Nrx Visualizer",
displayName: "Vector3Visualizer",
description: "Visualizer for MailAdress"),
};
/// <inheritdoc />
protected override void InitializeServices(IServiceCollection serviceCollection)
{
base.InitializeServices(serviceCollection);
// You can configure dependency injection here by adding services to the serviceCollection.
}
}
}

View File

@@ -1,80 +1,80 @@
using Microsoft.VisualStudio.RpcContracts.RemoteUI;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Vector3VisualizerSource;
namespace Vector3Visualizer;
public class MyRemoteUserControl : IRemoteWpfUserControl, IRemoteProxiedUserControl, IRemoteUserControl, IDisposable, IRemoteProxiedUserControl2
{
public Vector3Model? Model { get; }
public MyRemoteUserControl(Vector3Model? model) => Model = model;
private bool disposedValue;
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects)
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
disposedValue = true;
}
}
// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
// ~MyRemoteUserControl()
// {
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
// Dispose(disposing: false);
// }
void IDisposable.Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
Task<RemoteWpfUserControlDefinition> IRemoteWpfUserControl.InitializeAsync(IRemoteProxiedUserControlClient remoteUserControlClient, CancellationToken cancellationToken)
{
return Task.FromResult(new RemoteWpfUserControlDefinition());
}
Task IRemoteWpfUserControl.ControlLoadedAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
Task<bool> IRemoteProxiedUserControl.GetObjectAsync(ObjectId id, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl.SetObjectPropertyAsync(ObjectId id, string propertyName, MessagePackFragment value, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl.SetCollectionEntryAsync(ObjectId id, int index, MessagePackFragment value, ObjectVersion? version, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl.InvokeAsync(ObjectId id, MessagePackFragment parameter, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl2.InvokeAsync(ObjectId id, MessagePackFragment parameter, IReadOnlyDictionary<string, string> context, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
using Microsoft.VisualStudio.RpcContracts.RemoteUI;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Vector3VisualizerSource;
namespace Vector3Visualizer;
public class MyRemoteUserControl : IRemoteWpfUserControl, IRemoteProxiedUserControl, IRemoteUserControl, IDisposable, IRemoteProxiedUserControl2
{
public Vector3Model? Model { get; }
public MyRemoteUserControl(Vector3Model? model) => Model = model;
private bool disposedValue;
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects)
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
disposedValue = true;
}
}
// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
// ~MyRemoteUserControl()
// {
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
// Dispose(disposing: false);
// }
void IDisposable.Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
Task<RemoteWpfUserControlDefinition> IRemoteWpfUserControl.InitializeAsync(IRemoteProxiedUserControlClient remoteUserControlClient, CancellationToken cancellationToken)
{
return Task.FromResult(new RemoteWpfUserControlDefinition());
}
Task IRemoteWpfUserControl.ControlLoadedAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
Task<bool> IRemoteProxiedUserControl.GetObjectAsync(ObjectId id, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl.SetObjectPropertyAsync(ObjectId id, string propertyName, MessagePackFragment value, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl.SetCollectionEntryAsync(ObjectId id, int index, MessagePackFragment value, ObjectVersion? version, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl.InvokeAsync(ObjectId id, MessagePackFragment parameter, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
Task<bool> IRemoteProxiedUserControl2.InvokeAsync(ObjectId id, MessagePackFragment parameter, IReadOnlyDictionary<string, string> context, CancellationToken cancellationToken)
{
return Task.FromResult(false);
}
}

View File

@@ -1,7 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@@ -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);
}
}
}

View File

@@ -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();
}
}
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -1,9 +0,0 @@
<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" />
</Folder>
<Project Path="Vector3Visualizer/Vector3Visualizer.csproj" />
<Project Path="Vector3VisualizerSource/Vector3VisualizerSource.csproj" />
<Project Path="Vector3VisualizerTest/Test.csproj" />
</Solution>

View File

@@ -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(

View File

@@ -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" />

View File

@@ -1,12 +0,0 @@
using System.Runtime.Serialization;
namespace Vector3VisualizerSource;
[DataContract]
public class Vector3Model
{
[DataMember]
public string Vector3 { get; set; } = "Null";
[DataMember]
public string Quaternion { get; set; } = "Null";
}

View File

@@ -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);
}
}

View File

@@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.DebuggerVisualizers" Version="17.6.1032901" />
<PackageReference Include="System.Numerics.Vectors" Version="4.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NamedPipes\NamedPipes.csproj" />
</ItemGroup>
</Project>

View File

@@ -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;

View File

@@ -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>

View File

@@ -1,3 +0,0 @@
<Solution>
<Project Path="Test.csproj" />
</Solution>

View File

@@ -1,14 +1,14 @@
using Vector3VisualizerSource;
using Microsoft.VisualStudio.Extensibility.UI;
namespace Vector3Visualizer;
internal class Vector3VisualizerUserControl : RemoteUserControl
{
public Vector3VisualizerUserControl(Vector3Model? dataContext) : base(dataContext)
{
Vector3Model = (Vector3Model?)DataContext;
}
public Vector3Model? Vector3Model { get; }
using Vector3VisualizerSource;
using Microsoft.VisualStudio.Extensibility.UI;
namespace Vector3Visualizer;
internal sealed class Vector3VisualizerUserControl : RemoteUserControl
{
public Vector3VisualizerUserControl(Vector3Model? dataContext) : base(dataContext)
{
Vector3Model = (Vector3Model?)DataContext;
}
public Vector3Model? Vector3Model { get; }
}

View File

@@ -1,16 +1,16 @@
<DataTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="Vector3" Grid.Column="0" Grid.Row="0" />
<TextBlock Text="{Binding Vector3}" Grid.Column="1" Grid.Row="0" />
<TextBlock Text="Quaternion" Grid.Column="0" Grid.Row="1" />
<TextBlock Text="{Binding Quaternion}" Grid.Column="1" Grid.Row="1" />
</Grid>
<DataTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition>
<RowDefinition Height="20"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="Vector3" Grid.Column="0" Grid.Row="0" />
<TextBlock Text="{Binding Vector3}" Grid.Column="1" Grid.Row="0" />
<TextBlock Text="Quaternion" Grid.Column="0" Grid.Row="1" />
<TextBlock Text="{Binding Quaternion}" Grid.Column="1" Grid.Row="1" />
</Grid>
</DataTemplate>