Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile'#12203
Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile'#12203iSazonov merged 2 commits intoPowerShell:masterfrom
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.
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.
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.