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

Switch to AssemblyLoadContext for assembly retrival #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shabbafru
Copy link

With .NET (core) a new mechanism for assembly loading/plugin discovery has been introduced: AssemblyLoadContext. It allows to have multiple contexts and each can load and unload assemblies. The problem is that they are all (from all AssemblyLoadContexts) returned by AppDomain.CurrentDomain.GetAssemblies(). This is problematic as AssemblyLoadContext.Unload() does not immediately unload assemblies but marks them for removal by the GC. GetAssemblies() therefore returns assemblies that might get GC'ed at a later point in time.
Additionally, having the same assembly loaded multiple times breaks Attic and leads to not finding any transformers at all and as a result prevents saving/loading of files.

Therefore, AppDomain.CurrentDomain.GetAssemblies() is replaced with AssemblyLoadContext.Default.Assemblies in this PR to only return the assemblies from the default context. AssemblyLoadContext.Default.Assemblies only works with .NET, therefore the project was upgraded to .NET 8 and support for netstandard2.0 and net472 was dropped.

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