From 2f8bc1b3d7025ce8486850604da060c7e3a8daf4 Mon Sep 17 00:00:00 2001 From: Bill Holmes Date: Thu, 21 Oct 2021 16:44:36 -0400 Subject: Ignore inherit param for ParameterInfo.GetCustomAttributes (#21200) It is documented that the inherit flag is ignored. Attribute.GetCustomAttributes is to be used to search inheritance chain. This change is only for the Mono classlib implementation. CoreCLR already has this behavior. --- mcs/class/corlib/System.Reflection/RuntimeParameterInfo.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mcs') diff --git a/mcs/class/corlib/System.Reflection/RuntimeParameterInfo.cs b/mcs/class/corlib/System.Reflection/RuntimeParameterInfo.cs index 0b49a1aff35..d57fbdecde9 100644 --- a/mcs/class/corlib/System.Reflection/RuntimeParameterInfo.cs +++ b/mcs/class/corlib/System.Reflection/RuntimeParameterInfo.cs @@ -192,14 +192,20 @@ namespace System.Reflection override object[] GetCustomAttributes (bool inherit) { - return MonoCustomAttrs.GetCustomAttributes (this, inherit); + // It is documented that the inherit flag is ignored. + // Attribute.GetCustomAttributes is to be used to search + // inheritance chain. + return MonoCustomAttrs.GetCustomAttributes (this, false); } public override object[] GetCustomAttributes (Type attributeType, bool inherit) { - return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit); + // It is documented that the inherit flag is ignored. + // Attribute.GetCustomAttributes is to be used to search + // inheritance chain. + return MonoCustomAttrs.GetCustomAttributes (this, attributeType, false); } internal object GetDefaultValueImpl (ParameterInfo pinfo) -- cgit v1.2.3