-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
332 additions
and
29 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide/ExecutionPlanObjectSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Text; | ||
using MarkMpn.Sql4Cds.Engine; | ||
using MarkMpn.Sql4Cds.Engine.ExecutionPlan; | ||
using Microsoft.VisualStudio.DebuggerVisualizers; | ||
|
||
namespace MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide | ||
{ | ||
public class ExecutionPlanObjectSource : VisualizerObjectSource | ||
{ | ||
public override void GetData(object target, Stream outgoingData) | ||
{ | ||
if (target is IRootExecutionPlanNode root) | ||
WritePlan(outgoingData, root); | ||
else | ||
WritePlan(outgoingData, new UnknownRootNode { Source = (IExecutionPlanNode)target }); | ||
} | ||
|
||
private void WritePlan(Stream outgoingData, IRootExecutionPlanNode source) | ||
{ | ||
var json = ExecutionPlanSerializer.Serialize(source); | ||
SerializeAsJson(outgoingData, new SerializedPlan { Plan = json }); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...pn.Sql4Cds.DebugVisualizer.DebugeeSide/MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;net462</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.DebuggerVisualizers" Version="17.6.1032901" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MarkMpn.Sql4Cds.Engine.NetCore\MarkMpn.Sql4Cds.Engine.NetCore.csproj" Condition="'$(TargetFramework)' == 'net6.0'" /> | ||
<ProjectReference Include="..\MarkMpn.Sql4Cds.Engine.NetFx\MarkMpn.Sql4Cds.Engine.NetFx.csproj" Condition="'$(TargetFramework)' == 'net462'" /> | ||
</ItemGroup> | ||
|
||
</Project> |
13 changes: 13 additions & 0 deletions
13
MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide/SerializedPlan.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide | ||
{ | ||
public class SerializedPlan | ||
{ | ||
public string Plan { get; set; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide/UnknownRootNode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MarkMpn.Sql4Cds.Engine.ExecutionPlan; | ||
|
||
namespace MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide | ||
{ | ||
internal class UnknownRootNode : IRootExecutionPlanNode | ||
{ | ||
public string Sql { get; set; } | ||
public int Index { get; set; } | ||
public int Length { get; set; } | ||
public int LineNumber { get; set; } | ||
|
||
public IExecutionPlanNode Parent => null; | ||
|
||
public int ExecutionCount => 0; | ||
|
||
public TimeSpan Duration => TimeSpan.Zero; | ||
|
||
public IExecutionPlanNode Source { get; set; } | ||
|
||
public IEnumerable<IExecutionPlanNode> GetSources() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide/.vsextension/string-resources.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"MarkMpn.Sql4Cds.DebugVisualizer.DisplayName": "SQL 4 CDS Visualizer" | ||
} |
38 changes: 38 additions & 0 deletions
38
MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide/ExecutionPlanDebuggerVisualizerProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Diagnostics; | ||
using MarkMpn.Sql4Cds.Engine; | ||
using Microsoft; | ||
using Microsoft.VisualStudio.Extensibility; | ||
using Microsoft.VisualStudio.Extensibility.Commands; | ||
using Microsoft.VisualStudio.Extensibility.DebuggerVisualizers; | ||
using Microsoft.VisualStudio.Extensibility.Shell; | ||
using Microsoft.VisualStudio.Extensibility.VSSdkCompatibility; | ||
using Microsoft.VisualStudio.RpcContracts.RemoteUI; | ||
using Microsoft.VisualStudio.Shell; | ||
|
||
namespace MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide | ||
{ | ||
/// <summary> | ||
/// Debugger visualizer provider for <see cref="IRootExecutionPlanNode"/>. | ||
/// </summary> | ||
[VisualStudioContribution] | ||
internal class ExecutionPlanDebuggerVisualizerProvider : DebuggerVisualizerProvider | ||
{ | ||
private const string DisplayName = "MarkMpn.Sql4Cds.DebugVisualizer.DisplayName"; | ||
|
||
public override DebuggerVisualizerProviderConfiguration DebuggerVisualizerProviderConfiguration => new( | ||
new VisualizerTargetType($"%{DisplayName}%", "MarkMpn.Sql4Cds.Engine.ExecutionPlan.SelectNode, MarkMpn.Sql4Cds.Engine, Version=0.0.0.0, Culture=neutral")) | ||
{ | ||
VisualizerObjectSourceType = new("MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide.ExecutionPlanObjectSource, MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide") | ||
}; | ||
|
||
public override async Task<IRemoteUserControl> CreateVisualizerAsync(VisualizerTarget visualizerTarget, CancellationToken cancellationToken) | ||
{ | ||
var serializedPlan = await visualizerTarget.ObjectSource.RequestDataAsync<SerializedPlan>(null, cancellationToken); | ||
var plan = ExecutionPlanSerializer.Deserialize(serializedPlan.Plan); | ||
|
||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); | ||
var wrapper = new WpfControlWrapper(new QueryPlanUserControl(plan)); | ||
return wrapper; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide/ExtensionEntrypoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.VisualStudio.Extensibility; | ||
|
||
namespace MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide | ||
{ | ||
/// <summary> | ||
/// Extension entrypoint for the VisualStudio.Extensibility extension. | ||
/// </summary> | ||
[VisualStudioContribution] | ||
internal class ExtensionEntrypoint : Extension | ||
{ | ||
/// <inheritdoc/> | ||
public override ExtensionConfiguration ExtensionConfiguration => new() | ||
{ | ||
RequiresInProcessHosting = true | ||
}; | ||
|
||
/// <inheritdoc /> | ||
protected override void InitializeServices(IServiceCollection serviceCollection) | ||
{ | ||
base.InitializeServices(serviceCollection); | ||
|
||
// You can configure dependency injection here by adding services to the serviceCollection. | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions
48
....Sql4Cds.DebugVisualizer.DebuggerSide/MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> | ||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<VssdkCompatibleExtension>true</VssdkCompatibleExtension> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Remove="QueryPlanUserControl.xaml" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="..\MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide\bin\$(Configuration)\net6.0\MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide.dll" Link="netcoreapp\MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide.dll" /> | ||
<Content Include="..\MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide\bin\$(Configuration)\net462\MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide.dll" Link="net2.0\MarkMpn.Sql4Cds.DebugVisualizer.DebugeeSide.dll" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Page Include="QueryPlanUserControl.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.DebuggerVisualizers" Version="17.6.1032901" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.2092" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.2092" /> | ||
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.10.40171"> | ||
<ExcludeAssets>runtime</ExcludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="System.Xaml" /> | ||
<Reference Include="WindowsFormsIntegration" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Images\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MarkMpn.Sql4Cds.Controls\MarkMpn.Sql4Cds.Controls.csproj" /> | ||
<ProjectReference Include="..\MarkMpn.Sql4Cds.Engine.NetFx\MarkMpn.Sql4Cds.Engine.NetFx.csproj" /> | ||
</ItemGroup> | ||
</Project> |
6 changes: 6 additions & 0 deletions
6
MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide/QueryPlanUserControl.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<UserControl x:Class="MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide.QueryPlanUserControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> | ||
<Grid x:Name="grid"/> | ||
</UserControl> |
44 changes: 44 additions & 0 deletions
44
MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide/QueryPlanUserControl.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using MarkMpn.Sql4Cds.Engine.ExecutionPlan; | ||
using Microsoft.VisualStudio.Extensibility.DebuggerVisualizers; | ||
using Microsoft.VisualStudio.PlatformUI; | ||
//using Microsoft.Web.WebView2.Core; | ||
using System.Buffers; | ||
using System.Diagnostics; | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Forms; | ||
|
||
namespace MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide | ||
{ | ||
public partial class QueryPlanUserControl : System.Windows.Controls.UserControl | ||
{ | ||
private readonly IRootExecutionPlanNode _plan; | ||
|
||
public QueryPlanUserControl(IRootExecutionPlanNode plan) | ||
{ | ||
InitializeComponent(); | ||
DataContext = this; | ||
|
||
_plan = plan; | ||
this.Loaded += QueryPlanUserControl_Loaded; | ||
} | ||
|
||
private void QueryPlanUserControl_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
// Create the interop host control. | ||
System.Windows.Forms.Integration.WindowsFormsHost host = | ||
new System.Windows.Forms.Integration.WindowsFormsHost(); | ||
|
||
// Create the control. | ||
var control = new MarkMpn.Sql4Cds.Controls.ExecutionPlanView { Plan = _plan }; | ||
|
||
// Assign the MaskedTextBox control as the host control's child. | ||
host.Child = control; | ||
|
||
// Add the interop host control to the Grid | ||
// control's collection of child controls. | ||
this.grid.Children.Add(host); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide/SerializedPlan.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide | ||
{ | ||
public class SerializedPlan | ||
{ | ||
public string Plan { get; set; } | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide/source.extension.vsixmanifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011"> | ||
<Metadata> | ||
<Identity Id="MarkMpn.Sql4Cds.DebugVisualizer.DebuggerSide.2FD700A9-659B-45CB-A045-25B050AD5CAF" Version="1.0.0" Language="en-US" Publisher="MarkMpn" /> | ||
<DisplayName>SQL 4 CDS Visualizer</DisplayName> | ||
<Description xml:space="preserve">View SQL 4 CDS query plan directly inside Visual Studio.</Description> | ||
<Preview>false</Preview> | ||
<MoreInfo>https://github.com/MarkMpn.Sql4Cds</MoreInfo> | ||
<GettingStartedGuide>https://github.com/MarkMpn/Sql4Cds/blob/master/README.md</GettingStartedGuide> | ||
<Icon>Images\IconSmall.png</Icon> | ||
<Tags>SQL 4 CDS,SQL4CDS, Visualizer, Query Plan</Tags> | ||
</Metadata> | ||
<Installation ExtensionType="VSSDK+VisualStudio.Extensibility"> | ||
<InstallationTarget Version="[17.9, 18.0)" Id="Microsoft.VisualStudio.Community"> | ||
<ProductArchitecture>amd64</ProductArchitecture> | ||
</InstallationTarget> | ||
<InstallationTarget Version="[17.9, 18.0)" Id="Microsoft.VisualStudio.Community"> | ||
<ProductArchitecture>arm64</ProductArchitecture> | ||
</InstallationTarget> | ||
<InstallationTarget Version="[17.9,18.0)" Id="Microsoft.VisualStudio.Pro"> | ||
<ProductArchitecture>amd64</ProductArchitecture> | ||
</InstallationTarget> | ||
<InstallationTarget Version="[17.9,18.0)" Id="Microsoft.VisualStudio.Pro"> | ||
<ProductArchitecture>arm64</ProductArchitecture> | ||
</InstallationTarget> | ||
<InstallationTarget Version="[17.9,18.0)" Id="Microsoft.VisualStudio.Enterprise"> | ||
<ProductArchitecture>amd64</ProductArchitecture> | ||
</InstallationTarget> | ||
<InstallationTarget Version="[17.9,18.0)" Id="Microsoft.VisualStudio.Enterprise"> | ||
<ProductArchitecture>arm64</ProductArchitecture> | ||
</InstallationTarget> | ||
</Installation> | ||
<Dependencies> | ||
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" /> | ||
</Dependencies> | ||
<Prerequisites> | ||
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,18.0)" DisplayName="Visual Studio core editor" /> | ||
</Prerequisites> | ||
</PackageManifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters