-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor runtime-specific logic out of CustomAttributeData #55870
Conversation
CustomAttributeData is meant to be abstract base class of reflection object model. Move the runtime-specific part into a separate RuntimeCustomAttributeData type.
231025c
to
c1bb326
Compare
bool first = true; | ||
|
||
int count = ConstructorArguments.Count; | ||
IList<CustomAttributeTypedArgument> constructorArguments = ConstructorArguments; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache in locals to avoid redundant interface calls.
@@ -79,6 +87,11 @@ public override string ToString() | |||
|
|||
#region Public Members | |||
public virtual Type AttributeType => Constructor.DeclaringType!; | |||
|
|||
// Expected to be overriden | |||
public virtual ConstructorInfo Constructor => null!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the existing Mono behavior. The existing CoreCLR behavior is to throw NullReferenceException in some of these.
src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs
Show resolved
Hide resolved
74a6760
to
00aa646
Compare
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeNamedArgument.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeNamedArgument.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeNamedArgument.cs
Outdated
Show resolved
Hide resolved
…tomAttributeNamedArgument.cs Co-authored-by: Marek Safar <marek.safar@gmail.com>
CustomAttributeData is meant to be abstract base class of reflection object model. Move the runtime-specific part
into a separate RuntimeCustomAttributeData type.
This avoids bugs like #55726 by construction.