-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile' #12203
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
…oad(byte[])' and 'Assembly.LoadFile'
| /// </summary> | ||
| private static IEnumerable<Assembly> GetPSVisibleAssemblies() | ||
| { | ||
| const string IndividualAssemblyLoadContext = "System.Runtime.Loader.IndividualAssemblyLoadContext"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is that IndividualAssemblyLoadContext is internal class and .Net is free to change the name.
Maybe more reliable to use an assembly context name ("Assembly.Load(byte[], ...)" and "Assembly.LoadFile({0})"). It is public contract and has one prefix Assembly.Load for both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any one can create a ALC instance with the name "Assembly.Load(byte[], ...)" or "Assembly.LoadFile(".
It's less reliable to depend on the name than the type. They can change the type name, but I think that possibility is very low, and we have test to catch the failure if the type name really changes.
|
🎉 Handy links: |
|
🎉 Handy links: |
…oadFile' (PowerShell#12203) * Fix regression: pwsh should discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile'
PR Summary
Fix #12052
Fix a regression in PS 7.0 introduced by #11088
PowerShell should discover assemblies loaded by
Assembly.Load(byte[])andAssembly.LoadFileas in prior versions.Assemblies loaded by
Assembly.Load(byte[])andAssembly.LoadFileare placed in specialAssemblyLoadContextinstances of the typeSystem.Runtime.Loader.IndividualAssemblyLoadContext. PowerShell should return assemblies from those load context instances.Also include a minor change to ignore the
.ionidefolders, which are auto-generated by VS Code C# extension to hold symbol caches./cc @SeeminglyScience
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.