Skip to content

Conversation

@daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Mar 25, 2020

PR Summary

Fix #12052

Fix a regression in PS 7.0 introduced by #11088
PowerShell should discover assemblies loaded by Assembly.Load(byte[]) and Assembly.LoadFile as in prior versions.

Assemblies loaded by Assembly.Load(byte[]) and Assembly.LoadFile are placed in special AssemblyLoadContext instances of the type System.Runtime.Loader.IndividualAssemblyLoadContext. PowerShell should return assemblies from those load context instances.

Also include a minor change to ignore the .ionide folders, which are auto-generated by VS Code C# extension to hold symbol caches.

/cc @SeeminglyScience

PR Checklist

@ghost ghost assigned anmenaga Mar 25, 2020
@daxian-dbw daxian-dbw requested review from iSazonov and rjmholt March 25, 2020 18:36
@daxian-dbw daxian-dbw assigned iSazonov and unassigned anmenaga Mar 25, 2020
@daxian-dbw daxian-dbw added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Mar 25, 2020
@daxian-dbw daxian-dbw added this to the 7.0.x-Servicing-Consider milestone Mar 25, 2020
/// </summary>
private static IEnumerable<Assembly> GetPSVisibleAssemblies()
{
const string IndividualAssemblyLoadContext = "System.Runtime.Loader.IndividualAssemblyLoadContext";
Copy link
Collaborator

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.

Copy link
Member Author

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.

@iSazonov iSazonov merged commit e741dc5 into PowerShell:master Mar 28, 2020
@iSazonov iSazonov changed the title Fix regression: pwsh should discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile' Discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile' Mar 28, 2020
@daxian-dbw daxian-dbw deleted the assembly branch March 28, 2020 18:09
@TravisEz13 TravisEz13 modified the milestones: 7.0.1-approved, 7.0.1 Apr 20, 2020
@ghost
Copy link

ghost commented Apr 23, 2020

🎉v7.1.0-preview.2 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented May 14, 2020

🎉v7.0.1 has been released which incorporates this pull request.:tada:

Handy links:

silijon pushed a commit to SkyKick/PowerShell that referenced this pull request Jul 2, 2020
…oadFile' (PowerShell#12203)

* Fix regression: pwsh should discover assemblies loaded by 'Assembly.Load(byte[])' and 'Assembly.LoadFile'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Powershell 7.x : Cannot use type from dll (built for netstandard2.0)

9 participants