Skip to content

Commit 7b7d56f

Browse files
authored
Remove object[] allocation from CustomAttribute.AddCustomAttributes (#87902)
1 parent 2aa0c9b commit 7b7d56f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,25 +1241,25 @@ private static void AddCustomAttributes(
12411241
}
12421242
}
12431243

1244-
PropertyInfo? property = type is null ?
1244+
RuntimePropertyInfo? property = (RuntimePropertyInfo?)(type is null ?
12451245
attributeType.GetProperty(name) :
1246-
attributeType.GetProperty(name, type, Type.EmptyTypes);
1246+
attributeType.GetProperty(name, type, Type.EmptyTypes));
12471247

12481248
// Did we get a valid property reference?
12491249
if (property is null)
12501250
{
12511251
throw new CustomAttributeFormatException(SR.Format(SR.RFLCT_InvalidPropFail, name));
12521252
}
12531253

1254-
MethodInfo setMethod = property.GetSetMethod(true)!;
1254+
RuntimeMethodInfo setMethod = property.GetSetMethod(true)!;
12551255

12561256
// Public properties may have non-public setter methods
12571257
if (!setMethod.IsPublic)
12581258
{
12591259
continue;
12601260
}
12611261

1262-
setMethod.Invoke(attribute, BindingFlags.Default, null, new object?[] { value }, null);
1262+
setMethod.InvokeOneParameter(attribute, BindingFlags.Default, null, value, null);
12631263
}
12641264
else
12651265
{

0 commit comments

Comments
 (0)