Skip to content

Commit

Permalink
[mono] Fixed getting namespace names of array types. (#80426)
Browse files Browse the repository at this point in the history
* [mono] Fixed getting namespace names of array types. #42633

* [mono] Namespace getter icall of Type, code style.

* Reenabled TypeInfoTests.Namespace for Mono.

* [mono] Namespace for array types now works also for jagged arrays.

* [mono] Fixed Type.Namespace for enums.

* [mono] Fixed failing Microsoft.XmlSerializer.Generator.Tests.SgenCommandTest.

* Adding cases to TypeInfoTests.Namespace test.
  • Loading branch information
jandupej authored Jan 12, 2023
1 parent d4a59b3 commit 25e84d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libraries/System.Reflection/tests/TypeInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,8 @@ public void IsVisible(Type type, bool expected)
[InlineData(typeof(int), "System")]
[InlineData(typeof(TI_BaseClass[]), "System.Reflection.Tests")]
[InlineData(typeof(TI_BaseClass.PublicNestedClass1[]), "System.Reflection.Tests")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/42633", TestRuntimes.Mono)]
[InlineData(typeof(TI_BaseClass.PublicNestedClass1[][]), "System.Reflection.Tests")]
[InlineData(typeof(TI_Struct*), "System.Reflection.Tests")]
public void Namespace(Type type, string expected)
{
Assert.Equal(expected, type.GetTypeInfo().Namespace);
Expand Down Expand Up @@ -1864,6 +1865,10 @@ public class ClassWithExplicitStructLayout
public short y;
}
}
public struct TI_Struct
{
public int _field;
}
public class TI_BaseClass
{
static TI_BaseClass() { }
Expand Down
6 changes: 6 additions & 0 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,12 @@ ves_icall_RuntimeType_GetNamespace (MonoQCallTypeHandle type_handle, MonoObjectH
{
MonoType *type = type_handle.type;
MonoClass *klass = mono_class_from_mono_type_internal (type);

MonoClass *elem;
while (!m_class_is_enumtype (klass) &&
!mono_class_is_nullable (klass) &&
(klass != (elem = m_class_get_element_class (klass))))
klass = elem;

MonoClass *klass_nested_in;
while ((klass_nested_in = m_class_get_nested_in (klass)))
Expand Down

0 comments on commit 25e84d3

Please sign in to comment.