未验证 提交 d96073ad 编写于 作者: M Michal Strehovský 提交者: GitHub

Allow mismatched assembly name and file name (#67220)

`GetModuleForSimpleName` checks that the assembly name matches the file name we just opened and throws if it doesn't. Avoid this API for the `--root` command line argument.

This is needed because we have 400+ Pri-0 tests in IL where the assembly name doesn't match the file name of the test.
上级 1e00c6f5
......@@ -135,6 +135,8 @@ public EcmaModule GetMetadataOnlyModuleFromPath(string filePath)
private EcmaModule GetOrAddModuleFromPath(string filePath, bool useForBinding)
{
filePath = Path.GetFullPath(filePath);
// This method is not expected to be called frequently. Linear search is acceptable.
foreach (var entry in ModuleHashtable.Enumerator.Get(_moduleHashtable))
{
......@@ -182,6 +184,8 @@ public static unsafe PEReader OpenPEFile(string filePath, out MemoryMappedViewAc
private EcmaModule AddModule(string filePath, string expectedSimpleName, bool useForBinding, ModuleData oldModuleData = null)
{
filePath = Path.GetFullPath(filePath);
PEReader peReader = null;
MemoryMappedViewAccessor mappedViewAccessor = null;
PdbSymbolReader pdbReader = null;
......
......@@ -607,7 +607,6 @@ private int Run(string[] args)
}
}
_rootedAssemblies = new List<string>(_rootedAssemblies.Select(a => ILLinkify(a)));
_conditionallyRootedAssemblies = new List<string>(_conditionallyRootedAssemblies.Select(a => ILLinkify(a)));
_trimmedAssemblies = new List<string>(_trimmedAssemblies.Select(a => ILLinkify(a)));
......@@ -626,10 +625,16 @@ static string ILLinkify(string rootedAssembly)
// Root whatever assemblies were specified on the command line
foreach (var rootedAssembly in _rootedAssemblies)
{
// For compatibility with IL Linker, the parameter could be a file name or an assembly name.
// This is the logic IL Linker uses to decide how to interpret the string. Really.
EcmaModule module = File.Exists(rootedAssembly)
? typeSystemContext.GetModuleFromPath(rootedAssembly)
: typeSystemContext.GetModuleForSimpleName(rootedAssembly);
// We only root the module type. The rest will fall out because we treat _rootedAssemblies
// same as conditionally rooted ones and here we're fulfilling the condition ("something is used").
compilationRoots.Add(
new GenericRootProvider<ModuleDesc>(typeSystemContext.GetModuleForSimpleName(rootedAssembly),
new GenericRootProvider<ModuleDesc>(module,
(ModuleDesc module, IRootingServiceProvider rooter) => rooter.AddCompilationRoot(module.GetGlobalModuleType(), "Command line root")));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册