Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
<OutputPath>bin/$(Configuration)/</OutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DeployExtension>True</DeployExtension>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CodingWithCalvin.Otel4Vsix" Version="0.2.2" />
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.14.40265" />
</ItemGroup>

Expand Down
85 changes: 57 additions & 28 deletions src/CodingWithCalvin.OpenBinFolder/Commands/OpenBinFolderCommand.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Windows.Forms;
using CodingWithCalvin.Otel4Vsix;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
Expand Down Expand Up @@ -44,39 +46,48 @@ private void OpenPath(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

if (!(ServiceProvider.GetService(typeof(DTE)) is DTE2 dte))
{
throw new ArgumentNullException(nameof(dte));
}
using var activity = VsixTelemetry.StartCommandActivity("OpenBinFolder.OpenPath");

foreach (
UIHierarchyItem selectedItem in (Array)
dte.ToolWindows.SolutionExplorer.SelectedItems
)
try
{
switch (selectedItem.Object)
if (!(ServiceProvider.GetService(typeof(DTE)) is DTE2 dte))
{
throw new ArgumentNullException(nameof(dte));
}

foreach (
UIHierarchyItem selectedItem in (Array)
dte.ToolWindows.SolutionExplorer.SelectedItems
)
{
case Project project:
try
{
switch (selectedItem.Object)
{
case Project project:
OpenProjectBinFolder(project);
}
catch (Exception ex)
{
MessageBox.Show(
$@"
Unable to determine output path for selected project
{Environment.NewLine}
{Environment.NewLine}
Exception: {ex.Message}"
);
}

break;
break;
}
}

VsixTelemetry.LogInformation("Bin folder opened successfully");
}
catch (Exception ex)
{
activity?.RecordError(ex);
VsixTelemetry.TrackException(ex, new Dictionary<string, object>
{
{ "operation.name", "OpenPath" }
});
throw;
}
}

void OpenProjectBinFolder(Project project)
private void OpenProjectBinFolder(Project project)
{
ThreadHelper.ThrowIfNotOnUIThread();

using var activity = VsixTelemetry.StartCommandActivity("OpenBinFolder.OpenProjectBinFolder");

try
{
var projectPath =
Path.GetDirectoryName(project.FullName)
Expand All @@ -88,9 +99,27 @@ void OpenProjectBinFolder(Project project)

var projectBinPath = Path.Combine(projectPath, projectOutputPath);

System.Diagnostics.Process.Start(
System.Diagnostics.Process.Start(
Directory.Exists(projectBinPath) ? projectBinPath : projectPath
);

VsixTelemetry.LogInformation("Opened bin folder for project");
}
catch (Exception ex)
{
activity?.RecordError(ex);
VsixTelemetry.TrackException(ex, new Dictionary<string, object>
{
{ "operation.name", "OpenProjectBinFolder" },
});

MessageBox.Show(
$@"
Unable to determine output path for selected project
{Environment.NewLine}
{Environment.NewLine}
Exception: {ex.Message}"
);
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/CodingWithCalvin.OpenBinFolder/HoneycombConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace CodingWithCalvin.OpenBinFolder
{
internal static class HoneycombConfig
{
public const string ApiKey = "PLACEHOLDER";
}
}
27 changes: 26 additions & 1 deletion src/CodingWithCalvin.OpenBinFolder/OpenBinFolderPackage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System;
using System.Runtime.InteropServices;
using System.Threading;
using CodingWithCalvin.OpenBinFolder.Commands;
using CodingWithCalvin.Otel4Vsix;
using Microsoft.VisualStudio.Shell;
using Task = System.Threading.Tasks.Task;

Expand All @@ -20,7 +21,31 @@ IProgress<ServiceProgressData> progress
{
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

var builder = VsixTelemetry.Configure()
.WithServiceName(VsixInfo.DisplayName)
.WithServiceVersion(VsixInfo.Version)
.WithVisualStudioAttributes(this)
.WithEnvironmentAttributes();

#if !DEBUG
builder
.WithOtlpHttp("https://api.honeycomb.io")
.WithHeader("x-honeycomb-team", HoneycombConfig.ApiKey);
#endif

builder.Initialize();

OpenBinFolderCommand.Initialize(this);
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
VsixTelemetry.Shutdown();
}

base.Dispose(disposing);
}
}
}