-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from tom-englert/feature/improvements
Feature/improvements
- Loading branch information
Showing
15 changed files
with
100 additions
and
67 deletions.
There are no files selected for viewing
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,7 @@ | ||
namespace NuGetMonitor | ||
{ | ||
internal static class GlobalConstants | ||
{ | ||
public static readonly string NetStandardPackageId = "NETStandard.Library"; | ||
} | ||
} |
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,4 @@ | ||
global using static Microsoft.VisualStudio.Shell.ThreadHelper; | ||
global using static NuGetMonitor.GlobalConstants; | ||
global using static NuGetMonitor.Services.LoggingService; | ||
|
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
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
using Microsoft.Build.Evaluation; | ||
using NuGet.Versioning; | ||
using NuGet.Versioning; | ||
using NuGetMonitor.Services; | ||
|
||
namespace NuGetMonitor.Models; | ||
|
||
internal sealed record PackageReferenceEntry | ||
{ | ||
public PackageReferenceEntry(string id, VersionRange versionRange, ProjectItem projectItem, string justification) | ||
public PackageReferenceEntry(string id, VersionRange versionRange, ProjectItemInTargetFramework projectItemInTargetFramework, string justification) | ||
{ | ||
ProjectItem = projectItem; | ||
ProjectItemInTargetFramework = projectItemInTargetFramework; | ||
Justification = justification; | ||
Identity = new PackageReference(id, versionRange); | ||
} | ||
|
||
public PackageReference Identity { get; } | ||
|
||
public ProjectItem ProjectItem { get; } | ||
public ProjectItemInTargetFramework ProjectItemInTargetFramework { get; } | ||
|
||
public string Justification { get; } | ||
}; | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,32 +1,44 @@ | ||
using Community.VisualStudio.Toolkit; | ||
using Microsoft.VisualStudio; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
|
||
namespace NuGetMonitor.Services; | ||
|
||
internal static class LoggingService | ||
{ | ||
private static Guid _outputPaneGuid = new("{5B951352-356E-45A9-8F73-80DF1C57FED4}"); | ||
|
||
private static IVsOutputWindowPane? _outputWindowPane; | ||
|
||
public static void Log(string message) | ||
{ | ||
LogAsync(message).FireAndForget(); | ||
} | ||
|
||
public static async Task LogAsync(string message) | ||
{ | ||
_outputWindowPane ??= await GetOutputWindowPane(); | ||
|
||
await JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
|
||
_outputWindowPane?.OutputStringThreadSafe($"[{DateTime.Now:T}] {message}\r\n"); | ||
} | ||
|
||
private static async Task<IVsOutputWindowPane?> GetOutputWindowPane() | ||
{ | ||
var outputWindow = await VS.Services.GetOutputWindowAsync(); | ||
|
||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
await JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
|
||
var errorCode = outputWindow.GetPane(ref _outputPaneGuid, out var pane); | ||
|
||
if (ErrorHandler.Failed(errorCode) || pane == null) | ||
{ | ||
outputWindow.CreatePane(ref _outputPaneGuid, "NuGet Monitor", Convert.ToInt32(true), Convert.ToInt32(false)); | ||
outputWindow.GetPane(ref _outputPaneGuid, out pane); | ||
} | ||
if (!ErrorHandler.Failed(errorCode) && pane != null) | ||
return pane; | ||
|
||
outputWindow.CreatePane(ref _outputPaneGuid, "NuGet Monitor", Convert.ToInt32(true), Convert.ToInt32(false)); | ||
outputWindow.GetPane(ref _outputPaneGuid, out pane); | ||
|
||
pane?.OutputStringThreadSafe($"[{DateTime.Now:T}] {message}\r\n"); | ||
return pane; | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.