Skip to content

Fix Export-ModuleMember bug for scriptblocks having no context #8363

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

Merged
merged 3 commits into from
Nov 30, 2018
Merged

Fix Export-ModuleMember bug for scriptblocks having no context #8363

merged 3 commits into from
Nov 30, 2018

Conversation

PaulHigin
Copy link
Contributor

PR Summary

Export-ModuleMember cmdlet throws an exception if module functions are exported across language boundaries (Windows only). But a scriptblock LanguageMode property can be null if the scriptblock is created without a PowerShell context, and this can happen through the PowerShell API called from C#. In this case Export-ModuleMember throws erroneously when no language mode restrictions are in play.

Fix is to check if LanguageMode is null before comparing context and scriptblock language modes.

PR Checklist

@PaulHigin PaulHigin added Issue-Bug Issue has been identified as a bug in the product OS-Windows WG-Cmdlets-Core cmdlets in the Microsoft.PowerShell.Core module CL-Engine Indicates that a PR should be marked as an engine change in the Change Log labels Nov 29, 2018
@PaulHigin PaulHigin requested a review from TravisEz13 November 29, 2018 23:43
@TravisEz13 TravisEz13 merged commit 743a964 into PowerShell:master Nov 30, 2018
@PaulHigin PaulHigin deleted the fix_exportmodulemember_nocontext branch November 30, 2018 20:42
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 Issue-Bug Issue has been identified as a bug in the product OS-Windows WG-Cmdlets-Core cmdlets in the Microsoft.PowerShell.Core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants