Skip to content
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

Fix default InModuleScope args-value #1812

Merged
merged 1 commit into from
Mar 4, 2021
Merged

Conversation

fflaten
Copy link
Collaborator

@fflaten fflaten commented Dec 19, 2020

PR Summary

Using ParameterAttribute or CmdLetBinding in InModuleScope scriptblock causes ParameterBindingException for the default when no arguments are provided. $ArgumentList-parameter is default null and is always passed to the scriptblock, which throws the error since advanced functions don't implicitly allow arguments.

PR changes $ArgumentList to be empty array by default as it won't cause the exception when not defined. Similar to #1730 for Mocks.

Fix #1809

PR Checklist

  • PR has meaningful title
  • Summary describes changes
  • PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • Tests are added/update (if required)
  • Documentation is updated/added (if required)

@nohwnd
Copy link
Member

nohwnd commented Dec 21, 2020

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@JustinGrote
Copy link
Contributor

Is this possibly related to #1603?

@fflaten
Copy link
Collaborator Author

fflaten commented Jan 27, 2021

No, it won't add any parameters for InModuleScope scriptblock automatically if that's what you mean.

This PR is just a fix to support an advanced functions/script as the InModuleScope scriptblock.

@nohwnd nohwnd merged commit 3e38303 into pester:v5.0 Mar 4, 2021
@fflaten fflaten deleted the inmodulescope-args branch March 4, 2021 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InModuleScope: Cannot use [Parameter()] for the parameter inside the scriptblock
3 participants