Ejemplo n.º 1
0
        /// <exception cref="BadImageFormatException">An exception from metadata reader.</exception>
        internal static ImmutableArray <AssemblyIdentity> GetReferencedAssembliesOrThrow(this MetadataReader reader)
        {
            var result = ArrayBuilder <AssemblyIdentity> .GetInstance(reader.AssemblyReferences.Count);

            try
            {
                foreach (var assemblyRef in reader.AssemblyReferences)
                {
                    AssemblyReference reference = reader.GetAssemblyReference(assemblyRef);
                    result.Add(reader.CreateAssemblyIdentityOrThrow(
                                   reference.Version,
                                   reference.Flags,
                                   reference.PublicKeyOrToken,
                                   reference.Name,
                                   reference.Culture,
                                   isReference: true));
                }

                return(result.ToImmutable());
            }
            finally
            {
                result.Free();
            }
        }
Ejemplo n.º 2
0
        /// <exception cref="BadImageFormatException">An exception from metadata reader.</exception>
        internal static AssemblyIdentity ReadAssemblyIdentityOrThrow(this MetadataReader reader)
        {
            if (!reader.IsAssembly)
            {
                return(null);
            }

            var assemblyDef = reader.GetAssemblyDefinition();

            return(reader.CreateAssemblyIdentityOrThrow(
                       assemblyDef.Version,
                       assemblyDef.Flags,
                       assemblyDef.PublicKey,
                       assemblyDef.Name,
                       assemblyDef.Culture,
                       isReference: false));
        }