-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Type.GetProperties does not return non-public properties from inherited type on Android #86149
Comments
This seems like a runtime issue, not something specific to the UI Framework. @jonathanpeppers What do you think? Should it be transferred? |
Yes, this is correct I can move it to dotnet/runtime. |
Tagging subscribers to this area: @dotnet/area-system-reflection Issue DetailsDescriptionThis may be bug of some underlying framework/runtime, possibly Mono. If this is not appropriate repo to file this issue in, please direct me to correct one. During upgrade from Xamarin.Forms to MAUI we discovered odd bug. Reflection after upgrade is not behaving the same as before. When getting all properties for a type, including the non-public ones, the protected properties declared in inherited type are not returned. As described in the repro steps as well as in linked repro project, when declaring type Foo, that inherits from type Bar, the properties returned by Issue is experienced only in Android, when the same app is run in Windows, it returns expected results. Steps to Reproduce
public class Foo : Bar
{
public string PublicFromFoo { get; set; }
private string PrivateFromFoo { get; set; }
}
public class Bar
{
public string PublicFromBar { get; set; }
protected string ProtectedFromBar { get; set; }
}
Expected result: properties is array with Length 4 Link to public reproduction project repositoryhttps://github.com/Ropack/MauiReflectionBugRepro Version with bug7.0 (current) Last version that worked wellUnknown/Other Affected platformsAndroid Affected platform versionsAndroid 11 Did you find any workaround?No response Relevant log outputNo response
|
/cc @steveisok |
@Ropack thank you for providing a detailed repro steps. I have managed to reproduce the issue with: Would you mind trying it yourself with .NET8? I will try to find which PR got it fixed and check if the fix is going to be backported to .NET7. |
@ivanpovazan sorry for a late reply. I can confirm that this is fixed in .net8.0, tried with |
No worries and thank you for the confirmation! |
Closing as the fix has been backported to .net7 via: #87175 |
Description
This may be bug of some underlying framework/runtime, possibly Mono. If this is not appropriate repo to file this issue in, please direct me to correct one.
During upgrade from Xamarin.Forms to MAUI we discovered odd bug. Reflection after upgrade is not behaving the same as before. When getting all properties for a type, including the non-public ones, the protected properties declared in inherited type are not returned.
As described in the repro steps as well as in linked repro project, when declaring type Foo, that inherits from type Bar, the properties returned by
GetProperties
method does not include non-public properties declared in Bar even though the BindingFlags specify that they should.Issue is experienced only in Android, when the same app is run in Windows, it returns expected results.
Steps to Reproduce
var properties = typeof(Foo).GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
`Expected result: properties is array with Length 4
Actual result: properties is array with Length 3
Link to public reproduction project repository
https://github.com/Ropack/MauiReflectionBugRepro
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 11
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: