Closed jhoneill closed 4 years ago
Was the original default value being passed to cmdlets of other modules? I never even considered that! So sorry for the trouble.
Searching for just ':projectName' returns a lot more places. Let me see if all the alias still use the projectName if we add the -VSteam* to it.
EditI just checked, defaults do work for aliases . You can define a default for an alias, or for the canonical name, but you can't defined different ones for each. End edit
I was writing new functions which use _callApi and (a) they were getting passed the project name and I couldn't see why a parameter set without projectname never got selected and I was focusing on the parameter sets being the cause, so spent a long time looking in the wrong place for the problem (b) _callApi was being called with a project name when I wasn't passing it one.
Projectname could be used in other modules but isn't in that I can think of
I would prefer a script: scoped or global: scoped variable to be the parameter default, but that's a change which needs a lot more work.
I see. I scoped it as you suggested but I fixed the other problem by adding the -NoProject flag to the _callAPI function. That flag has _callAPI ignore any default value stored for project. But now understanding this better I might remove the -NoProject flag now that the default is properly scoped to just external functions. I will do some testing. Thanks for the explanation.
After a frustrating debugging session which turned out to be something with a ProjectName parameter being passed a default, I'm now of the opinion that the default should only apply to commands with -VsTeam nouns. Changing is a matter of a global search and replace of
$Global:PSDefaultParameterValues['*:projectName']
With$Global:PSDefaultParameterValues['*-Vsteam*:projectName']
I have been doing this successfully on my development branch for a little while but haven't added it to the branch that is the subject of a PR because (a) there may be side effects I don't know about and (b) That PR is quite big enough already.