Skip to content

Commit 02d5f4b

Browse files
authored
Merge pull request #1484 from Unity-Technologies/mono-paraminfo-getattrs-inherit-ignore
Ignore inherit param for ParameterInfo.GetCustomAttributes
2 parents c0a96d0 + 3bed6fd commit 02d5f4b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

mcs/class/corlib/System.Reflection/RuntimeParameterInfo.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,20 @@ int MetadataToken {
192192
override
193193
object[] GetCustomAttributes (bool inherit)
194194
{
195-
return MonoCustomAttrs.GetCustomAttributes (this, inherit);
195+
// It is documented that the inherit flag is ignored.
196+
// Attribute.GetCustomAttributes is to be used to search
197+
// inheritance chain.
198+
return MonoCustomAttrs.GetCustomAttributes (this, false);
196199
}
197200

198201
public
199202
override
200203
object[] GetCustomAttributes (Type attributeType, bool inherit)
201204
{
202-
return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
205+
// It is documented that the inherit flag is ignored.
206+
// Attribute.GetCustomAttributes is to be used to search
207+
// inheritance chain.
208+
return MonoCustomAttrs.GetCustomAttributes (this, attributeType, false);
203209
}
204210

205211
internal object GetDefaultValueImpl (ParameterInfo pinfo)

mcs/class/corlib/System/MonoCustomAttrs.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ internal static object[] GetCustomAttributes (ICustomAttributeProvider obj, Type
183183
if (inherit && GetBase (obj) == null)
184184
inherit = false;
185185

186-
if (obj is RuntimeParameterInfo)
187-
inherit = false;
188-
189186
// if AttributeType is sealed, and Inherited is set to false, then
190187
// there's no use in scanning base types
191188
if ((attributeType != null && attributeType.IsSealed) && inherit) {

0 commit comments

Comments
 (0)