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

#76881 internal properties in GetRuntimeProperties are not shown #77169

Merged
merged 12 commits into from
Nov 3, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public void GetRuntimeProperties()
Assert.Contains("CanRead", propertyNames);
Assert.Contains("CanWrite", propertyNames);
Assert.Contains("CanSeek", propertyNames);

List<PropertyInfo> props = typeof(TestClass).GetRuntimeProperties().ToList();
Assert.Equal(2, props.Count);
}

[Fact]
Expand Down Expand Up @@ -359,6 +362,16 @@ private class TestDerived : TestBase
public override void Foo() { throw null; }
}

private class TestClassBase
{
internal int TestClassBaseProperty { get; set; }
}

private class TestClass : TestClassBase
{
internal int TestClassProperty { get; set; }
}

abstract class TestTypeBase : IDisposable
{
public abstract bool CanRead { get; }
Expand Down
1 change: 0 additions & 1 deletion src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.FileSystem.Watcher\tests\System.IO.FileSystem.Watcher.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.Ports\tests\System.IO.Ports.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Net.Quic\tests\FunctionalTests\System.Net.Quic.Functional.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection\tests\System.Reflection.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Serialization.Formatters\tests\System.Runtime.Serialization.Formatters.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Security.Cryptography.Algorithms\tests\System.Security.Cryptography.Algorithms.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Security.Cryptography.Csp\tests\System.Security.Cryptography.Csp.Tests.csproj" />
Expand Down
8 changes: 1 addition & 7 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -4057,8 +4057,6 @@ property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass)
GPtrArray*
ves_icall_RuntimeType_GetPropertiesByName_native (MonoQCallTypeHandle type_handle, gchar *propname, guint32 bflags, guint32 mlisttype, MonoError *error)
{
// Fetch non-public properties as well because they can hide public properties with the same name in base classes
bflags |= BFLAGS_NonPublic;
MonoType *type = type_handle.type;

if (m_type_is_byref (type))
Expand Down Expand Up @@ -4097,11 +4095,9 @@ ves_icall_RuntimeType_GetPropertiesByName_native (MonoQCallTypeHandle type_handl
(prop->set && ((prop->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC))) {
if (bflags & BFLAGS_Public)
match++;
} else if (bflags & BFLAGS_NonPublic) {
if (property_accessor_nonpublic(prop->get, startklass == klass) ||
} else if (property_accessor_nonpublic(prop->get, startklass == klass) ||
property_accessor_nonpublic(prop->set, startklass == klass)) {
match++;
}
}
if (!match)
continue;
Expand Down Expand Up @@ -4131,8 +4127,6 @@ ves_icall_RuntimeType_GetPropertiesByName_native (MonoQCallTypeHandle type_handl
g_hash_table_insert (properties, prop, prop);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass))) {
// BFLAGS_NonPublic should be excluded for base classes
bflags &= ~BFLAGS_NonPublic;
mdh1418 marked this conversation as resolved.
Show resolved Hide resolved
goto handle_parent;
}

Expand Down