Skip to content

Conversation

AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Aug 13, 2025

On CoreCLR, the Reflection API was preemptively
filtering out members with the same name and signature.
This means that hidden private members in C# using
the new keyword in derived classes can make public
members in base classes inaccessible.

Add tests for properties and methods.

Fixes #28056
Fixes #98533
Fixes #118677

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a CoreCLR reflection issue where hidden private/internal members in derived classes can make public members in base classes inaccessible through reflection APIs. The fix removes duplicate filtering logic that was incorrectly filtering out legitimate public members when a derived class uses the new keyword to hide them.

  • Removes duplicate property filtering logic in CoreCLR's RuntimeType class
  • Adds comprehensive tests for both property and method reflection scenarios with hidden members
  • Ensures public base class members remain accessible via reflection even when hidden by derived class members

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs Removes duplicate filtering logic that prevented access to hidden public properties
src/libraries/System.Runtime/tests/System.Reflection.Tests/PropertyInfoTests.cs Adds test cases and test classes to verify hidden public properties remain accessible
src/libraries/System.Runtime/tests/System.Reflection.Tests/MethodInfoTests.cs Adds test cases and test classes to verify hidden public methods remain accessible

@AaronRobinsonMSFT AaronRobinsonMSFT added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Aug 13, 2025
@dotnet-policy-service dotnet-policy-service bot added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Aug 13, 2025
Copy link
Contributor

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET Breaking Change Notification DL.

Tagging @dotnet/compat for awareness of the breaking change.

This is a narrow change to address a user
reported issue on System.Runtime and the
common implementation detail, System.RuntimeType.
@AaronRobinsonMSFT
Copy link
Member Author

I'm closing this issue for now. It is going to require additional discussion for fixes to the underlying issue with Reflection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Reflection breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet
Projects
None yet
2 participants