Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ModuleReaderParameters::WorkingDirectory for assembly resolution #438

Closed
Washi1337 opened this issue Jun 2, 2023 · 0 comments · Fixed by #441
Closed

Use ModuleReaderParameters::WorkingDirectory for assembly resolution #438

Washi1337 opened this issue Jun 2, 2023 · 0 comments · Fixed by #441
Labels
dotnet Issues related to AsmResolver.DotNet enhancement
Milestone

Comments

@Washi1337
Copy link
Owner

Problem Description

The implementation of AssemblyResolverBase uses its IList<string> SearchDirectories property to probe for assemblies matching the name provided by an AssemblyDescriptor. This search directories property is populated automatically with string ModuleDefinition::FilePath if it is not null or empty.

The FilePath property is only set when using ModuleDefinition.FromFile, but not when using any of the other FromXXX methods. This means the default assembly resolver does not know anything about the file location of the input binary, and thus also not any of its dependencies.

Proposal

Populate AssemblyResolverBase::SearchDirectories with ModuleReaderParameters::WorkingDirectory when not-null and/or are read from a source different than a file on the disk.

Alternatives

The user can manually add the working directory to the current AssemblyResolverBase instance. This, however, is a bit hidden behind ModuleDefinition::MetadataResolver::AssemblyResolver, and requires up-casting since AssemblyResolverBase is not the type that is directly exposed, making this process unintuitive.

Additional Context

string WorkingDirectory property is currently only used by the DefaultNetModuleResolver to resolve sub-modules of multi-module assemblies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet Issues related to AsmResolver.DotNet enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant