-
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 GetCustomAttributesData routines #55726
Conversation
@uweigand maybe we can pull the common bit of CustomAttributeData into a new file under src/libraries and share it between the two runtimes? runtime/src/coreclr/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs Lines 15 to 49 in bd9d4e0
|
I guess so ... but is it worthwhile doing this now, just for these trivial bits? I think in the end most of the custom attribute logic should be shareable between Mono and CoreCLR, but that will need more cleanup. |
Yea that's exactly my question. 😄 I guess one reason to do it on a small relatively trivial PR is that it would be pretty easy to make sense of the diff, compared to something deeper. But it's up to you. I certainly don't have a problem with the PR as is.
Yea I think compared to elsewhere in Reflection the differences here are more incidental, so we should be able to converge. |
I'd prefer to go with the PR as-is for now. I can look into what can be merged here a bit later (probably best after .NET 6 has branched). |
src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs
Outdated
Show resolved
Hide resolved
New version that moves common bits to the shared location. This includes moving |
Thanks! |
src/mono/System.Private.CoreLib/src/System/Reflection/CustomAttributeData.cs
Show resolved
Hide resolved
* Merge common bits of Mono and CoreCLR CustomAttributeData implementation * Have CustomAttributeData.GetCustomAttributes call target.GetCustomAttributesData to allow derived classes to override the latter (like in CoreCLR) * Use Constructor, ConstructorArguments, and NamedArguments in internal routines to allow them being overridden (like with CoreCLR).
Hello @marek-safar! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
to allow derived classes to override the latter (like in CoreCLR)
System.Text.Json.SourceGeneration.Tests
are currently failing when using a Mono-based dotnet runtime. This is because the source-generation logic overridesGetCustomAttributesData
in various derived classes, and expects this to be called from the genericCustomAttributeData.GetCustomAttributes
routine. This works in CoreCLR, because thereCustomAttributeData.GetCustomAttributes
calls target.GetCustomAttributesData
which calls back toCustomAttributeData.GetCustomAttributesInternal
, which does the actual work. However, the current Mono code has instead target.GetCustomAttributesData
calling toCustomAttributeData.GetCustomAttributes
, which does the actual work.Fix this by introducing
GetCustomAttributesInternal
routines and re-arranging the call sequence to match CoreCLR.