This change merges Jim's fixes with some more I identified that will make the tests more reliable and faster to run.
The changes add functions to wait for the desired state instead of simply waiting a specified period of time, and also speeds up running job script execution time.
* Use `nameof` where appropriate
* Factor out a repeated `entry.Key.ToString()` call
* Use a `StringBuilder` in the `ToString()` method
* Dissect a trick comparison method into something simpler
* Use HashCode.Combine() method
Previously, we limited use of UseShellExecute when starting a new process to only Windows Desktop. However, CoreFx now supports UseShellExecute (appropriately calling `open` on macOS and `xdg-open` on Linux) so we can have a consistent code and remove some of the existing redundant code or unnecessary limiting code.
* The major refactoring changes are:
- In `ModuleIntrisic.cs`, remove unneeded Windows-PowerShell-only code.
- In `ModuleUtils.cs`
- use the new API `Directory.GetDirectories(string path, string searchPattern, EnumerationOptions enumerationOptions)` and `Directory.GetFiles(string path, string searchPattern, EnumerationOptions enumerationOptions)` to enumerate files and sub-directories within a directory path.
- remove the unused parameter `bool force` from `GetDefaultAvailableModuleFiles(bool force, bool isForAutoDiscovery, ExecutionContext context)`
- refactor the method `GetModuleVersionsFromAbsolutePath`. Add more comments and rename the method name.
- In `ModuleCmdletBase.cs`, refactor the method `GetModuleForNonRootedPaths` to `GetModuleForNames` to simply its implementation.
- In `PSModuleInfo.cs`
- group the declarations of `Declared*Exports` fields together
- rename `_detected*Exports` fields to `Detected*Exports` to group them together. They are internal fields and used outside `PSModuleInfo`.
* There is some perf improvement after this refactoring change:
- For `Get-Module -ListAvailable`, there is about 36% speed improvement for 94 default modules.
- For `Get-Module -ListAvailable -All`, there is about 14% speed improvement for totally 600 module files.
- For `Get-Module <name> -ListAvailable -List`, there is over 17x speed improvement for finding 13 modules from 600 modules. This is because we now filter names using the module file before creating a `PSMdouleInfo` object.
-preview switch:
- installs pwsh-preview packages when a package manager is being used.
- uses link name pwsh-preview when tar ball install is being done
- results in preview release being available for calling manually, but does not become systemwide version
Issue #7177
PSRP currently relies on XML for the transport messages. When using PSRP over SSH, if the target side fails, it sends back a text message. PSRP sees this and doesn't know what to do so it throws
a generic message which makes troubleshooting the issue more difficult. Change here is to throw
the text message which now looks like:
>new-pssession : [test-machine] There is an error processing data from the background process. Error reported: Invalid argument '-np', did you mean:.
Previously:
>new-pssession : [test-machine] There is an error processing data from the background process. Error reported: Cannot process an element with node type "Text". Only Element and EndElement node types are supported..
Since it's processing one line at a time, not able to get the whole message.
* [FEATURE] Allow Basic Auth over HTTPS
* WSManTransportManager.cs: Simplify HTTPS check
Update comment in test to refer to the right exception type.
* Disable test until limi crash fo selected connection error paths is fixed
* Use Hex format for defining the expected HRESULT