Skip to content

System.Reflection.CustomAttributeFormatException thrown on a retrieval of derived attribute with overridden property getter #117584

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

pedrobsaila
Copy link
Contributor

@pedrobsaila pedrobsaila commented Jul 13, 2025

Fixes #110412

Sorry for the delay, I've been busy these last weeks

…l of derived attribute with overridden property getter
@@ -107,7 +107,7 @@ public static Attribute Instantiate(this CustomAttributeData cad)
for (; ; )
{
PropertyInfo? propertyInfo = walk.GetProperty(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly);
if (propertyInfo != null)
if (propertyInfo?.SetMethod is not null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this logic equivalent to the others, or just equivalent enough to pass the test? What corner cases are we missing in the test that necessitate the more complex logic elsewhere?

Copy link
Contributor Author

@pedrobsaila pedrobsaila Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was going to be off for a few days so I did rapidely just enough to pass the test and not let the PR hanging, I fixed it now. The missing condition stops the lookup in base classes early if someone used the new keyword to hide the property instead of overriding it.

@pedrobsaila pedrobsaila requested a review from marek-safar as a code owner July 20, 2025 14:41
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Reflection community-contribution Indicates that the PR has been added by a community member linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.Reflection.CustomAttributeFormatException thrown on a retrieval of derived attribute with overridden property getter
2 participants