-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
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
- Create new MAUI App
- Create two types with public and private properties, one inherited from another
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; }
}- In MainPage add code, that should get all properties from type Foo
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
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