private void MapCustomAttributes(SR.ICustomAttributeProvider provider, MC.ICustomAttributeProvider targetProvider)
        {
            var type = provider.GetType();

            // System.Reflection.Module.GetCustomAttributesData() not implemented in mono <= 3.4.0
            if (_is_running_mono && typeof(System.Reflection.Module).IsAssignableFrom(type))
            {
                return;
            }

            var method = type.GetMethod("GetCustomAttributesData");

            if (method == null)
            {
                throw new NotSupportedException("No method GetCustomAttributesData for type " + provider.GetType().FullName);
            }

            var custom_attributes_data = (IList <CustomAttributeData>)method.Invoke(provider, new object[0]);

            foreach (var custom_attribute_data in custom_attributes_data)
            {
                var custom_attribute = new CustomAttribute(CreateReference(custom_attribute_data.Constructor, null));

                foreach (var argument in custom_attribute_data.ConstructorArguments)
                {
                    custom_attribute.ConstructorArguments.Add(CustomAttributeArgumentFor(argument));
                }

                foreach (var named_argument in custom_attribute_data.NamedArguments)
                {
                    var argument = new MC.CustomAttributeNamedArgument(named_argument.MemberInfo.Name, CustomAttributeArgumentFor(named_argument.TypedValue));
                    if (named_argument.MemberInfo is PropertyInfo)
                    {
                        custom_attribute.Properties.Add(argument);
                    }
                    else if (named_argument.MemberInfo is FieldInfo)
                    {
                        custom_attribute.Fields.Add(argument);
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }

                targetProvider.CustomAttributes.Add(custom_attribute);
            }
        }