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

feat: load configuration from assembly if present #432

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jshield
Copy link

@jshield jshield commented Apr 12, 2023

implements a version of #431

}
File.Copy(configurationAssemblyPath, copiedAssembly);
configurationAssemblyPath = copiedAssembly;
_configurationAssembly = Assembly.LoadFile(configurationAssemblyPath);
Copy link
Member

@josteink josteink Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding of things, Assembly.LoadFile actually caches the loaded assembly.

This would mean that compiling a new config and doing a workspacer reload (with the current code) wont actually load the new configuration.

Isn't that a bit counter-intuitive?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah good point I should probably create a new AssemblyLoadContext, and dispose/create anew.
I don't tend to use reload tbh as I am usually running it with a debugger attached, and actively making code changes.

I was under the impression that while it is indeed cached it keeps a lock on the assembly file on disk, I noticed that it would remain locked when I was running in release mode, perhaps I should read the assembly into a memory stream and load it from there instead of doing the copy to disk

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't tend to use reload tbh as I am usually running it with a debugger attached, and actively making code changes

In general, I think when making a config it's common to try different things interactively until you find what works. It would be nice to be able to support that flow.

perhaps I should read the assembly into a memory stream and load it from there instead of doing the copy to disk

That's probably a simpler approach, yeah.

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.

None yet

2 participants