-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Do not discover assemblies loaded by Assembly.LoadFile
#18047
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
Conversation
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
I'm not sure if we want to make this breaking change, given that it has been the way it works since PowerShell 6. |
|
I think it's better to keep the current behavior unchanged. For modules built against |
|
It seems general question is - should Engine use only default ALC for PowerShell's type resolution? Maybe it makes sense to make this configurable? |
It definitely needs to resolve types from assemblies loaded by Even though there is no report on |
PR Summary
For modules that target both Windows PowerShell and PowerShell Core, they are usually built against either
netstandard2.0, ornet462, so that one single set of assemblies can work on both .NET Framework and .NET Core.For those modules, the API
Assembly.LoadFileis usually used to load a dependency assembly into a separate load context when working in PowerShell Core to isolate the dependency, so as to avoid assembly loading conflicts with other modules. This usually happens when the dependency is commonly used by modules, such asNewtonsoft.JsonandYamlDotNet.Today, assemblies loaded by
Assembly.LoadFileare discoverable by PowerShell's type resolution, and this breaks the isolation those modules are looking for when usingAssembly.LoadFile. Since they are built againstnetstandard2.0andnet462, they cannot use theAssemblyLoadContextAPIs for creating a custom load context but have to depend onAssembly.LoadFilewhich loads an assembly in a separate assembly load context.This PR is a breaking change.
PR Context
Assemblies loaded by
Assembly.LoadFileare made discoverable by #12203.However, the original issues that PR was to address is just for assemblies loaded from memory by
Assembly.Load(byte[]), andAssembly.LoadFilewas never the ask.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.