Skip to content
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

Inconsistent GetRuntimeProperties() Behavior #28056

Closed
Tracked by #44655
mikernet opened this issue Dec 5, 2018 · 9 comments
Closed
Tracked by #44655

Inconsistent GetRuntimeProperties() Behavior #28056

mikernet opened this issue Dec 5, 2018 · 9 comments
Labels
area-System.Reflection breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. bug needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity
Milestone

Comments

@mikernet
Copy link
Contributor

mikernet commented Dec 5, 2018

In the following example:

public class Test : TestBase
{	
	public new string Value { get; }
}

public class TestBase
{
	public string Value { get; }
}

If you call typeof(Test).GetRuntimeProperties() it only returns 1 property. If you change the property type in the Test class to something else (i.e. int) then it returns 2 properties. That behavior clearly doesn't make sense - I believe it should be returning both properties in both situations.

@MichalStrehovsky
Copy link
Member

Members on types generated by the C# compiler are marked hidebysig (stackoverflow) which means a derived type hides members inherited from the base if it has the same name and signature. GetRuntimeProperties simply respects those rules.

Would your expectation be different if the property was virtual?

public class Test : TestBase
{	
	public override string Value { get; }
}

public class TestBase
{
	public virtual string Value { get; }
}

@mikernet
Copy link
Contributor Author

mikernet commented Dec 5, 2018

My expectation is that it behaves the same way methods do. Right now it's very difficult to get all actual available properties on a type due to this "hiding", which isn't an issue with methods.

@mikernet
Copy link
Contributor Author

mikernet commented Dec 5, 2018

Methods also have hidebysig applied to them but hidden methods are returned when GetRuntimeMethods() is called.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 23, 2020
@steveharter
Copy link
Member

It does appear to be a bug - according to the doc inherited members should be included, and in this case these are two independent (non-virtual) methods so both should be returned.

We need to get approval for changing this as it could be classified as a "breaking change".

cc @GrabYourPitchforks

@GrabYourPitchforks GrabYourPitchforks added breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. bug and removed question Answer questions and provide assistance, not an issue with source code or documentation. untriaged New issue has not been triaged by the area owner labels Mar 19, 2020
@GrabYourPitchforks GrabYourPitchforks modified the milestones: Future, 5.0 Mar 19, 2020
@steveharter
Copy link
Member

Moving to future based on schedule + priority.

@buyaa-n
Copy link
Contributor

buyaa-n commented Jun 10, 2022

This bug been there since dotnet .NET Framework 1.0 so fixing this now could be quite breaking, as it is quite edge case scenario does not feel it is worth fixing.

@mikernet how important the fix for you? What is the scenario where you need this hidden parent property?

@buyaa-n buyaa-n added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jun 13, 2022
@ghost
Copy link

ghost commented Jun 13, 2022

This issue has been marked needs-author-action and may be missing some important information.

@ghost ghost added the no-recent-activity label Jun 27, 2022
@ghost
Copy link

ghost commented Jun 27, 2022

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

@ghost
Copy link

ghost commented Jul 12, 2022

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

@ghost ghost closed this as completed Jul 12, 2022
Repository owner moved this from Future to Done in Triage POD for Reflection, META, etc. Jul 12, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 11, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Reflection breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. bug needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity
Projects
No open projects
Development

No branches or pull requests

7 participants