Skip to content

Inherited internal properties are not returned via reflection on net6.0-android #7445

@dominik-weber

Description

@dominik-weber

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

VS 2022 17.3.5

Description

Type.GetRuntimeProperties(), Type.GetProperties(..), etc. don't return internal properties that are defined in a base class of the given type when running on net6.0-android. When I run the same code as a net6.0 console application or a Xamarin.Android app, the properties are correctly returned.

Steps to Reproduce

  1. Create a new .NET 6 Android application. Add the code below and run the Test.Execute method.
    public static class Test
    {
        public static void Execute()
        {
            var obj = new Class2();
            var properties = obj.GetType().GetRuntimeProperties();

            var names = properties.Select(x => x.Name).ToList();
            Console.WriteLine($"Found {names.Count} properties: {string.Join(", ", names)}");

            // Xamarin.Android: Found 2 properties: TestProp2, TestProp1
            // net6.0:          Found 2 properties: TestProp2, TestProp1
            // net6.0-android:  Found 1 properties: TestProp2
        }
    }

    public class Class1
    {
        internal int TestProp1 { get; set; }
    }

    public class Class2 : Class1
    {
        internal int TestProp2 { get; set; }
    }

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: Mono RuntimeMono-related issues: BCL bugs, AOT issues, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions