Repository navigation
Re-export nested assembly module members - #28114
Open
Jordan Borean (jborean93) wants to merge 1 commit into
Open
Jordan Borean (jborean93) wants to merge 1 commit into
Jordan Borean (jborean93) wants to merge 1 commit into
Conversation
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.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Jordan Borean (jborean93)
September 27, 2026 18:51
View session
Contributor
There was a problem hiding this comment.
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.LoadFromandAssemblyLoadContext.
| 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.
Contributor
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 expectedThis behaviour matches what
Import-Module $pathalready 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
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header