GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — PS should try to load the assembly from file path first before loading from assemblyName by chunqingchen · Pull Request #4196 · PowerShell/PowerShell Conversation
|
|
Can you add a synthetic test case? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
0e8289f to
0f4d8e8
Compare
7fdb970 to
8091493
Compare
8091493 to
9bee62a
Compare
|
Steve Lee (@SteveL-MSFT) test is added |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
add newline at end of file
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
delete this empty line
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this is redundant from line 1329
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
if we were given a filepath and it doesn't exist, it doesn't seem like we should try to load something that happens to have the same name but different path
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
if we were given a filepath and it doesn't exist, it doesn't seem like we should try to load something that happens to have the same name but different path
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We are removing FullCLR code, so you should remove this since you're touching this file
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
be consistent with line 1338 and return loadedAssembly on line 1375
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
since the FullCLR code should be removed fixedName is only used within this if statement so move it inside the if statement
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
if you didn't successfully load the assembly, loadedAssembly should still be null, so I think you can get rid of the return null; statements and just return loadedAssembly at the end
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
make this else if
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
9bee62a to
5e09204
Compare
|
Steve Lee (@SteveL-MSFT) your comments are resolved. thank you |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Delete blank line
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
5e09204 to
963c997
Compare
|
Steve Lee (@SteveL-MSFT) your comment is resolved thanks |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This works only because the actual assembly name of the assembly generated from Add-Type is not the same as the file name.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, you can use Import-Module -Passthru and have the exact Assembly instance to validate.
We also want to avoid Should Be $true because the logs are less useful, so I'd like to see something like:
$assem = Import-Module -PassThru ... $assem.Location | Should Be $Path
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
resolved
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This change seems risky to me.
Add Jason Shirk (@lzybkr) to reviewers to get more inputs on this change. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You should make this a complete cmdlet that can be called. That is the real scenario that needs to be tested.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
963c997 to
f1947af
Compare
f1947af to
37aa739
Compare
…g from assemblyName
37aa739 to
cb1f0af
Compare
|
Dongbo Wang (@daxian-dbw) Loading assembly in GAC regardless user's given file path is exactly where the bug scenario comes from. Jason Shirk (@lzybkr) your comments are resolved. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| Describe "Import-Module for Binary Modules" -Tags 'CI' { | ||
|
|
||
| It "PS should try to load the assembly from file path first" { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this test validates the fix? It passes even without your fix.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
previously when system.automation.management is used loading error will be occured.
Now we have to check the actual cmdlet is loaded.
Resolved.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Chunqing Chen (@chunqingchen) please don't override existing commit history. Instead, push new commits to address comments. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Chunqing Chen (@chunqingchen) if we decide to take this breaking change, then it'd better go in as soon as possible so that we have more time to validate the potential impact. Can you please address the comments as soon as you get a chance? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
2902f5d to
ec9aa56
Compare
|
Dongbo Wang (@daxian-dbw) thanks for your comments. your comment is resolved. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ec9aa56 to
192de66
Compare
| "@ | ||
|
|
||
| Add-Type -TypeDefinition $src -OutputAssembly $TESTDRIVE\System.dll | ||
| $assembly = Import-Module $TESTDRIVE\System.dll -Force -PassThru |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Once the dll loaded, you will get errors when Pester tries to remove $TestDrive. I suggest you do import-module, $module.Path and Test-BinaryModuleCmdlet1 in a new powershell instance, and use the returned value for validation, so that there won't be any errors when Pester removes $TestDrive.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Plus, Import-Module -PassThru returns a PSModuleInfo object, so the value name should be $module instead of $assembly.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| #Ignore slash format difference under windows/Unix | ||
| $path = (Get-ChildItem $TESTDRIVE\System.dll).FullName | ||
| $assembly.Path | Should be $path |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think your actual intent is to use $module.ImplementingAssembly.Location.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Chunqing Chen (@chunqingchen) Thanks for the update, I left a few more comments. Please push new commits to address the commits without overriding the commit history. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry that maybe I wasn't clear on my comment. I suggest you use powershell.exe to gather the information you want to test. In that way, the generated system.dll won't be loaded into the current app domain and thus Pester can remove it properly later.
It should be something like this:
$results = powershell -noprofile -c "`$module = Import-Module $TESTDRIVE\System.dll -Pssthru; `$module.ImplementingAssembly.Location; Test-BinaryModuleCmdlet1"
$results[0] | Should Be $path
$results[1] | Should BeExactly "BinaryModuleCmdlet1 exported by the ModuleCmdlets module."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
c1086e2 to
3e99b29
Compare
|
Chunqing Chen (@chunqingchen) Please fix the test failure. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3e99b29 to
52ac1bb
Compare
|
thanks Dongbo Wang (@daxian-dbw) , checks are passed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…bly.Load' when the file path is given (PowerShell#4196) It's to solve a side-by-side problem we have with powershell core. If a .NET Core version assembly has the same name as it's .NET ancestor in GAC, then even if you specify the file path to `Import-Module`, powershell core will still load the one in GAC because it tries 'Assembly.Load' first. Now we change it to use `Assembly.LoadFrom` first when a file path is given, so it works for modules that have side-by-side assemblies.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.