Closed alx9r closed 2 days ago
@michaeltlombardi Thank you for your help with this issue. I see the help for -PassThru
now reads as follows:
Returns a System.Runtime object that represents the types that were added. By default, this cmdlet doesn't generate any output. Use this parameter if you used OutputAssembly to create a DLL file and you want to return the type from the newly created assembly.
I don't think this addresses my original issue. The new wording does not mention that, in addition to outputting the System.Runtime object, -PassThru
also has the side-effect of loading the assembly. Without -PassThru
the assembly is not loaded. That's surprising behavior, and so I think ought to be documented. Or perhaps that behavior is a bug that should be corrected. As it stands the surprising behavior is still undocumented which isn't ideal. I'm happy to open an issue in the PowerShell repository if you think that's the right solution.
Prerequisites
Get-Foo
cmdlet" instead of "Typo."Links
-PassThru
for 7.4Summary
The following
n.c
,.\d1.dll
, then.\d2.dll
.The calls for (2) and (3) differ only by whether
-PassThru
is provided. In other words, adding-PassThru
has the side-effect of loading an assembly that otherwise would not have been. I find this to be surprising behavior since the kind of assembly metadata output with-PassThru
is obtained separately from loading an assembly when usingCSharpCompilation
and friends in .Net. (As much is demonstrated in PowerShell/PowerShell#24612.)Indeed the following test suggests this behavior is so intended (although I do not understand why):
repro.ps1
outputs
Suggested Fix
I would find the behavior less surprising if the following were added to the documentation for
-PassThru
:I think that statement is true, but I'm completely sure. That language would be consistent with this other statement: