-
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
[mono] Allow overriding CustomAttributeData accessors #55728
Conversation
* Use Constructor, ConstructorArguments, and NamedArguments in internal routines to allow them being overridden (like with CoreCLR).
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
public virtual Type AttributeType | ||
{ | ||
get { return ctorInfo.DeclaringType!; } | ||
get { return Constructor.DeclaringType!; } | ||
} |
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.
Please move the code to the shared location once it exists
@@ -152,30 +152,28 @@ public static IList<CustomAttributeData> GetCustomAttributes(ParameterInfo targe | |||
|
|||
public virtual Type AttributeType | |||
{ | |||
get { return ctorInfo.DeclaringType!; } | |||
get { return Constructor.DeclaringType!; } | |||
} | |||
|
|||
public override string ToString() |
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.
Please move the code to the shared location once it exists
Closing in favour of #55726 |
routines to allow them being overridden (like with CoreCLR).
Even after #55726,
System.Text.Json.SourceGeneration.Tests
are still failing when using a Mono-based dotnet runtime. This new problem is triggered because the source-generation logic provides a classCustomAttributeDataWrapper
derived fromCustomAttributeData
, which overrides the latter class' accessor routinesConstructor
,ConstructorArguments
, andNamedArguments
.This works with CoreCLR. However, with the current Mono implementation, other routines in
CustomAttributeData
now crash when called on an instance of the derived class, because they now access internal data members that have never been initialized. Fix this by instead calling the accessor routines like in CoreCLR.