private AttributeInfo[] GetAssemblyAttributes()
        {
            return(_metadataReader.CustomAttributes
                   .Select(_metadataReader.GetCustomAttribute)
                   .Where(x => x.Constructor.Kind == HandleKind.MemberReference && x.Parent.Kind == HandleKind.AssemblyDefinition)
                   .Select(customAttribute =>
            {
                var constructorRef = _metadataReader.GetMemberReference((MemberReferenceHandle)customAttribute.Constructor);
                var attributeTypeRefHandle = (TypeReferenceHandle)constructorRef.Parent;
                var typeProvider = new AttributeTypeProvider();
                var attributeTypeName = typeProvider.GetTypeFromReference(_metadataReader, attributeTypeRefHandle, 0);

                try
                {
                    var customAttributeValues = customAttribute.DecodeValue(typeProvider);

                    return (attributeTypeName, customAttributeValues);
                }
                catch (UnknownTypeException)
                {
                    return default((string Name, CustomAttributeValue <string> Args)?);
                }
            })
                   .Where(x => x.HasValue && x.Value.Name.StartsWith("System.Reflection.Assembly"))
                   .Select(x => new AttributeInfo(
                               Regex.Replace(x.Value.Name, @"^System\.Reflection\.Assembly(\w+)Attribute", "$1"),
                               x.Value.Args.FixedArguments.FirstOrDefault().Value.ToString()
                               ))
                   .ToArray());
        }
        public IEnumerable <AttributeInfo> GetAssemblyAttributes()
        {
            foreach (var attributeHandle in _metadataReader.CustomAttributes)
            {
                var customAttribute = _metadataReader.GetCustomAttribute(attributeHandle);
                if (customAttribute.Constructor.Kind != HandleKind.MemberReference ||
                    customAttribute.Parent.Kind != HandleKind.AssemblyDefinition)
                {
                    continue;
                }

                var constructorRef         = _metadataReader.GetMemberReference((MemberReferenceHandle)customAttribute.Constructor);
                var attributeTypeRefHandle = (TypeReferenceHandle)constructorRef.Parent;

                var typeProvider = new AttributeTypeProvider();

                var attributeTypeName = typeProvider.GetTypeFromReference(_metadataReader, attributeTypeRefHandle, 0);

                AttributeInfo?attrInfo = null;
                try
                {
                    var customAttributeValues = customAttribute.DecodeValue(typeProvider);

                    attrInfo = new AttributeInfo(
                        attributeTypeName,
                        customAttributeValues.FixedArguments.ToArray(),
                        customAttributeValues.NamedArguments.ToArray());
                }
                catch (UnknownTypeException)
                {
                    // It could happen that we cannot resolve some argument type (e.g. for custom attributes).
                    // In this case simply omit the attribute and try to read other ones.
                }

                if (attrInfo != null)
                {
                    yield return(attrInfo);
                }
            }
        }