Browse Source

fix #509 Visual Studio Addin is useless for Framework Assemblies

pull/521/head
Siegfried Pammer 11 years ago
parent
commit
27f50ee6b9
  1. 15
      ILSpy.AddIn/ILSpyAddInPackage.cs
  2. 20
      ILSpy.AddIn/Utils.cs
  3. 3
      ILSpy/Properties/AssemblyInfo.template.cs

15
ILSpy.AddIn/ILSpyAddInPackage.cs

@ -10,6 +10,7 @@ using Microsoft.VisualStudio.OLE.Interop; @@ -10,6 +10,7 @@ using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using System.Reflection;
using System.IO;
using Mono.Cecil;
namespace ICSharpCode.ILSpy.AddIn
{
@ -86,13 +87,19 @@ namespace ICSharpCode.ILSpy.AddIn @@ -86,13 +87,19 @@ namespace ICSharpCode.ILSpy.AddIn
private void OpenInILSpyCallback(object sender, EventArgs e)
{
var explorer = ((EnvDTE80.DTE2)GetGlobalService(typeof(EnvDTE.DTE))).ToolWindows.SolutionExplorer;
var items =(object[]) explorer.SelectedItems ;
var items =(object[]) explorer.SelectedItems;
foreach (EnvDTE.UIHierarchyItem item in items) {
dynamic obj = item.Object;
OpenAssemblyInILSpy(obj.Path);
dynamic reference = item.Object;
string path = null;
if (reference.PublicKeyToken != "") {
var token = Utils.HexStringToBytes(reference.PublicKeyToken);
path = GacInterop.FindAssemblyInNetGac(new AssemblyNameReference(reference.Identity, new Version(reference.Version)) { PublicKeyToken = token });
}
if (path == null)
path = reference.Path;
OpenAssemblyInILSpy(path);
}
}
private void OpenILSpyCallback(object sender, EventArgs e)

20
ILSpy.AddIn/Utils.cs

@ -100,5 +100,25 @@ namespace ICSharpCode.ILSpy.AddIn @@ -100,5 +100,25 @@ namespace ICSharpCode.ILSpy.AddIn
}
#endregion
public static byte[] HexStringToBytes(string hex)
{
var result = new byte[hex.Length / 2];
for (int i = 0; i < hex.Length / 2; i++) {
result[i] = (byte)(ParseNibble(hex[i * 2]) * 16
+ ParseNibble(hex[i * 2 + 1]));
}
return result;
}
static int ParseNibble(char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
throw new ArgumentException("Invalid hex digit: " + c);
}
}
}

3
ILSpy/Properties/AssemblyInfo.template.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#endregion
@ -29,6 +30,8 @@ using System.Runtime.InteropServices; @@ -29,6 +30,8 @@ using System.Runtime.InteropServices;
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
Justification = "AssemblyInformationalVersion does not need to be a parsable version")]
[assembly: InternalsVisibleTo("ILSpy.AddIn, PublicKey=0024000004800000940000000602000000240000525341310004000001000100653c4a319be4f524972c3c5bba5fd243330f8e900287d9022d7821a63fd0086fd3801e3683dbe9897f2ecc44727023e9b40adcf180730af70c81c54476b3e5ba8b0f07f5132b2c3cc54347a2c1a9d64ebaaaf3cbffc1a18c427981e2a51d53d5ab02536b7550e732f795121c38a0abfdb38596353525d034baf9e6f1fd8ac4ac")]
internal static class RevisionClass
{
public const string Major = "2";

Loading…
Cancel
Save