To repro the issue:
Add _ = ((EcmaType)_module.GetObject(_handle)).IsValueType to GetStaticDependencies of TypeDefinitionNode. Notice that iltrim now asserts/crashes.
This is because we need to provide two things for the type system to actually work - places where to resolve assemblies, and information about what assembly is the system module.
We need to set the ReferenceFilePaths to a string -> string dictionary that maps assembly simple name (basically, just file name without extension) to the file path of the assembly.
Once that's provided, we should also call SetSystemModule with the module that represents the CoreLib and defines System.Object.
To repro the issue: Add
_ = ((EcmaType)_module.GetObject(_handle)).IsValueType
toGetStaticDependencies
ofTypeDefinitionNode
. Notice that iltrim now asserts/crashes.This is because we need to provide two things for the type system to actually work - places where to resolve assemblies, and information about what assembly is the system module.
This should be done somewhere around here:
https://github.com/MichalStrehovsky/iltrim/blob/8659658fc189b91fbcefc625da88677c41d0d448/src/coreclr/tools/ILTrim/ILTrim/Trimmer.cs#L25-L32
We need to set the ReferenceFilePaths to a string -> string dictionary that maps assembly simple name (basically, just file name without extension) to the file path of the assembly.
Once that's provided, we should also call
SetSystemModule
with the module that represents the CoreLib and defines System.Object.