Visitar URL original
Re-export nested assembly module members by jborean93 · Pull Request #28114 · PowerShell/PowerShell · GitHub
Skip to content

Re-export nested assembly module members - #28114

Open
Jordan Borean (jborean93) wants to merge 1 commit into
PowerShell:masterfrom
jborean93:nested-asm-module
Open

Jordan Borean (jborean93) wants to merge 1 commit into
PowerShell:masterfrom
jborean93:nested-asm-module

Conversation

@jborean93

Copy link
Copy Markdown
Collaborator

PR Summary

Re-exports the cmdlets and aliases present in a binary module assembly when it is loaded as a nested module using Import-Module -Assembly .... Previously the cmdlets and aliases would not be exported in the parent module when imported for a second time due to the module being in the global cache. Now the global cache is still used but the members will now be re-exported as expected

This behaviour matches what Import-Module $path already does for a script module that is already loaded.

PR Context

Fixes: #20710

I thought this only affected ALC based modules but it turns out it also affected any module with a nested assembly containing cmdlets/aliases. This fix solves both at the same time.

PR Checklist

Re-exports the cmdlets and aliases present in a binary module assembly
when it is loaded as a nested module using `Import-Module -Assembly
...`. Previously the cmdlets and aliases would not be exported in the
parent module when imported for a second time due to the module being in
the global cache. Now the global cache is still used but the members
will now be re-exported as expected.
Copilot AI lite review requested due to automatic review settings September 27, 2026 18:51
@jborean93
Jordan Borean (jborean93) requested a review from a team as a code owner September 27, 2026 18:51
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The ALC regression test does not reuse the original assembly, so it does not validate the reported same-assembly scenario.

Review effort: Lite
Findings: None

What changed in this PR

Re-exports cached binary nested-module cmdlets and aliases during re-imports.

Changes:

  • Re-imports cached assembly members into the current session.
  • Adds coverage for Assembly.LoadFrom and AssemblyLoadContext.
File Description
test/​powershell/​Modules/​Microsoft.PowerShell.Core/​Import-Module.Tests.ps1 Tests cmdlet and alias exports across re-imports.
src/​System.Management.Automation/​engine/​Modules/​ImportModuleCommand.cs Re-exports cached assembly module members.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Oct 5, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module Assembly Load Context has no ExportedCommands on 2nd import

2 participants