include non-public accessors when resolving implementing properties - #90
Open
koenbeuk wants to merge 1 commit into
Open
include non-public accessors when resolving implementing properties#90koenbeuk wants to merge 1 commit into
koenbeuk wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates TypeExtensions.GetImplementingProperty to handle interface properties whose accessors are non-public (e.g., internal interface accessors), and adds a regression test to cover that scenario in the runtime test suite.
Changes:
- Include non-public accessors when selecting an interface property accessor for interface-map resolution.
- Add a test case for an interface property with a non-public accessor implemented explicitly.
- (Needed) Adjust accessor-kind detection so non-public getters don’t get misclassified as setters during implementing-property lookup.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/ExpressiveSharp/Extensions/TypeExtensions.cs |
Switches to GetAccessors(true) for interface properties; currently needs a follow-up fix to correctly identify getter vs setter for non-public accessors. |
tests/ExpressiveSharp.Tests/Extensions/TypeExtensionsTests.cs |
Adds a regression test for non-public interface accessors; currently needs a stronger assertion to ensure the concrete implementing property is returned. |
Suppressed comments (1)
src/ExpressiveSharp/Extensions/TypeExtensions.cs:129
GetImplementingPropertynow selects a non-public accessor viaGetAccessors(true)[0], but the laterpropertyInfo.GetMethod == accessorcheck only works for public getters (it will benullfor non-public get accessors). For interface properties with non-public getters this makes the code treat the accessor as a setter, causing the implementing property lookup to fail and returning the original interfacePropertyInfo. UseGetGetMethod(true)/GetSetMethod(true)to both pick the accessor and determine whether it is a getter vs setter.
var accessor = propertyInfo.GetAccessors(true)[0];
var implementingAccessor = derivedType.GetImplementingMethod(accessor);
if (implementingAccessor == accessor)
{
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+131
to
+134
| var result = typeof(HiddenImpl).GetConcreteProperty(interfaceProperty); | ||
|
|
||
| Assert.IsNotNull(result); | ||
| } |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.