Skip to content

Commit

Permalink
[release/7.0-staging] dotnet#76881 internal properties in GetRuntimeP…
Browse files Browse the repository at this point in the history
…roperties are not shown (dotnet#87175)

dotnet#76881 Add internal properties in GetRuntimeProperties
---------
Co-authored-by: Meri Khamoyan <[email protected]>
  • Loading branch information
github-actions[bot] authored Jun 30, 2023
1 parent d5ad559 commit 2251e9f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
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
3 changes: 2 additions & 1 deletion src/libraries/System.Reflection/tests/AssemblyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void ExportedTypes(Type type, bool expected)

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "entry assembly won't be xunit.console on browser")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/36892", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/36892", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst | TestPlatforms.Android)]
public void GetEntryAssembly()
{
Assert.NotNull(Assembly.GetEntryAssembly());
Expand Down Expand Up @@ -872,6 +872,7 @@ public static void AssemblyGetForwardedTypes()

[Fact]
[ActiveIssue("https://github.com/dotnet/runtimelab/issues/155", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
[ActiveIssue("https://github.com/dotnet/runtimelab/issues/77821", TestPlatforms.Android)]
public static void AssemblyGetForwardedTypesLoadFailure()
{
Assembly a = typeof(TypeInForwardedAssembly).Assembly;
Expand Down
1 change: 0 additions & 1 deletion src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,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 @@ -4032,8 +4032,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 @@ -4072,11 +4070,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 @@ -4106,8 +4102,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;
goto handle_parent;
}

Expand Down

0 comments on commit 2251e9f

Please sign in to comment.