initial commit.
not working
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
[InternetShortcut]
|
||||||
|
URL=https://blog.elmah.io/creating-custom-debug-visualizers-for-visual-studio-2022/
|
||||||
3
MailAddressVisualizer/.vsextension/string-resources.json
Normal file
3
MailAddressVisualizer/.vsextension/string-resources.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"MailAddressVisualizer.Command1.DisplayName": "Sample Remote Command"
|
||||||
|
}
|
||||||
31
MailAddressVisualizer/ExtensionEntrypoint.cs
Normal file
31
MailAddressVisualizer/ExtensionEntrypoint.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.VisualStudio.Extensibility;
|
||||||
|
|
||||||
|
namespace MailAddressVisualizer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extension entrypoint for the VisualStudio.Extensibility extension.
|
||||||
|
/// </summary>
|
||||||
|
[VisualStudioContribution]
|
||||||
|
internal class ExtensionEntrypoint : Extension
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override ExtensionConfiguration ExtensionConfiguration => new()
|
||||||
|
{
|
||||||
|
Metadata = new(
|
||||||
|
id: "MailAddressVisualizer.3c0400c3-acec-4b09-b561-c11fac7b10a7",
|
||||||
|
version: this.ExtensionAssemblyVersion,
|
||||||
|
publisherName: "Publisher name",
|
||||||
|
displayName: "MailAddressVisualizer",
|
||||||
|
description: "Extension description"),
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void InitializeServices(IServiceCollection serviceCollection)
|
||||||
|
{
|
||||||
|
base.InitializeServices(serviceCollection);
|
||||||
|
|
||||||
|
// You can configure dependency injection here by adding services to the serviceCollection.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using MailAddressVisualizerSource;
|
||||||
|
using Microsoft.VisualStudio.Extensibility.DebuggerVisualizers;
|
||||||
|
using Microsoft.VisualStudio.RpcContracts.RemoteUI;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace MailAddressVisualizer;
|
||||||
|
|
||||||
|
internal class MailAddressDebuggerVisualizerProvider : DebuggerVisualizerProvider
|
||||||
|
{
|
||||||
|
public override DebuggerVisualizerProviderConfiguration DebuggerVisualizerProviderConfiguration
|
||||||
|
=> new("Mail Address Visualizer", typeof(MailAddress));
|
||||||
|
|
||||||
|
public override async Task<IRemoteUserControl> CreateVisualizerAsync(
|
||||||
|
VisualizerTarget visualizerTarget, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
MailAddressModel? model = await visualizerTarget
|
||||||
|
.ObjectSource
|
||||||
|
.RequestDataAsync<MailAddressModel?>(jsonSerializer: null, CancellationToken.None);
|
||||||
|
|
||||||
|
return await Task.FromResult<IRemoteUserControl>(
|
||||||
|
new MailAddressVisualizerUserControl(model));
|
||||||
|
}
|
||||||
|
}
|
||||||
24
MailAddressVisualizer/MailAddressVisualizer.csproj
Normal file
24
MailAddressVisualizer/MailAddressVisualizer.csproj
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.14.40608" PrivateAssets="all" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.14.40608" PrivateAssets="all" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="MailAddressVisualizerUserControl.xaml" />
|
||||||
|
<EmbeddedResource Include="MailAddressVisualizerUserControl.xaml" LogicalName="$(RootNamespace).MailAddressVisualizerUserControl.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MailAddressVisualizerSource\MailAddressVisualizerSource.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\MailAddressVisualizerSource\bin\$(Configuration)\netstandard2.0\MailAddressVisualizerSource.dll" Link="netstandard2.0\MailAddressVisualizerSource.dll" CopyToOutputDirectory="PreserveNewest" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
4
MailAddressVisualizer/MailAddressVisualizer.slnx
Normal file
4
MailAddressVisualizer/MailAddressVisualizer.slnx
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<Solution>
|
||||||
|
<Project Path="../MailAddressVisualizerSource/MailAddressVisualizerSource.csproj" />
|
||||||
|
<Project Path="MailAddressVisualizer.csproj" />
|
||||||
|
</Solution>
|
||||||
11
MailAddressVisualizer/MailAddressVisualizerUserControl .cs
Normal file
11
MailAddressVisualizer/MailAddressVisualizerUserControl .cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using MailAddressVisualizerSource;
|
||||||
|
using Microsoft.VisualStudio.Extensibility.UI;
|
||||||
|
|
||||||
|
namespace MailAddressVisualizer;
|
||||||
|
|
||||||
|
internal class MailAddressVisualizerUserControl : RemoteUserControl
|
||||||
|
{
|
||||||
|
public MailAddressVisualizerUserControl(MailAddressModel? model) : base(model)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
16
MailAddressVisualizer/MailAddressVisualizerUserControl.xaml
Normal file
16
MailAddressVisualizer/MailAddressVisualizerUserControl.xaml
Normal file
@@ -0,0 +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="Display Name" Grid.Column="0" Grid.Row="0" />
|
||||||
|
<TextBlock Text="{Binding DisplayName}" Grid.Column="1" Grid.Row="0" />
|
||||||
|
<TextBlock Text="Email" Grid.Column="0" Grid.Row="1" />
|
||||||
|
<TextBlock Text="{Binding Email}" Grid.Column="1" Grid.Row="1" />
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
13
MailAddressVisualizerSource/MailAddressModel.cs
Normal file
13
MailAddressVisualizerSource/MailAddressModel.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Runtime.Serialization;
|
||||||
|
namespace MailAddressVisualizerSource;
|
||||||
|
|
||||||
|
[DataContract]
|
||||||
|
public class MailAddressModel
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public string DisplayName { get; set; } = "";
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
public string Email { get; set; } = "";
|
||||||
|
}
|
||||||
|
|
||||||
20
MailAddressVisualizerSource/MailAddressObjectSource .cs
Normal file
20
MailAddressVisualizerSource/MailAddressObjectSource .cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Microsoft.VisualStudio.DebuggerVisualizers;
|
||||||
|
using System.Net.Mail;
|
||||||
|
|
||||||
|
namespace MailAddressVisualizerSource;
|
||||||
|
|
||||||
|
public class MailAddressObjectSource : VisualizerObjectSource
|
||||||
|
{
|
||||||
|
public override void GetData(object target, Stream outgoingData)
|
||||||
|
{
|
||||||
|
if (target is MailAddress mail)
|
||||||
|
{
|
||||||
|
var result = new MailAddressModel
|
||||||
|
{
|
||||||
|
DisplayName = mail.DisplayName,
|
||||||
|
Email = mail.Address,
|
||||||
|
};
|
||||||
|
SerializeAsJson(outgoingData, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.DebuggerVisualizers" Version="17.6.1032901" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
7
MailAddressVisualizerTest/Program.cs
Normal file
7
MailAddressVisualizerTest/Program.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
using System.Net.Mail;
|
||||||
|
|
||||||
|
var displayName = "Thomas Ardal";
|
||||||
|
var email = "thomas@elmah.io";
|
||||||
|
var mailAddress = new MailAddress(email, displayName);
|
||||||
|
return;
|
||||||
10
MailAddressVisualizerTest/Test.csproj
Normal file
10
MailAddressVisualizerTest/Test.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
3
MailAddressVisualizerTest/Test.slnx
Normal file
3
MailAddressVisualizerTest/Test.slnx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<Solution>
|
||||||
|
<Project Path="Test.csproj" />
|
||||||
|
</Solution>
|
||||||
Reference in New Issue
Block a user