Browse Source

Merge pull request #2454 from icsharpcode/fix-2446-package-refs

Solution for #2446 adding support for package and project references in new-style "Dependencies" node
pull/2465/head
Christoph Wille 4 years ago committed by GitHub
parent
commit
cd928e5bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      ILSpy.AddIn/Commands/NuGetReferenceForILSpy.cs
  2. 16
      ILSpy.AddIn/Commands/OpenReferenceCommand.cs
  3. 8
      ILSpy.AddIn/ILSpy.AddIn.csproj
  4. 7
      ILSpy.AddIn/ILSpyAddIn.en-US.vsct
  5. 15
      ILSpy.AddIn/ILSpyAddIn.vsct
  6. 6
      ILSpy.AddIn/ILSpyAddIn.zh-Hans.vsct
  7. 23
      ILSpy/MainWindow.xaml.cs

6
ILSpy.AddIn/Commands/NuGetReferenceForILSpy.cs

@ -8,6 +8,8 @@ using EnvDTE; @@ -8,6 +8,8 @@ using EnvDTE;
using Microsoft.VisualStudio.Shell;
using VSLangProj;
namespace ICSharpCode.ILSpy.AddIn.Commands
{
/// <summary>
@ -33,8 +35,8 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -33,8 +35,8 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
if (itemData is ProjectItem projectItem)
{
var properties = Utils.GetProperties(projectItem.Properties, "Type");
if ((properties[0] as string) == "Package")
var properties = Utils.GetProperties(projectItem.Properties, "Type", "ExtenderCATID");
if (((properties[0] as string) == "Package") || ((properties[1] as string) == PrjBrowseObjectCATID.prjCATIDCSharpReferenceBrowseObject))
{
return new NuGetReferenceForILSpy(projectItem);
}

16
ILSpy.AddIn/Commands/OpenReferenceCommand.cs

@ -68,14 +68,6 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -68,14 +68,6 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
return;
}
// Handle NuGet references
var nugetRefItem = NuGetReferenceForILSpy.Detect(itemObject);
if (nugetRefItem != null)
{
OpenAssembliesInILSpy(nugetRefItem.GetILSpyParameters());
return;
}
// Handle project references
var projectRefItem = ProjectReferenceForILSpy.Detect(itemObject);
if (projectRefItem != null)
@ -96,6 +88,14 @@ namespace ICSharpCode.ILSpy.AddIn.Commands @@ -96,6 +88,14 @@ namespace ICSharpCode.ILSpy.AddIn.Commands
OpenAssembliesInILSpy(projectRefItem.GetILSpyParameters());
return;
}
// Handle NuGet references
var nugetRefItem = NuGetReferenceForILSpy.Detect(itemObject);
if (nugetRefItem != null)
{
OpenAssembliesInILSpy(nugetRefItem.GetILSpyParameters());
return;
}
}
internal static void Register(ILSpyAddInPackage owner)

8
ILSpy.AddIn/ILSpy.AddIn.csproj

@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.4.0" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServices" Version="2.4.0" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.0.1619-preview1">
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.0.2155-preview2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
@ -165,6 +165,12 @@ @@ -165,6 +165,12 @@
<None Include="ILSpyAddIn.vsct">
<SubType>Designer</SubType>
</None>
<None Include="ILSpyAddIn.en-US.vsct">
<SubType>Designer</SubType>
</None>
<None Include="ILSpyAddIn.zh-Hans.vsct">
<SubType>Designer</SubType>
</None>
<Content Include="zh-Hans\extension.vsixlangpack">
<IncludeInVSIX>true</IncludeInVSIX>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

7
ILSpy.AddIn/ILSpyAddIn.en-US.vsct

@ -56,7 +56,7 @@ @@ -56,7 +56,7 @@
<ButtonText>Open in ILSpy</ButtonText>
</Strings>
</Button>
<Button guid="guidILSpyAddInCmdSet" id="cmdidOpenProjectOutputInILSpy" priority="0x0600" type="Button">
<Parent guid="guidILSpyAddInCmdSet" id="OpenILSpyProjGroup" />
<Icon guid="guidImages" id="bmpLogo" />
@ -84,11 +84,6 @@ @@ -84,11 +84,6 @@
<ButtonText>ILSpy</ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
</CommandTable>

15
ILSpy.AddIn/ILSpyAddIn.vsct

@ -64,6 +64,14 @@ @@ -64,6 +64,14 @@
<Bitmap guid="guidImages" href="Resources\Images.png" usedList="bmpLogo, bmpPic1, bmpPic2, bmpPicX, bmpPicArrows"/>
</Bitmaps>
</Commands>
<CommandPlacements>
<CommandPlacement guid="guidILSpyAddInCmdSet" id="OpenILSpyRefGroup" priority="0x0200">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PACKAGEREFERENCE"/>
</CommandPlacement>
<CommandPlacement guid="guidILSpyAddInCmdSet" id="OpenILSpyRefGroup" priority="0x0200">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJECTREFERENCE"/>
</CommandPlacement>
</CommandPlacements>
<Symbols>
<!-- This is the package guid. -->
<GuidSymbol name="guidILSpyAddInPkg" value="{a9120dbe-164a-4891-842f-fb7829273838}" />
@ -75,6 +83,8 @@ @@ -75,6 +83,8 @@
<IDSymbol name="OpenILSpyRefGroup" value="0x1020" />
<IDSymbol name="OpenILSpyProjGroup" value="0x1030" />
<IDSymbol name="OpenILSpyCodeItemGroup" value="0x1040" />
<IDSymbol name="OpenILSpyPackageRefGroup" value="0x1050" />
<IDSymbol name="OpenILSpyProjectRefGroup" value="0x1060" />
<IDSymbol name="cmdidOpenILSpy" value="0x0100" />
<IDSymbol name="cmdidOpenReferenceInILSpy" value="0x0200" />
<IDSymbol name="cmdidOpenProjectOutputInILSpy" value="0x0300" />
@ -89,6 +99,11 @@ @@ -89,6 +99,11 @@
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
<GuidSymbol name="guidReferenceContext" value="{D309F791-903F-11D0-9EFC-00A0C911004F}">
<IDSymbol name="IDM_VS_CTXT_PACKAGEREFERENCE" value="0x04A3"/>
<IDSymbol name="IDM_VS_CTXT_PROJECTREFERENCE" value="0x04A7"/>
</GuidSymbol>
</Symbols>
</CommandTable>

6
ILSpy.AddIn/ILSpyAddIn.zh-Hans.vsct

@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
group; your package should define its own command set in order to avoid collisions
with command ids defined by other packages. -->
<!--Buttons section. -->
<!--This section defines the elements the user can interact with, like a menu command or a button
or combo box in a toolbar. -->
@ -84,9 +84,9 @@ @@ -84,9 +84,9 @@
<ButtonText>ILSpy</ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
</CommandTable>

23
ILSpy/MainWindow.xaml.cs

@ -379,24 +379,8 @@ namespace ICSharpCode.ILSpy @@ -379,24 +379,8 @@ namespace ICSharpCode.ILSpy
List<LoadedAssembly> commandLineLoadedAssemblies = new List<LoadedAssembly>();
List<string> nugetPackagesToLoad = new List<string>();
bool HandleCommandLineArguments(CommandLineArguments args)
{
int i = 0;
while (i < args.AssembliesToLoad.Count)
{
var asm = args.AssembliesToLoad[i];
if (Path.GetExtension(asm) == ".nupkg")
{
nugetPackagesToLoad.Add(asm);
args.AssembliesToLoad.RemoveAt(i);
}
else
{
i++;
}
}
LoadAssemblies(args.AssembliesToLoad, commandLineLoadedAssemblies, focusNode: false);
if (args.Language != null)
sessionSettings.FilterSettings.Language = Languages.GetLanguage(args.Language);
@ -409,13 +393,6 @@ namespace ICSharpCode.ILSpy @@ -409,13 +393,6 @@ namespace ICSharpCode.ILSpy
/// </summary>
void HandleCommandLineArgumentsAfterShowList(CommandLineArguments args, ILSpySettings spySettings = null)
{
if (nugetPackagesToLoad.Count > 0)
{
var relevantPackages = nugetPackagesToLoad.ToArray();
nugetPackagesToLoad.Clear();
// Show the nuget package open dialog after the command line/window message was processed.
Dispatcher.BeginInvoke(new Action(() => LoadAssemblies(relevantPackages, commandLineLoadedAssemblies, focusNode: false)), DispatcherPriority.Normal);
}
var relevantAssemblies = commandLineLoadedAssemblies.ToList();
commandLineLoadedAssemblies.Clear(); // clear references once we don't need them anymore
NavigateOnLaunch(args.NavigateTo, sessionSettings.ActiveTreeViewPath, spySettings, relevantAssemblies);

Loading…
Cancel
Save