public static string GetFullAssemblyName(this MetadataReader metadataReader, AssemblyDefinition assemblyDefinition) { var assemblyName = metadataReader.GetString(assemblyDefinition.Name); var culture = metadataReader.GetString(assemblyDefinition.Culture); if (string.IsNullOrEmpty(culture)) { culture = "neutral"; } var version = assemblyDefinition.Version; var publicKeyBytes = metadataReader.GetBytes(assemblyDefinition.PublicKey); byte[] publicKeyTokenBytes = publicKeyBytes; string publicKeyToken = "null"; if (publicKeyBytes.Length > 0) { publicKeyTokenBytes = CalculatePublicKeyToken(publicKeyBytes); publicKeyToken = Conversion.ByteArrayToHexString(publicKeyTokenBytes); } var fullAssemblyName = string.Format( "{0}, Version={1}, Culture={2}, PublicKeyToken={3}", assemblyName, version.ToString(), culture, publicKeyToken); return(fullAssemblyName); }
public static string GetFullAssemblyName(this MetadataReader metadataReader, AssemblyReference assemblyReference) { var assemblyName = metadataReader.GetString(assemblyReference.Name); var culture = metadataReader.GetString(assemblyReference.Culture); if (string.IsNullOrEmpty(culture)) { culture = "neutral"; } var version = assemblyReference.Version; var publicKeyTokenBytes = metadataReader.GetBytes(assemblyReference.PublicKeyOrToken); var publicKeyToken = Conversion.ByteArrayToHexString(publicKeyTokenBytes); publicKeyToken = string.IsNullOrEmpty(publicKeyToken) ? "null" : publicKeyToken; var fullAssemblyName = string.Format( "{0}, Version={1}, Culture={2}, PublicKeyToken={3}", assemblyName, version.ToString(), culture, publicKeyToken); return(fullAssemblyName); }
private void WriteBlobs() { int size = reader.GetHeapSize(HeapIndex.Blob); if (size == 0) { return; } writer.WriteLine(string.Format("#Blob (size = {0}):", size)); var handle = MetadataTokens.BlobHandle(0); do { byte[] value = reader.GetBytes(handle); writer.WriteLine(" {0:x}: {1}", reader.GetHeapOffset(handle), BitConverter.ToString(value)); handle = reader.GetNextHandle(handle); }while (!handle.IsNil); writer.WriteLine(); }