Skip to content

MonoCecilTempGenerator - only check path if assembly not already loaded #143

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

K0lb3
Copy link

@K0lb3 K0lb3 commented Jun 2, 2025

This PR slightly changes the behavior of MonoCecilTempGenerator.GetTemplateField.
So far this function checked if the given assembly string corresponds to an existing .dll within the managed path.
This effectively prevents adding assemblies in other ways, e.g. from memory, or from different paths.

With this PR, the function first checks if the given assembly string corresponds to an already loaded assembly, and only if not, tries to load it from a file within the managed path.

@K0lb3
Copy link
Author

K0lb3 commented Jun 2, 2025

I guess that alternatively it would be enough to simply remove the File.Exists(assemblyPath) path check in combination with wrapping the Read function in a try/catch.
This would also allow to cover the case of the assembly in question producing an error on being read by AssemblyDefinition.ReadAssembly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant