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

Design entra-powershell with ALC bridge pattern for a more robust assembly load handling #1242

Open
AndersRask opened this issue Dec 3, 2024 · 1 comment
Labels
enhancement New feature or request P1 ToTriage

Comments

@AndersRask
Copy link

Describe the feature
People usually use not only one but several PowerShell modules, which often cause assembly conflicts depending on the order the modules were loaded or used.

Developers of a given module often "lives in a bubble" where everything inside the module works fine, but in real-life scenarios, where multiple modules from multiple providers are used, they might fall short due to assembly load design of the module.

Enter Assembly Load Contexts (ALCs). ALCs were introduced in .NET Core 1.0 to specifically address the need to load multiple versions of the same assembly into the same runtime.

ALC is the "new" way of loading assemblies in PowerShell 7, and should have better ways of handling multiple versions of the same assembly. There are a few samples in the code below that show how to avoid this breaking code into two modules and using the IModuleAssemblyInitializer to lazy load and undload assemblies into ALC.

https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/resolving-dependency-conflicts?view=powershell-7.3#more-robust-solutions

How will this feature enhance your project and further the project’s overall goals? Who will benefit from this feature (i.e. all users; the project team)?
Try and do a search on Az, MgGraph, PnP.PowerShell github issues lists or other foras. One of the most common issues with PowerShell modules are assembly conflicts (our new "dll-hell") due to the fact that a module loads a dll when a certain function is used, and depending on module versions and order the involved PowerShell modules was loaded, errors will occur.
ALC bridging pattern makes it possible to load multiple versions of the same assembly, hence minimizing the assembly conflicts and resulting in a more robust module and less frustrated users :)

Describe alternatives you've considered

Additional context

@SteveMutungi254
Copy link
Contributor

Acknowledged, @AndersRask. Thanks so much for the ACL recommendation! Our Engineering team will be looking into this as soon as possible. We’re excited to work towards interoperability that reflects real-world scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1 ToTriage
Projects
None yet
Development

No branches or pull requests

2 participants