Skip to content

Commit 5be20e8

Browse files
jkoritzinskydirecthex
authored andcommitted
Add support for nested types in the corelib.h parser for rooting descriptors (#105432)
1 parent 88a8796 commit 5be20e8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/coreclr/vm/corelib.h

-7
Original file line numberDiff line numberDiff line change
@@ -1123,15 +1123,10 @@ DEFINE_METHOD(UTF8STRINGMARSHALLER, CONVERT_TO_MANAGED, ConvertToManaged, SM_Ptr
11231123
DEFINE_METHOD(UTF8STRINGMARSHALLER, CONVERT_TO_UNMANAGED, ConvertToUnmanaged, SM_Str_RetPtrByte)
11241124
DEFINE_METHOD(UTF8STRINGMARSHALLER, FREE, Free, SM_PtrByte_RetVoid)
11251125

1126-
// The generator for the ILLink XML doesn't understand inner classes so generation
1127-
// needs to skip the following type.
1128-
// See https://github.com/dotnet/runtime/issues/71847
1129-
#ifndef FOR_ILLINK
11301126
DEFINE_CLASS(UTF8STRINGMARSHALLER_IN, Marshalling, Utf8StringMarshaller+ManagedToUnmanagedIn)
11311127
DEFINE_METHOD(UTF8STRINGMARSHALLER_IN, FROM_MANAGED, FromManaged, IM_Str_SpanOfByte_RetVoid)
11321128
DEFINE_METHOD(UTF8STRINGMARSHALLER_IN, TO_UNMANAGED, ToUnmanaged, IM_RetPtrByte)
11331129
DEFINE_METHOD(UTF8STRINGMARSHALLER_IN, FREE, Free, IM_RetVoid)
1134-
#endif // FOR_ILLINK
11351130

11361131
DEFINE_CLASS(UTF8BUFFERMARSHALER, StubHelpers, UTF8BufferMarshaler)
11371132
DEFINE_METHOD(UTF8BUFFERMARSHALER, CONVERT_TO_NATIVE, ConvertToNative, NoSig)
@@ -1180,9 +1175,7 @@ DEFINE_CLASS(EXCEPTIONSERVICES_INTERNALCALLS, ExceptionServices, InternalCalls)
11801175
DEFINE_CLASS(STACKFRAMEITERATOR, Runtime, StackFrameIterator)
11811176
#endif // FEATURE_EH_FUNCLETS
11821177

1183-
#ifndef FOR_ILLINK
11841178
DEFINE_CLASS(EXINFO, Runtime, EH+ExInfo)
1185-
#endif // FOR_ILLINK
11861179

11871180
DEFINE_CLASS_U(System, GCMemoryInfoData, GCMemoryInfoData)
11881181
DEFINE_FIELD_U(_highMemoryLoadThresholdBytes, GCMemoryInfoData, highMemLoadThresholdBytes)

src/tools/illink/src/ILLink.Tasks/CreateRuntimeRootDescriptorFile.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,10 @@ string GetFullClassName (string classNamespace, string className)
471471
Log.LogError ($"Unknown namespace '{classNamespace}'.");
472472
}
473473

474-
return namespaceDictionary[classNamespace] + "." + className;
474+
// Convert from the System.Reflection/CoreCLR nested type name format to the IL/Cecil format.
475+
string classNameWithCecilNestedFormat = className.Replace ('+', '/');
476+
477+
return namespaceDictionary[classNamespace] + "." + classNameWithCecilNestedFormat;
475478
}
476479

477480
void InitializeDefineConstants ()

src/tools/illink/test/ILLink.Tasks.Tests/CreateRuntimeRootDescriptorFileTests.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public void TestCoreLibClassGen ()
3939
"#endif // FEATURE_BOTH",
4040
"#if FOR_ILLINK",
4141
"DEFINE_METHOD(TESTCLASS, TESTMETHODFORILLINK, TestMethodForILLink, 5)",
42-
"#endif"
42+
"#endif",
43+
"DEFINE_CLASS(NESTEDTESTCLASS, TestNS, TestClass+Nested)",
44+
"DEFINE_METHOD(NESTEDTESTCLASS, TESTMETHOD, TestMethod, 0)"
4345
});
4446

4547
File.WriteAllText ("namespace.h",
@@ -90,6 +92,8 @@ public void TestCoreLibClassGen ()
9092
new XElement ("method", new XAttribute ("name", "TestMethodIfNotBoth")),
9193
new XElement ("method", new XAttribute ("name", "TestMethodIfNotBothForILLink")),
9294
new XElement ("method", new XAttribute ("name", "TestMethodForILLink"))),
95+
new XElement ("type", new XAttribute("fullname", "TestNS.TestClass/Nested"),
96+
new XElement ("method", new XAttribute("name", "TestMethod"))),
9397
new XElement ("type", new XAttribute ("fullname", "TestNS.TestAlwaysException"),
9498
new XElement ("method", new XAttribute ("name", ".ctor"))),
9599
new XElement ("type", new XAttribute ("fullname", "TestNS.TestFeatureOnException"),

0 commit comments

Comments
 (0)