-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support navigating to Object Browser from the Dependencies tree #9602
Changes from all commits
9d06bb5
df2ef42
434d2e0
38a5703
8752831
823fbd2
0cc24dd
32b7a4f
d2feb6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information. | ||
|
||
namespace Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections; | ||
|
||
/// <summary> | ||
/// Used by implementations of <see cref="IRelatableItem"/> that support opening in Visual Studio's Object Browser via their context menu. | ||
/// </summary> | ||
public interface IObjectBrowserItem : IRelatableItem | ||
{ | ||
/// <summary> | ||
/// Gets the absolute path to an assembly that should be opened in the Object Browser. | ||
/// </summary> | ||
string? AssemblyPath { get; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,11 @@ | |
|
||
namespace Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections.Implementation | ||
{ | ||
internal sealed class FrameworkReferenceAssemblyItem : RelatableItemBase | ||
internal sealed class FrameworkReferenceAssemblyItem : RelatableItemBase, IObjectBrowserItem | ||
{ | ||
private const int IDM_VS_CTXT_TRANSITIVE_ASSEMBLY_REFERENCE = 0x04B1; | ||
|
||
private static readonly IContextMenuController s_defaultMenuController = new MenuController(VsMenus.guidSHLMainMenu, IDM_VS_CTXT_TRANSITIVE_ASSEMBLY_REFERENCE); | ||
private static readonly IContextMenuController s_defaultMenuController = CreateContextMenuController(VsMenus.guidSHLMainMenu, IDM_VS_CTXT_TRANSITIVE_ASSEMBLY_REFERENCE); | ||
|
||
public string AssemblyName { get; } | ||
public string? Path { get; } | ||
|
@@ -38,33 +38,33 @@ public FrameworkReferenceAssemblyItem(string assemblyName, string? path, string? | |
|
||
public override object? GetBrowseObject() => new BrowseObject(this); | ||
|
||
private sealed class BrowseObject : LocalizableProperties | ||
{ | ||
private readonly FrameworkReferenceAssemblyItem _item; | ||
string? IObjectBrowserItem.AssemblyPath => GetAssemblyPath(); | ||
|
||
public BrowseObject(FrameworkReferenceAssemblyItem log) => _item = log; | ||
private string? GetAssemblyPath() => Path is not null | ||
? System.IO.Path.GetFullPath(System.IO.Path.Combine(Framework.Path, Path)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious, how does this path look like? are any of the paths rooted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It ultimately ends up as an absolute path to the assembly, so that we can use it in the object browser and show it in the "Properties" view. The |
||
: null; | ||
|
||
public override string GetComponentName() => _item.AssemblyName; | ||
private sealed class BrowseObject(FrameworkReferenceAssemblyItem item) : LocalizableProperties | ||
{ | ||
public override string GetComponentName() => item.AssemblyName; | ||
|
||
public override string GetClassName() => VSResources.FrameworkAssemblyBrowseObjectClassName; | ||
|
||
[BrowseObjectDisplayName(nameof(VSResources.FrameworkAssemblyAssemblyNameDisplayName))] | ||
[BrowseObjectDescription(nameof(VSResources.FrameworkAssemblyAssemblyNameDescription))] | ||
public string AssemblyName => _item.Text; | ||
public string AssemblyName => item.Text; | ||
|
||
[BrowseObjectDisplayName(nameof(VSResources.FrameworkAssemblyPathDisplayName))] | ||
[BrowseObjectDescription(nameof(VSResources.FrameworkAssemblyPathDescription))] | ||
public string Path => _item.Path is not null | ||
? System.IO.Path.GetFullPath(System.IO.Path.Combine(_item.Framework.Path, _item.Path)) | ||
: ""; | ||
public string Path => item.GetAssemblyPath() ?? ""; | ||
|
||
[BrowseObjectDisplayName(nameof(VSResources.FrameworkAssemblyAssemblyVersionDisplayName))] | ||
[BrowseObjectDescription(nameof(VSResources.FrameworkAssemblyAssemblyVersionDescription))] | ||
public string AssemblyVersion => _item.AssemblyVersion ?? ""; | ||
public string AssemblyVersion => item.AssemblyVersion ?? ""; | ||
|
||
[BrowseObjectDisplayName(nameof(VSResources.FrameworkAssemblyFileVersionDisplayName))] | ||
[BrowseObjectDescription(nameof(VSResources.FrameworkAssemblyFileVersionDescription))] | ||
public string FileVersion => _item.FileVersion ?? ""; | ||
public string FileVersion => item.FileVersion ?? ""; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish to learn more if there is a document I can refer about such kind setting more properties or constraint in package reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this document should cover that info: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files
Let me know if there are specific questions that doc doesn't answer for you.
Note that the change here is based on the recommendation from NuGet.org: https://www.nuget.org/packages/PolySharp/