Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Fix adding '.WinModule' with every execution of Import-WinModule command if the module is from NeverClobberList #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions WindowsCompatibility/WindowsCompatibility.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,12 @@ function Import-WinModule
{
$module = Import-Module -Name $name -NoClobber @importModuleParameters
# Hack using private reflection to keep the proxy module from shadowing the real module.
$null = [PSModuleInfo].
GetMethod('SetName',[System.Reflection.BindingFlags]'Instance, NonPublic').
Invoke($module, @($module.Name + '.WinModule'))
if (-not $module.Name.EndsWith('.WinModule', [System.StringComparison]::InvariantCulture))
{
$null = [PSModuleInfo].
GetMethod('SetName',[System.Reflection.BindingFlags]'Instance, NonPublic').
Invoke($module, @($module.Name + '.WinModule'))
}
if($PassThru.IsPresent)
{
$module
Expand Down