-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fixing bug #2607 related to ModuleSpec syntax in RequiredModules #3594
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
Fixing bug #2607 related to ModuleSpec syntax in RequiredModules #3594
Conversation
@@ -4104,10 +4104,11 @@ internal PSModuleInfo LoadRequiredModule(PSModuleInfo currentModule, ModuleSpeci | |||
if (currentModule != null) | |||
{ | |||
requiredModules.Add(new ModuleSpecification(currentModule), new List<ModuleSpecification> { requiredModuleSpecification }); | |||
requiredModules.Add(requiredModuleSpecification, new List<ModuleSpecification> ( requiredModuleInfo.RequiredModulesSpecification )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does requiredModuleSpecification only needs to be added when currentModule is not null?
this is confusing here. if so, please add comment explains why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally I was thinking that both addition should be bundled together; but thinking more about it - it is better to move the new addition to its own 'if' check. Updated.
|
||
try | ||
{ | ||
Import-Module $lastModule -ErrorAction Stop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also check that the module is actually loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; updated.
5fc877d
to
bad1221
Compare
good to sign off |
This fixes issue #2607.
'RequiredModules' is a field in module manifest that can reference other modules using ModuleSpecification format.
The basic version of this format (just module name) was working fine, however there was a problem when more detailed version of the format was used (the one that uses module versions or/and GUIDs).
During module import, there is a check for cyclic references through 'RequiredModules' field. The bug was in this check for cyclic references , related to comparison rules for ModuleSpecification objects - as a result code was incorrectly reporting 'cyclic reference' error in cases when there was none.
Added tests for different ModuleSpecification formats and a test for error when there is actually a cyclic reference.
Test results before the fix:

Test results after the fix:
