-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Allow empty prefix string in 'Import-Module -Prefix' to override default prefix in manifest #20409
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
Conversation
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
The engine working group reviewed this and approved the idea. |
@MartinGC94 Please resolve merge conflicts. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
Outdated
Show resolved
Hide resolved
…se.cs Co-authored-by: Staffan Gustafsson <staffangu@outlook.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Ilya <darpa@yandex.ru>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@iSazonov @MartinGC94 thank you! |
Starting in 7.6.0-preview.4 a default command prefix to be exported from a module gets ignored. At least we can override the default prefix using the Import-Module’s -Prefix parameter. This unexpected behaviour might be related to the merging of this pull request. |
@wi-fr Can you elaborate on what the unexpected behavior is? If I create a module like this:
Then if I run |
@MartinGC94 It seems we skipped that BasePrefix is initialized with string.Empty in line 120. |
Got the same issue since the update and was wondering what is going on. I didn't see a bug report opened though. |
Had a quick look at the code: string resolvedCommandPrefix = BasePrefix ?? defaultCommandPrefix ?? string.Empty; This is not a good replacement for So, I'd suggest either not initialize it with |
@totkeks Please open new issue with repro steps.
BasePrefix is used in another code branches. So it is more safe to revert to IsNullOrEmpty check. Although it is necessary to check that other code branches will work correctly. |
…ide default prefix in manifest (PowerShell#20409)" This reverts commit b8ed5be.
PR Summary
Updates the check for the user specified prefix so it allows empty strings, which can then be used to override the prefix specified in a module manifest like so:
Import-Module MyPrefixedModule -Prefix ""
Previously, if you provided an empty string it would be silently ignored.
PR Context
Fixes #16936
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).