|
|
|
@ -17,14 +17,12 @@
@@ -17,14 +17,12 @@
|
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Reflection; |
|
|
|
|
using System.Reflection.Metadata; |
|
|
|
|
using System.Security.Cryptography; |
|
|
|
|
using System.Text; |
|
|
|
|
using ICSharpCode.Decompiler.Util; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.Decompiler.Metadata |
|
|
|
|
{ |
|
|
|
@ -167,27 +165,26 @@ namespace ICSharpCode.Decompiler.Metadata
@@ -167,27 +165,26 @@ namespace ICSharpCode.Decompiler.Metadata
|
|
|
|
|
{ |
|
|
|
|
static readonly SHA1 sha1 = SHA1.Create(); |
|
|
|
|
|
|
|
|
|
readonly System.Reflection.Metadata.AssemblyReference entry; |
|
|
|
|
|
|
|
|
|
public MetadataReader Metadata { get; } |
|
|
|
|
public AssemblyReferenceHandle Handle { get; } |
|
|
|
|
|
|
|
|
|
System.Reflection.Metadata.AssemblyReference This() => Metadata.GetAssemblyReference(Handle); |
|
|
|
|
|
|
|
|
|
public bool IsWindowsRuntime => (This().Flags & AssemblyFlags.WindowsRuntime) != 0; |
|
|
|
|
public bool IsRetargetable => (This().Flags & AssemblyFlags.Retargetable) != 0; |
|
|
|
|
public bool IsWindowsRuntime => (entry.Flags & AssemblyFlags.WindowsRuntime) != 0; |
|
|
|
|
public bool IsRetargetable => (entry.Flags & AssemblyFlags.Retargetable) != 0; |
|
|
|
|
|
|
|
|
|
public string Name => Metadata.GetString(This().Name); |
|
|
|
|
public string FullName => This().GetFullAssemblyName(Metadata); |
|
|
|
|
public Version Version => This().Version; |
|
|
|
|
public string Culture => Metadata.GetString(This().Culture); |
|
|
|
|
public string Name => Metadata.GetString(entry.Name); |
|
|
|
|
public string FullName => entry.GetFullAssemblyName(Metadata); |
|
|
|
|
public Version Version => entry.Version; |
|
|
|
|
public string Culture => Metadata.GetString(entry.Culture); |
|
|
|
|
byte[] IAssemblyReference.PublicKeyToken => GetPublicKeyToken(); |
|
|
|
|
|
|
|
|
|
public byte[] GetPublicKeyToken() |
|
|
|
|
{ |
|
|
|
|
var inst = This(); |
|
|
|
|
if (inst.PublicKeyOrToken.IsNil) |
|
|
|
|
if (entry.PublicKeyOrToken.IsNil) |
|
|
|
|
return null; |
|
|
|
|
var bytes = Metadata.GetBlobBytes(inst.PublicKeyOrToken); |
|
|
|
|
if ((inst.Flags & AssemblyFlags.PublicKey) != 0) { |
|
|
|
|
var bytes = Metadata.GetBlobBytes(entry.PublicKeyOrToken); |
|
|
|
|
if ((entry.Flags & AssemblyFlags.PublicKey) != 0) { |
|
|
|
|
return sha1.ComputeHash(bytes).Skip(12).ToArray(); |
|
|
|
|
} |
|
|
|
|
return bytes; |
|
|
|
@ -201,6 +198,7 @@ namespace ICSharpCode.Decompiler.Metadata
@@ -201,6 +198,7 @@ namespace ICSharpCode.Decompiler.Metadata
|
|
|
|
|
throw new ArgumentNullException(nameof(handle)); |
|
|
|
|
Metadata = metadata; |
|
|
|
|
Handle = handle; |
|
|
|
|
entry = metadata.GetAssemblyReference(handle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AssemblyReference(PEFile module, AssemblyReferenceHandle handle) |
|
|
|
@ -211,6 +209,7 @@ namespace ICSharpCode.Decompiler.Metadata
@@ -211,6 +209,7 @@ namespace ICSharpCode.Decompiler.Metadata
|
|
|
|
|
throw new ArgumentNullException(nameof(handle)); |
|
|
|
|
Metadata = module.Metadata; |
|
|
|
|
Handle = handle; |
|
|
|
|
entry = Metadata.GetAssemblyReference(handle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override string ToString() |
|
|
|
|