Merge branch 'master' into dev/cross-platform-pester

This commit is contained in:
Zachary Folwick 2015-12-28 10:01:39 -08:00
commit 3eb2f5751b
92 changed files with 5422 additions and 1757 deletions

16
.gitignore vendored
View File

@ -1,7 +1,11 @@
/.config
/.nuget\\packages\\/
/.bash_history
/bin/
bin/
obj/
/lib/
/tools/
*-tests.xml
/approot/
/src/*/bin/
/.bash_history
/.vscode/
project.lock.json
*-tests.xml
/src/TypeCatalogGen/powershell.inc
/src/TypeCatalogGen/CorePsTypeCatalog.cs

4
.gitmodules vendored
View File

@ -5,10 +5,6 @@
[submodule "src/monad-native"]
path = src/monad-native
url = https://msostc.visualstudio.com/DefaultCollection/PS/_git/monad-native
branch = develop
[submodule "src/monad-ext"]
path = src/monad-ext
url = https://msostc.visualstudio.com/DefaultCollection/PS/_git/monad-ext
[submodule "ext-src/pester"]
path = ext-src/pester
url = https://msostc.visualstudio.com/DefaultCollection/PS/_git/Pester

121
Makefile
View File

@ -1,121 +0,0 @@
# the monad-linux superproject
export MONAD=$(realpath $(CURDIR))
# location of powershell and coreclr folders
export PSLIB=$(MONAD)/lib/powershell
export CLRLIB=$(MONAD)/lib/coreclr
all: powershell-native powershell-managed
# managed code
powershell-managed:
mkdir -p $(PSLIB) $(CLRLIB)
cp -R $(MONAD)/src/monad-ext/coreclr/Runtime/* $(CLRLIB)
$(MAKE) -j -C src/monad-build
$(MAKE) -j -C src/monad-build test
# native code
powershell-native: src/monad-native/Makefile
$(MAKE) -j -C src/monad-native
$(MAKE) -j -C src/monad-native test
$(MAKE) -j -C src/monad-native install
## will install to $(MONAD)/{bin,lib}
src/monad-native/Makefile:
cd src/monad-native && cmake -DCMAKE_INSTALL_PREFIX=$(MONAD) .
# one-time setup
tools/nuget.exe:
cd tools && wget 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'
bootstrap: tools/nuget.exe
mono $< restore -PackagesDirectory tools
# run targets
export POWERSHELL=env TEMP=/tmp LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(MONAD)/lib:$(PSLIB) PSMODULEPATH=$(PSLIB)/Modules $(MONAD)/bin/powershell
demo:
$(POWERSHELL) '"a","b","c","a","a" | Select-Object -Unique'
shell:
$(POWERSHELL)
# tests
test: test-pester
## TODO: fix this after refactoring bin/powershell
test-hashbang:
PATH=$(PATH):bin src/3rdparty/hashbang/script.ps1
## Pester tests for PowerShell - results in pester-tests.xml
## - see https://github.com/pester/Pester
## - requires $TEMP to be set
## - we cd because some tests rely on the current working directory
PESTER=$(MONAD)/src/pester-tests
test-pester:
$(POWERSHELL) 'invoke-pester $(PESTER) -OutputFile $(MONAD)/pester-tests.xml -OutputFormat NUnitXml'
## Pester self-tests
## - results in pester-self-tests.xml
test-pester-self:
$(POWERSHELL) 'cd $(PSLIB)/Modules/Pester/Functions; $$env:TEMP="/tmp"; invoke-pester -OutputFile $(MONAD)/pester-self-tests.xml -OutputFormat NUnitXml'
## tracing
## - use PAL_DBG_CHANNELS="+LOADER.TRACE" to enable CoreCLR tracing
## - use Set-PSDebug -Trace 2 to enable PowerShell tracing
# OMI
OMI=src/omi/Unix
OMI_FLAGS=--dev --enable-debug
$(OMI)/GNUmakefile:
cd $(OMI) && ./configure $(OMI_FLAGS)
OMISERVER=$(OMI)/output/bin/omiserver
$(OMISERVER): $(OMI)/GNUmakefile
$(MAKE) -j -C $(OMI)
## copy libpshost because OMI isn't configurable
MONAD_PROVIDER=src/monad-omi-provider
PSRP_OMI_PROVIDER=$(OMI)/output/lib/libpsrpomiprov.so
$(PSRP_OMI_PROVIDER): $(OMISERVER) powershell-native
cp lib/libpshost.a $(OMI)/output/lib
$(MAKE) -j -C $(MONAD_PROVIDER)
psrp: $(PSRP_OMI_PROVIDER)
## phony targets so that the recursive make is always invoked
.PHONY: $(OMISERVER) $(PSRP_OMI_PROVIDER)
# clean targets
clean: clean-monad
-rm *-tests.xml
distclean: distclean-monad distclean-native distclean-omi clean
-rm -rf $(CLRLIB)
clean-monad:
$(MAKE) -C src/monad-build clean
distclean-monad:
$(MAKE) -C src/monad-build distclean
clean-native:
-$(MAKE) -C src/monad-native clean
distclean-native:
cd src/monad-native && git clean -fdx
clean-omi:
-$(MAKE) -C $(OMI) clean
distclean-omi:
-$(MAKE) -C $(OMI) distclean
clean-psrp:
-$(MAKE) -C $(MONAD_PROVIDER) clean

114
README.md
View File

@ -75,47 +75,101 @@ Our convention is to create feature branches `dev/feature` off our integration b
## Setup build environment
There are two approaches. You can build in our Docker container and have all the [dependencies](docs/Dependencies.md) taken care of for you, or you can install them by hand and run "baremetal."
We use the [.NET Command Line Interface][dotnet-cli] (`dotnet-cli`) to build the managed components, and [CMake][] to build the native components. Install `dotnet-cli` by following their documentation (make sure to install the `dotnet-dev` package to get the latest version). Then install the following dependencies (assuming Ubuntu 14.04):
### Docker
```sh
sudo apt-get install g++ cmake make libboost-filesystem-dev lldb-3.6 strace
```
See the official [installation documentation][] on how to install Docker, and don't forget to setup a [Docker group][].
### OMI
The Docker container can be updated with `docker pull andschwa/magrathea`, which downloads it from the [automated build repository][].
To develop on the PowerShell Remoting Protocol (PSRP), you'll need to be able to compile OMI, which additionally requires:
This container isolates all our build dependencies, including Ubuntu 14.04 and Mono. See the [Dockerfile][] to look under the hood.
```sh
sudo apt-get install libpam0g-dev libssl-dev libcurl4-openssl-dev
```
The `monad-docker.sh` script has two Bash functions, `monad-run` and `monad-it`, which are wrappers that start a temporary container with `monad-linux` mounted and runs the arguments given to the script as your current user, but inside the container. The build artifacts will exist in your local folder and be owned by your user, essentially making the use of the container invisible. The `monad-tty` version also allocates a shell for the container, and so allows you to launch Bash or an interactive PowerShell session. Since these are Bash functions, it is simplest to source the `monad-docker.sh` script directly in your `~/.bashrc`, but the `./build.sh` script will also source it and delegate to `monad-run`.
[Docker group]: https://docs.docker.com/installation/ubuntulinux/#create-a-docker-group
[installation documentation]: https://docs.docker.com/installation/ubuntulinux/
[automated build repository]: https://registry.hub.docker.com/u/andschwa/magrathea/
[Dockerfile]: https://github.com/andschwa/docker-magrathea/blob/master/Dockerfile
[Make]: https://www.gnu.org/software/make/manual/make.html
[CMake]: http://www.cmake.org/cmake/help/v2.8.12/cmake.html
[dotnet-cli]: https://github.com/dotnet/cli#new-to-net-cli
[CMake]: https://cmake.org/cmake/help/v2.8.12/cmake.html
## Building
Please note that the square brackets indicate that part is only necessary if building within the Docker container. If running baremetal, ignore them.
The command `dotnet restore` must be done at least once from the top directory to obtain all the necessary .NET packages; unfortunately, we also have to temporarily patch `System.Console.dll` until the API is officially updated, so run `./patch.sh`.
1. `[source monad-docker.sh]` to get the `monad-run` and `monad-it` Bash functions
2. `[monad-run] make boostrap` will download dependent NuGet packages (including the C# compiler)
3. `[monad-run] make` will build PowerShell for Linux and execute the managed and native unit tests
4. `[monad-run] make demo` will build and execute a demo, `"a","b","c","a","a" | Select-Object -Unique`
5. `[monad-run] make test` will build PowerShell and execute the Pester smoke tests
6. `[monad-it] make shell` will open an interactive PowerShell console (note the `it` for `--interactive --tty`)
7. `make clean` will remove built libraries
8. `make distclean` will remove all untracked files in `monad-native` (such as CMake's generated files) as well as generated files for `monad`
9. `git clean -fdx && git submodule foreach git clean -fdx` will nuke everything that is untracked by Git in all repositories, use with caution
Build with `./build.sh`, which does the following steps.
## Adding Pester tests
> The variable `$BIN` is the output directory, `bin`.
Pester tests are located in the `src/pester-tests` folder. The makefile targets `test` and `pester-tests` will run all Pester tests.
### Native
The steps to add your pester tests are:
- add `*.Tests.ps1` files to `src/pester-tests`
- run `make test` to run all the tests
- `libpsnative.so`: native functions that `CorePsPlatform.cs` P/Invokes
- `libpshost.a`: native CLR host library
- `powershell`: native CLR host executable (for local shell)
- `api-ms-win-core-registry-l1-1-0.dll`: registry stub to prevent missing DLL error on shutdown
## TODO: Docker shell-in-a-box
#### monad-native
## TODO: Architecture
Driven by CMake, with its own unit tests using Google Test.
```sh
cd src/monad-native
cmake -DCMAKE_BUILD_TYPE=Debug .
make -j
ctest -V
# Deploy development copy of libpsnative
cp native/libpsnative.so $BIN
```
#### registry-stub
Provides `RegCloseKey()` to satisfy the disposal of `SafeHandle` objects on shutdown.
```sh
cd src/registry-stub
make
cp api-ms-win-core-registry-l1-1-0.dll $BIN
```
### Managed
Builds with `dotnet-cli`. Publishes all dependencies into the `bin` directory.
```sh
cd src/Microsoft.PowerShell.Linux.Host
dotnet publish --framework dnxcore50 --runtime ubuntu.14.04-x64 --output $BIN
# Copy files that dotnet-publish doesn't currently deploy
cp *.ps1xml *_profile.ps1 $BIN
```
### PowerShell Remoting Protocol
PSRP communication is tunneled through OMI using the `monad-omi-provider`. These build steps are not part of the `./build.sh` script.
#### OMI
```sh
cd src/omi/Unix
./configure --dev --enable-debug
make -j
```
#### Provider
The provider has its own `./build.sh` script which does the second step documented here.
```sh
cd src/monad-omi-provider
make clean && make -j && make reg
```
## Running
- launch local shell with `./run.sh`.
- launch local shell in LLDB with `./debug.sh`
- launch `omiserver` for PSRP (and in LLDB) with `./prsp.sh`, and connect with `Enter-PSSession` from Windows
## Known Issues
### xUnit
Sadly, `dotnet-test` is not fully supported on Linux, so our xUnit tests do not currently run. We may be able to work around this, or get the `dotnet-cli` team to fix their xUnit runner. GitHub [issue](https://github.com/dotnet/cli/issues/407).

60
build.sh Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env bash
export BIN=$(pwd)/bin
mkdir -p $BIN/Modules
# Deploy PowerShell modules
(
cd $BIN/Modules
ln -sf ../../ext-src/pester Pester
ln -sf ../../src/monad/monad/miscfiles/modules/Microsoft.PowerShell.Utility .
OMI=Microsoft.PowerShell.Commands.Omi
mkdir -p $OMI
ln -sf $BIN/$OMI.dll $OMI/
)
# Build native components
(
cd src/monad-native
cmake -DCMAKE_BUILD_TYPE=Debug .
make -j
ctest -V
# Deploy development copy of libpsnative
cp native/libpsnative.so $BIN
)
# Build registry stub (this should go away, again)
(
cd src/registry-stub
make
cp api-ms-win-core-registry-l1-1-0.dll $BIN
)
# Publish PowerShell
(
cd src/Microsoft.PowerShell.Linux.Host
dotnet publish --framework dnxcore50 --runtime ubuntu.14.04-x64 --output $BIN
# Copy files that dotnet-publish does not currently deploy
cp *_profile.ps1 $BIN
)
# Symlink types and format files to correct names
(
cd $BIN
ln -sf ../src/monad/monad/miscfiles/types/CoreClr/types.ps1xml .
ln -sf ../src/monad/monad/miscfiles/types/CoreClr/typesv3.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/Certificate.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/Diagnostics.Format.ps1xml Diagnostics.format.ps1xml
ln -sf ../src/monad/monad/miscfiles/display/DotNetTypes.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/Event.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/FileSystem.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/Help.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/HelpV3.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/PowerShellCore.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/PowerShellTrace.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/Registry.format.ps1xml .
ln -sf ../src/monad/monad/miscfiles/display/WSMan.format.ps1xml .
)

2
debug.sh Executable file
View File

@ -0,0 +1,2 @@
export CORE_ROOT=$(pwd)/bin
lldb-3.6 -o "plugin load ./bin/libsosplugin.so" -- ./powershell $@

@ -1 +1 @@
Subproject commit fec78c273908447efd539283d8fa22303b495fdc
Subproject commit f23641488f8d7bf8630ca3496e61562aa3a64009

3
global.json Normal file
View File

@ -0,0 +1,3 @@
{
"projects": ["src"]
}

View File

@ -22,8 +22,8 @@ monad-docker-run()
local CONSOLE=$1
shift 1
docker run --rm \
--volume $(pwd)/:/opt \
--workdir /opt \
--volume $(pwd)/:/opt/src \
--workdir /opt/src \
$CONSOLE \
andschwa/magrathea:latest \
bash -c "$(monad-impersonate) bash -c '$*'"
@ -49,6 +49,6 @@ monad-impersonate()
fi
echo \
groupadd -o -f -g $CGID $CGROUP '&&' \
useradd -u $CUID -g $CGID -d /opt $CUSER '&&' \
useradd -u $CUID -g $CGID -G sudo -d /opt $CUSER '&&' \
sudo --set-home -u $CUSER -g $CGROUP --
}

11
nuget.config Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dotnetcore" value="https://www.myget.org/F/dotnet-core/" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="7.0.1" />
<package id="System.Reflection.Metadata" version="1.0.22" />
<package id="System.Collections.Immutable" version="1.1.37" />
<package id="Microsoft.Net.Compilers" version="1.0.0" />
</packages>

7
patch.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
dotnet restore
echo Patching System.Console.dll
curl -fLo \
~/.dnx/packages/System.Console/4.0.0-rc2-23616/ref/dotnet5.4/System.Console.dll \
'https://github.com/andschwa/corefx/raw/cc1ad3b33318c44d6c615d449b2db7b1715e8e60/System.Console.dll'

6
pester.sh Executable file
View File

@ -0,0 +1,6 @@
export CORE_ROOT=$(pwd)/bin
./powershell -c "Invoke-Pester src/pester-tests/$1 -OutputFile pester-tests.xml -OutputFormat NUnitXml"
# XML files are not executable
chmod -x pester-tests.xml
# Fix tty due to possible bug in .NET
stty echo || true

1
powershell Symbolic link
View File

@ -0,0 +1 @@
src/monad-native/host/powershell

2
psrp.sh Executable file
View File

@ -0,0 +1,2 @@
export CORE_ROOT=$(pwd)/bin
lldb-3.6 -o "plugin load ./bin/libsosplugin.so" -- ./src/omi/Unix/output/bin/omiserver --ignoreAuthentication

4
run.sh Executable file
View File

@ -0,0 +1,4 @@
export CORE_ROOT=$(pwd)/bin
./powershell $@
# Fix tty due to possible bug in .NET
stty echo

View File

@ -0,0 +1,17 @@
{
"version": "1.0.0-*",
"description": "Microsoft.Management.Infrastructure.Native Stub",
"authors": [ "garretts", "andschwa" ],
"compilationOptions": { "allowUnsafe": true },
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"System.Security.SecureString": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } }
}

View File

@ -0,0 +1,120 @@
{
"version": "1.0.0-*",
"description": "Microsoft.Management.Infrastructure Stub",
"authors": [ "garretts", "andschwa" ],
"compilationOptions": {
"define": [
"CORECLR",
"_CORECLR",
"LINUX"
]
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"System.Runtime.Serialization.Xml": "4.1.0-rc2-23616",
"System.Threading.ThreadPool": "4.0.10-rc2-23616",
"Microsoft.Management.Infrastructure.Native" : {
"type": "build",
"version": "1.0.0-*"
},
"System.Security.SecureString": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } },
"compileFiles": [
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/AssemblyInfo.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CancellationMode.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimApplication.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncCallbacksReceiverBase.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncCancellationDisposable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncClassObservable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncClassObserverProxy.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncDelegatedObservable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncIndicationObservable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncIndicationObserverProxy.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncInstanceObservable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncInstanceObserverProxy.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncMethodResultObservable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncMethodResultObserverProxy.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncObservableBase.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncObserverProxyBase.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncResult.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimAsyncStatus.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimClass.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimClassPropertiesCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimClassPropertyOfClass.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimClassQualifierCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimConverter.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimCredential.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimDeserializer.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimException.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimFlags.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimInstance.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimKeyedCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodDeclaration.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodDeclarationCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodDeclarationOfClass.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParameter.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParameterBackedByCimProperty.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParameterDeclaration.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParameterDeclarationCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParameterDeclarationOfMethod.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParameterQualifierCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParameterQualifierOfMethod.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodParametersCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodQualifierCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodQualifierOfMethod.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodResult.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodResultBase.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMethodStreamedResult.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMofDeserializer.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimMofSerializer.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimOperation.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimOperationFlags.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimOperationOptions.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimPropertiesCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimProperty.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimPropertyDeclaration.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimPropertyOfInstance.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimPropertyQualifierCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimPropertyStandalone.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimQualifier.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimQualifierOfClass.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimQualifierOfProperty.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimReadOnlyKeyedCollection.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSemantics.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSerializer.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSession.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSessionOptions.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSubscriptionDeliveryOptions.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSubscriptionResult.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncClassEnumerable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncClassEnumerator.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncEnumerableBase.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncEnumeratorBase.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncIndicationEnumerable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncIndicationEnumerator.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncInstanceEnumerable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSyncInstanceEnumerator.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimSystemProperties.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/CimType.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/ConvertingObservable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/DComSessionOptions.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/EmptyDisposable.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/Helpers.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/ImpersonationType.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/NativeErrorCode.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/PacketEncoding.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/ProxyType.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/SharedInstanceHandle.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/Strings.Designer.cs",
"../monad/wmi/WMIv2/Client/DotNetAPI/cs/WSManSessionOptions.cs",
]
}

View File

@ -0,0 +1,4 @@
using System.Reflection;
[assembly:AssemblyFileVersionAttribute("3.0.0.0")]
[assembly:AssemblyVersion("3.0.0.0")]

View File

@ -0,0 +1,90 @@
{
"version": "1.0.0-*",
"description": "Microsoft.PowerShell.Commands.Management Library",
"authors": [ "garretts", "andschwa" ],
"compilationOptions": {
"define": [
"CORECLR",
"_CORECLR",
"LINUX"
],
"allowUnsafe": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"System.ServiceProcess.ServiceController": "4.1.0-rc2-23616",
"System.Net.NameResolution": "4.0.0-rc2-23616",
"Microsoft.PowerShell.Security": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } },
"compile": [ "../monad-build/gen/COMMANDS_MANAGEMENT/*.cs" ],
"compileFiles": [
"../monad/monad/src/cimSupport/cmdletization/SessionBasedWrapper.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/CimJobException.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/CreateInstanceJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/DeleteInstanceJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/EnumerateAssociatedInstancesJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/ExtrinsicMethodInvocationJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/InstanceMethodInvocationJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/MethodInvocationJobBase.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/ModifyInstanceJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/PropertySettingJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/QueryJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/QueryJobBase.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/StaticMethodInvocationJob.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/TerminatingErrorTracker.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimChildJobBase.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimCmdletDefinitionContext.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimCmdletInvocationContext.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimConverter.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimJobContext.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimOperationOptionsHelper.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimQuery.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/cimWrapper.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/clientSideQuery.cs",
"../monad/monad/src/commands/management/AddContentCommand.cs",
"../monad/monad/src/commands/management/ClearContentCommand.cs",
"../monad/monad/src/commands/management/ClearPropertyCommand.cs",
"../monad/monad/src/commands/management/CombinePathCommand.cs",
"../monad/monad/src/commands/management/CommandsCommon.cs",
"../monad/monad/src/commands/management/Computer.cs",
"../monad/monad/src/commands/management/ContentCommandBase.cs",
"../monad/monad/src/commands/management/ConvertPathCommand.cs",
"../monad/monad/src/commands/management/CopyPropertyCommand.cs",
"../monad/monad/src/commands/management/GetChildrenCommand.cs",
"../monad/monad/src/commands/management/GetContentCommand.cs",
"../monad/monad/src/commands/management/GetPropertyCommand.cs",
"../monad/monad/src/commands/management/MovePropertyCommand.cs",
"../monad/monad/src/commands/management/Navigation.cs",
"../monad/monad/src/commands/management/NewPropertyCommand.cs",
"../monad/monad/src/commands/management/ParsePathCommand.cs",
"../monad/monad/src/commands/management/PassThroughContentCommandBase.cs",
"../monad/monad/src/commands/management/PassThroughPropertyCommandBase.cs",
"../monad/monad/src/commands/management/PingPathCommand.cs",
"../monad/monad/src/commands/management/Process.cs",
"../monad/monad/src/commands/management/PropertyCommandBase.cs",
"../monad/monad/src/commands/management/RemovePropertyCommand.cs",
"../monad/monad/src/commands/management/RenamePropertyCommand.cs",
"../monad/monad/src/commands/management/ResolvePathCommand.cs",
"../monad/monad/src/commands/management/Service.cs",
"../monad/monad/src/commands/management/SetContentCommand.cs",
"../monad/monad/src/commands/management/SetPropertyCommand.cs",
"../monad/monad/src/commands/management/WriteContentCommandBase.cs"
],
"namedResource": {
"CmdletizationResources": "../monad-build/gen/COMMANDS_MANAGEMENT/CmdletizationResources.resources",
"ComputerResources": "../monad-build/gen/COMMANDS_MANAGEMENT/ComputerResources.resources",
"NavigationResources": "../monad-build/gen/COMMANDS_MANAGEMENT/NavigationResources.resources",
"ProcessResources": "../monad-build/gen/COMMANDS_MANAGEMENT/ProcessResources.resources",
"ServiceResources": "../monad-build/gen/COMMANDS_MANAGEMENT/ServiceResources.resources"
}
}

View File

@ -0,0 +1,119 @@
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
using System.Management.Automation;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
namespace Microsoft.PowerShell.Commands.Omi
{
#region Get-OmiInstance
/// <summary>
/// implementation for the Get-OmiInstance command
/// </summary>
[Cmdlet( VerbsCommon.Get, "OmiInstance" )]
[OutputType(typeof(string))]
[OutputType(typeof(object[]))]
public sealed class GetOmiInstanceCommand : Cmdlet
{
#region parameters
[Parameter(Mandatory = true)]
[Alias("NS")]
public string Namespace
{
get
{
return nameSpace;
}
set
{
nameSpace = value;
}
}
private string nameSpace;
[Parameter(Mandatory = true)]
[Alias("CN")]
public string ClassName
{
get
{
return className;
}
set
{
className = value;
}
}
private string className;
[Parameter]
public string Property
{
get
{
return property;
}
set
{
property = value;
propertySpecified = true;
}
}
private string property;
private bool propertySpecified = false;
#endregion
#region methods
protected override void ProcessRecord()
{
OmiInterface oi = new OmiInterface();
if (propertySpecified)
{
string value;
oi.GetOmiValue(nameSpace, className, property, out value);
WriteObject(value);
return;
}
OmiData data;
oi.GetOmiValues(nameSpace, className, out data);
// Convert OmiData type to array of objects
ArrayList array = new ArrayList();
foreach (Dictionary<string, string> d in data.Values)
{
PSObject o = new PSObject();
foreach (string p in data.Properties)
{
string value = String.Empty;
if (d.ContainsKey(p))
{
value = d[p];
}
PSNoteProperty psp = new PSNoteProperty(p, value);
o.Members.Add(psp);
}
array.Add(o);
}
WriteObject((Object[])array.ToArray());
} // EndProcessing
#endregion
}
#endregion
} // namespace Microsoft.PowerShell.Commands

View File

@ -0,0 +1,413 @@
/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
using System.Runtime.InteropServices;
namespace Microsoft.PowerShell.Commands.Omi
{
internal static class Platform
{
internal static bool IsLinux()
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
}
internal static bool IsWindows()
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
}
}
/// <summary>
/// Data from OMI
/// </summary>
public class OmiData
{
public HashSet<string> Properties;
public HashSet<Dictionary<string, string>> Values;
public OmiData()
{
Properties = new HashSet<string>();
Values = new HashSet<Dictionary<string, string>>();
}
public void Debug()
{
foreach (string p in Properties)
{
Console.Write("{0,-22}", p);
}
Console.WriteLine();
foreach (Dictionary<string, string> d in Values)
{
foreach (string p in Properties)
{
string value = String.Empty;
if (d.ContainsKey(p))
{
value = Truncate(d[p], 16);
}
Console.Write("{0,-22}", value);
}
Console.WriteLine();
}
}
private string Truncate(string s, int maxChars)
{
return s.Length < maxChars ? s : s.Substring(0, maxChars) + " ...";
}
}
/// <summary>
/// Interfaces that cmdlets can use to interface with OMI
/// </summary>
public class OmiInterface
{
private string _xmlString = null;
private void GetXML(string nameSpace, string className)
{
using (Process process = new Process())
{
// Assume omicli is somewhere in PATH...
process.StartInfo.FileName = "omicli";
process.StartInfo.Arguments = $"ei {nameSpace} {className} -xml";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
if (process.ExitCode != 0)
{
throw new IOException();
}
_xmlString = $"<INSTANCES>{output}</INSTANCES>";
}
return;
}
private void GetValue(string nameSpace, string propertyName, out string type, out string value)
{
// parse xml
XElement cim = XElement.Parse(_xmlString);
IEnumerable<XElement> elements =
from el in cim.Elements("INSTANCE")
where (string)el.Attribute("CLASSNAME") == nameSpace
select el;
IEnumerable<XElement> properties =
from el in elements.First().Elements("PROPERTY")
where (string)el.Attribute("NAME") == propertyName
select el;
XElement property = properties.First();
XElement p = property.Element("VALUE");
type = (string)property.Attribute("TYPE");
value = p.Value;
}
private IEnumerable<XElement> GetValueIEnumerable()
{
// parse xml
XElement cim = XElement.Parse(_xmlString);
IEnumerable<XElement> elements = cim.Elements();
return elements;
}
private OmiData GetOmiData()
{
OmiData data = new OmiData();
const string VALUE = "VALUE";
const string VALUEARRAY = "VALUE.ARRAY";
const string PROPERTY = "PROPERTY";
const string PROPERTYARRAY = "PROPERTY.ARRAY";
IEnumerable<XElement> instances = GetValueIEnumerable();
foreach (XElement instance in instances)
{
// First, do PROPERTY elements
IEnumerable<XElement> properties = instance.Elements(PROPERTY);
foreach (XElement property in properties)
{
Dictionary<string, string> d = new Dictionary<string, string>();
IEnumerable<XAttribute> attrs = property.Attributes();
foreach (XAttribute attr in attrs)
{
data.Properties.Add(attr.Name.LocalName);
d[attr.Name.LocalName] = attr.Value;
}
// Now look for "VALUE" sub-element
IEnumerable<XElement> values = property.Elements(VALUE);
foreach (XElement value in values)
{
data.Properties.Add(VALUE);
d[VALUE] = value.Value;
}
data.Values.Add(d);
}
// Next, do PROPERTY.ARRAY elements
IEnumerable<XElement> propertyArrays = instance.Elements(PROPERTYARRAY);
foreach (XElement property in propertyArrays)
{
Dictionary<string, string> dCommon = new Dictionary<string, string>();
IEnumerable<XAttribute> attrs = property.Attributes();
foreach (XAttribute attr in attrs)
{
data.Properties.Add(attr.Name.LocalName);
dCommon[attr.Name.LocalName] = attr.Value;
}
IEnumerable<XElement> valueArrays = property.Elements(VALUEARRAY);
foreach (XElement valueArray in valueArrays)
{
IEnumerable<XElement> values = valueArray.Elements(VALUE);
foreach (XElement value in values)
{
Dictionary<string, string> d = new Dictionary<string, string>(dCommon);
data.Properties.Add(VALUE);
d[VALUE] = value.Value;
data.Values.Add(d);
}
}
}
}
return data;
}
/// <summary>
/// Query OMI and return a string value
/// </summary>
/// <param name="namespace">The OMI namespace to query
/// <param name="class">The OMI class to query
/// <param name="property">The OMI property to query
/// <param name="value">The return value
/// </param>
/// <exception>
/// <cref type="IOException">Thrown if a unable to communicate with OMI
/// <cref type="XmlException">Thrown if a unable to parse XML properly
/// <cref type="ArgumentNullException>Thrown if any argument is null
/// <cref type="ArgumentException>Thrown if any return value is of wrong type
/// </exception>
public void GetOmiValue(string nameSpace, string className, string property, out string value)
{
if (nameSpace == null || className == null || property == null)
{
throw new ArgumentNullException();
}
if (!Platform.IsLinux())
{
throw new PlatformNotSupportedException();
}
GetXML(nameSpace, className);
string type;
string stringValue;
GetValue(className, property, out type, out stringValue);
if (type != "string")
{
throw new ArgumentException();
}
value = stringValue;
}
/// <summary>
/// Query OMI and return a UInt32 value
/// </summary>
/// <param name="namespace">The OMI namespace to query
/// <param name="class">The OMI class to query
/// <param name="property">The OMI property to query
/// <param name="value">The return value
/// </param>
/// <exception>
/// <cref type="IOException">Thrown if a unable to communicate with OMI
/// <cref type="XmlException">Thrown if a unable to parse XML properly
/// <cref type="ArgumentNullException>Thrown if any argument is null
/// <cref type="ArgumentException>Thrown if any return value is of wrong type
/// </exception>
public void GetOmiValue(string nameSpace, string className, string property, out UInt32 value)
{
if (nameSpace == null || className == null || property == null)
{
throw new ArgumentNullException();
}
if (!Platform.IsLinux())
{
throw new PlatformNotSupportedException();
}
GetXML(nameSpace, className);
string type;
string stringValue;
GetValue(className, property, out type, out stringValue);
if (type != "uint32")
{
throw new ArgumentException();
}
value = UInt32.Parse(stringValue);
}
/// <summary>
/// Query OMI and return a UInt64 value
/// </summary>
/// <param name="namespace">The OMI namespace to query
/// <param name="class">The OMI class to query
/// <param name="property">The OMI property to query
/// <param name="value">The return value
/// </param>
/// <exception>
/// <cref type="IOException">Thrown if a unable to communicate with OMI
/// <cref type="XmlException">Thrown if a unable to parse XML properly
/// <cref type="ArgumentNullException>Thrown if any argument is null
/// <cref type="ArgumentException>Thrown if any return value is of wrong type
/// </exception>
public void GetOmiValue(string nameSpace, string className, string property, out UInt64 value)
{
if (nameSpace == null || className == null || property == null)
{
throw new ArgumentNullException();
}
if (!Platform.IsLinux())
{
throw new PlatformNotSupportedException();
}
GetXML(nameSpace, className);
string type;
string stringValue;
GetValue(className, property, out type, out stringValue);
if (type != "uint64")
{
throw new ArgumentException();
}
value = UInt64.Parse(stringValue);
}
/// <summary>
/// Query OMI and return a collection of XElements
/// </summary>
/// <param name="namespace">The OMI namespace to query
/// <param name="class">The OMI class to query
/// <param name="elements">The return values
/// </param>
/// <exception>
/// <cref type="IOException">Thrown if a unable to communicate with OMI
/// <cref type="XmlException">Thrown if a unable to parse XML properly
/// <cref type="ArgumentNullException>Thrown if any argument is null
/// <cref type="ArgumentException>Thrown if any return value is of wrong type
/// </exception>
public void GetOmiValues(string nameSpace, string className, out IEnumerable<XElement> elements)
{
if (nameSpace == null || className == null)
{
throw new ArgumentNullException();
}
if (!Platform.IsLinux())
{
throw new PlatformNotSupportedException();
}
GetXML(nameSpace, className);
elements = GetValueIEnumerable();
}
/// <summary>
/// Query OMI and return an OmiData data class
/// </summary>
/// <param name="namespace">The OMI namespace to query
/// <param name="class">The OMI class to query
/// <param name="data">The return values
/// </param>
/// <exception>
/// <cref type="IOException">Thrown if a unable to communicate with OMI
/// <cref type="XmlException">Thrown if a unable to parse XML properly
/// <cref type="ArgumentNullException>Thrown if any argument is null
/// <cref type="ArgumentException>Thrown if any return value is of wrong type
/// </exception>
public void GetOmiValues(string nameSpace, string className, out OmiData data)
{
if (nameSpace == null || className == null)
{
throw new ArgumentNullException();
}
if (!Platform.IsLinux())
{
throw new PlatformNotSupportedException();
}
GetXML(nameSpace, className);
data = GetOmiData();
}
/// <summary>
/// Query OMI and return output as XElement
/// </summary>
/// <param name="namespace">The OMI namespace to query
/// <param name="class">The OMI class to query
/// <param name="cim">The return xml as a XElement
/// </param>
/// <exception>
/// <cref type="IOException">Thrown if a unable to communicate with OMI
/// <cref type="XmlException">Thrown if a unable to parse XML properly
/// <cref type="ArgumentNullException>Thrown if any argument is null
/// <cref type="ArgumentException>Thrown if any return value is of wrong type
/// </exception>
public void GetOmiValues(string nameSpace, string className, out XElement cim)
{
if (nameSpace == null || className == null)
{
throw new ArgumentNullException();
}
if (!Platform.IsLinux())
{
throw new PlatformNotSupportedException();
}
GetXML(nameSpace, className);
cim = XElement.Parse(_xmlString);
}
}
}

View File

@ -0,0 +1,17 @@
{
"version": "1.0.0-*",
"description": "Microsoft.PowerShell.Commands.Omi Library",
"authors": [ "George Fleming", "andschwa" ],
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"System.Xml.XDocument": "4.0.11-rc2-23616",
"System.Runtime.InteropServices": "4.0.21-rc2-23616",
"System.Management.Automation": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } }
}

View File

@ -0,0 +1,18 @@
# Note that omicli must be in PATH and omiserver should be started with
# --ignoreAuthentication option
Describe "Get-OmiInstance" {
Import-Module Microsoft.PowerShell.Commands.Omi
It "Should execute basic command correctly" {
$instance = Get-OmiInstance -NameSpace root/omi -ClassName OMI_Identify
# This test is a workaround
$instance.Value.Contains("OMI") | Should Be $true
# TODO: test these when available
#$instance.ProductName | Should Be "OMI"
#$instance.ProductVendor | Should Be "Microsoft"
#$instance.OperatingSystem | Should Be "LINUX"
}
}

View File

@ -0,0 +1,4 @@
using System.Reflection;
[assembly:AssemblyFileVersionAttribute("3.0.0.0")]
[assembly:AssemblyVersion("3.0.0.0")]

View File

@ -0,0 +1,122 @@
{
"version": "1.0.0-*",
"description": "Microsoft.PowerShell.Commands.Utility Library",
"authors": [ "garretts", "andschwa" ],
"compilationOptions": {
"define": [
"CORECLR",
"_CORECLR",
"LINUX"
],
"allowUnsafe": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"System.Management.Automation": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } },
"compile": [ "../monad-build/gen/COMMANDS_UTILITY/*.cs" ],
"compileFiles": [
"../monad/monad/src/commands/utility/AddMember.cs",
"../monad/monad/src/commands/utility/CSVCommands.cs",
"../monad/monad/src/commands/utility/ConsoleColorCmdlet.cs",
"../monad/monad/src/commands/utility/ConvertFrom-StringData.cs",
"../monad/monad/src/commands/utility/Csv.cs",
"../monad/monad/src/commands/utility/DebugRunspaceCommand.cs",
"../monad/monad/src/commands/utility/Disable-PSBreakpoint.cs",
"../monad/monad/src/commands/utility/Enable-PSBreakpoint.cs",
"../monad/monad/src/commands/utility/EnableDisableRunspaceDebugCommand.cs",
"../monad/monad/src/commands/utility/ExportAliasCommand.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/GetFormatDataCommand.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/WriteFormatDataCommand.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/format-list/Format-List.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/format-object/format-object.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/format-table/Format-Table.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/format-wide/Format-Wide.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/out-file/Out-File.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/out-string/out-string.cs",
"../monad/monad/src/commands/utility/Get-PSBreakpoint.cs",
"../monad/monad/src/commands/utility/Get-PSCallStack.cs",
"../monad/monad/src/commands/utility/GetAliasCommand.cs",
"../monad/monad/src/commands/utility/GetCultureCommand.cs",
"../monad/monad/src/commands/utility/GetDateCommand.cs",
"../monad/monad/src/commands/utility/GetEventCommand.cs",
"../monad/monad/src/commands/utility/GetEventSubscriberCommand.cs",
"../monad/monad/src/commands/utility/GetHostCmdlet.cs",
"../monad/monad/src/commands/utility/GetMember.cs",
"../monad/monad/src/commands/utility/GetRandomCommand.cs",
"../monad/monad/src/commands/utility/GetRunspaceCommand.cs",
"../monad/monad/src/commands/utility/GetUICultureCommand.cs",
"../monad/monad/src/commands/utility/GetUnique.cs",
"../monad/monad/src/commands/utility/Import-LocalizedData.cs",
"../monad/monad/src/commands/utility/ImportAliasCommand.cs",
"../monad/monad/src/commands/utility/InvokeCommandCmdlet.cs",
"../monad/monad/src/commands/utility/MatchString.cs",
"../monad/monad/src/commands/utility/Measure-Object.cs",
"../monad/monad/src/commands/utility/NewAliasCommand.cs",
"../monad/monad/src/commands/utility/NewTimeSpanCommand.cs",
"../monad/monad/src/commands/utility/ObjectCommandComparer.cs",
"../monad/monad/src/commands/utility/OrderObjectBase.cs",
"../monad/monad/src/commands/utility/ReadConsoleCmdlet.cs",
"../monad/monad/src/commands/utility/RegisterObjectEventCommand.cs",
"../monad/monad/src/commands/utility/RegisterPSEventCommand.cs",
"../monad/monad/src/commands/utility/Remove-PSBreakpoint.cs",
"../monad/monad/src/commands/utility/RemoveEventCommand.cs",
"../monad/monad/src/commands/utility/Set-PSBreakpoint.cs",
"../monad/monad/src/commands/utility/SetAliasCommand.cs",
"../monad/monad/src/commands/utility/SetDateCommand.cs",
"../monad/monad/src/commands/utility/StartSleepCommand.cs",
"../monad/monad/src/commands/utility/TimeExpressionCommand.cs",
"../monad/monad/src/commands/utility/UnblockFile.cs",
"../monad/monad/src/commands/utility/UnregisterEventCommand.cs",
"../monad/monad/src/commands/utility/Update-Data.cs",
"../monad/monad/src/commands/utility/Update-TypeData.cs",
"../monad/monad/src/commands/utility/UtilityCommon.cs",
"../monad/monad/src/commands/utility/Var.cs",
"../monad/monad/src/commands/utility/WaitEventCommand.cs",
"../monad/monad/src/commands/utility/Write-Object.cs",
"../monad/monad/src/commands/utility/WriteAliasCommandBase.cs",
"../monad/monad/src/commands/utility/WriteConsoleCmdlet.cs",
"../monad/monad/src/commands/utility/WriteProgressCmdlet.cs",
"../monad/monad/src/commands/utility/compare-object.cs",
"../monad/monad/src/commands/utility/group-object.cs",
"../monad/monad/src/commands/utility/new-object.cs",
"../monad/monad/src/commands/utility/neweventcommand.cs",
"../monad/monad/src/commands/utility/select-object.cs",
"../monad/monad/src/commands/utility/sort-object.cs",
"../monad/monad/src/commands/utility/tee-object.cs",
"../monad/monad/src/commands/utility/write.cs"
],
"namedResource": {
"AddMember": "../monad-build/gen/COMMANDS_UTILITY/AddMember.resources",
"AddTypeStrings": "../monad-build/gen/COMMANDS_UTILITY/AddTypeStrings.resources",
"AliasCommandStrings": "../monad-build/gen/COMMANDS_UTILITY/AliasCommandStrings.resources",
"ConvertFromStringData": "../monad-build/gen/COMMANDS_UTILITY/ConvertFromStringData.resources",
"CsvCommandStrings": "../monad-build/gen/COMMANDS_UTILITY/CsvCommandStrings.resources",
"Debugger": "../monad-build/gen/COMMANDS_UTILITY/Debugger.resources",
"EventingStrings": "../monad-build/gen/COMMANDS_UTILITY/EventingStrings.resources",
"GetMember": "../monad-build/gen/COMMANDS_UTILITY/GetMember.resources",
"GetRandomCommandStrings": "../monad-build/gen/COMMANDS_UTILITY/GetRandomCommandStrings.resources",
"HostStrings": "../monad-build/gen/COMMANDS_UTILITY/HostStrings.resources",
"ImportLocalizedDataStrings": "../monad-build/gen/COMMANDS_UTILITY/ImportLocalizedDataStrings.resources",
"MatchStringStrings": "../monad-build/gen/COMMANDS_UTILITY/MatchStringStrings.resources",
"MeasureObjectStrings": "../monad-build/gen/COMMANDS_UTILITY/MeasureObjectStrings.resources",
"NewObjectStrings": "../monad-build/gen/COMMANDS_UTILITY/NewObjectStrings.resources",
"SelectObjectStrings": "../monad-build/gen/COMMANDS_UTILITY/SelectObjectStrings.resources",
"SortObjectStrings": "../monad-build/gen/COMMANDS_UTILITY/SortObjectStrings.resources",
"UpdateDataStrings": "../monad-build/gen/COMMANDS_UTILITY/UpdateDataStrings.resources",
"UtilityCommonStrings": "../monad-build/gen/COMMANDS_UTILITY/UtilityCommonStrings.resources",
"VariableCommandStrings": "../monad-build/gen/COMMANDS_UTILITY/VariableCommandStrings.resources",
"WriteErrorStrings": "../monad-build/gen/COMMANDS_UTILITY/WriteErrorStrings.resources",
"WriteProgressResourceStrings": "../monad-build/gen/COMMANDS_UTILITY/WriteProgressResourceStrings.resources"
}
}

View File

@ -3,4 +3,3 @@ using System.Reflection;
[assembly:InternalsVisibleTo("System.Management.Automation")]
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
{
"version": "1.0.0.0",
"description": "Microsoft.PowerShell.CoreCLR.AssemblyLoadContext Class",
"authors": [ "andschwa" ],
"compileFiles": [ "../monad/monad/src/CoreCLR/CorePsAssemblyLoadContext.cs" ],
"compilationOptions": { "define": [ "CORECLR", "LINUX" ] },
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"System.Runtime.Loader": "4.0.0-rc2-23616"
},
"frameworks": { "dnxcore50": { } }
}

View File

@ -1,4 +1,4 @@
namespace Microsoft.Samples.PowerShell.Host
namespace Microsoft.PowerShell.Linux.Host
{
using System;
using System.Globalization;
@ -13,15 +13,15 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
internal class MyHost : PSHost, IHostSupportsInteractiveSession
{
public MyHost(PSListenerConsoleSample program)
public MyHost(Listener Listener)
{
this.program = program;
this.Listener = Listener;
}
/// <summary>
/// A reference to the PSHost implementation.
/// </summary>
private PSListenerConsoleSample program;
private Listener Listener;
/// <summary>
/// The culture information of the thread that created
@ -88,7 +88,7 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public override string Name
{
get { return "MySampleConsoleHostImplementation"; }
get { return "PSL"; }
}
/// <summary>
@ -126,8 +126,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
public Runspace Runspace
{
get { return this.program.myRunSpace; }
internal set { this.program.myRunSpace = value; }
get { return this.Listener.myRunSpace; }
internal set { this.Listener.myRunSpace = value; }
}
#endregion IHostSupportsInteractiveSession Properties
@ -186,8 +186,8 @@ namespace Microsoft.Samples.PowerShell.Host
/// host application should use.</param>
public override void SetShouldExit(int exitCode)
{
this.program.ShouldExit = true;
this.program.ExitCode = exitCode;
this.Listener.ShouldExit = true;
this.Listener.ExitCode = exitCode;
}
#region IHostSupportsInteractiveSession Methods

View File

@ -1,4 +1,4 @@
namespace Microsoft.Samples.PowerShell.Host
namespace Microsoft.PowerShell.Linux.Host
{
using System;
using System.Collections.Generic;
@ -11,12 +11,84 @@ namespace Microsoft.Samples.PowerShell.Host
using System.Runtime.InteropServices;
using PowerShell = System.Management.Automation.PowerShell;
/// <summary>
/// This sample shows how to implement a basic read-evaluate-print
/// loop (or 'listener') that allowing you to interactively work
/// with the Windows PowerShell engine.
/// </summary>
internal class PSListenerConsoleSample
public static class Program
{
/// <summary>
/// Creates and initiates the listener instance.
/// </summary>
public static void Main(string[] args)
{
// Custom argument parsing
string initialScript = null;
if (args.Length > 0)
{
for (int i = 0; i < args.Length; ++i)
{
string arg = args[i];
bool hasNext = (i+1) < args.Length;
string nextArg = hasNext ? args[i+1] : string.Empty;
// lone argument is a script
if (!hasNext && arg.EndsWith(".ps1"))
{
initialScript = Path.GetFullPath(arg);
}
// lone argument is an inline script
else if (!hasNext)
{
initialScript = arg;
}
// --file <filePath> was specified
else if (hasNext && (arg == "--file" || arg == "-f"))
{
initialScript = Path.GetFullPath(nextArg);
++i;
}
// --command <string> was specified
else if (hasNext && (arg == "--command" || arg == "-c"))
{
if (nextArg == "-")
{
initialScript = "\"TODO: read stdin using Console.OpenStandardInput\"";
}
else
{
initialScript = nextArg;
}
++i;
}
// --working-dir (not on PowerShell for Windows, may be removed)
else if (hasNext && arg == "--working-dir")
{
Directory.SetCurrentDirectory(nextArg);
++i;
}
}
}
// TODO: check for input on stdin
// Create the listener and run it
Listener listener = new Listener(initialScript);
// only run if there was no script file passed in
if (initialScript == null)
{
// Display the welcome message.
Console.WriteLine();
Console.WriteLine("PowerShell for Linux interactive console");
Console.WriteLine("========================================");
Console.WriteLine();
Console.WriteLine("Current status:");
Console.WriteLine("- Type 'exit' to exit");
Console.WriteLine("- Utility and Management cmdlet modules are loadable");
Console.WriteLine();
listener.Run();
}
}
}
internal class Listener
{
/// <summary>
/// Used to read user input.
@ -74,84 +146,7 @@ namespace Microsoft.Samples.PowerShell.Host
set { this.exitCode = value; }
}
/// <summary>
/// Creates and initiates the listener instance.
/// </summary>
private static void Main(string[] args)
{
// Custom argument parsing
string initialScript = null;
if (args.Length > 0)
{
for (int i = 0; i < args.Length; ++i)
{
string arg = args[i];
bool hasNext = (i+1) < args.Length;
string nextArg = hasNext ? args[i+1] : string.Empty;
// lone argument is a script
if (!hasNext && arg.EndsWith(".ps1"))
{
initialScript = Path.GetFullPath(arg);
}
// lone argument is an inline script
else if (!hasNext)
{
initialScript = arg;
}
// --file <filePath> was specified
else if (hasNext && (arg == "--file" || arg == "-f"))
{
initialScript = Path.GetFullPath(nextArg);
++i;
}
// --command <string> was specified
else if (hasNext && (arg == "--command" || arg == "-c"))
{
if (nextArg == "-")
{
initialScript = "\"TODO: read stdin using Console.OpenStandardInput\"";
}
else
{
initialScript = nextArg;
}
++i;
}
// --working-dir (not on PowerShell for Windows, may be removed)
else if (hasNext && arg == "--working-dir")
{
Directory.SetCurrentDirectory(nextArg);
++i;
}
}
}
// TODO: check for input on stdin
// Create the listener and run it
PSListenerConsoleSample listener = new PSListenerConsoleSample(initialScript);
// only run if there was no script file passed in
if (initialScript == null)
{
// Display the welcome message.
Console.WriteLine();
Console.WriteLine("PowerShell for Linux interactive console");
Console.WriteLine("========================================");
Console.WriteLine();
Console.WriteLine("Current status:");
Console.WriteLine("- Type 'exit' to exit");
Console.WriteLine("- Utility and Management cmdlet modules are loadable");
Console.WriteLine();
listener.Run();
}
}
/// <summary>
/// Initializes a new instance of the PSListenerConsoleSample class.
/// </summary>
public PSListenerConsoleSample(string initialScript)
public Listener(string initialScript)
{
// Create the host and runspace instances for this interpreter.
// Note that this application does not support console files so
@ -205,12 +200,12 @@ namespace Microsoft.Samples.PowerShell.Host
if (this.myHost.IsRunspacePushed)
{
returnVal = string.Format("\n[{0}] PSL> ", this.myRunSpace.ConnectionInfo.ComputerName);
returnVal = string.Format($"{System.Environment.NewLine}[{this.myRunSpace.ConnectionInfo.ComputerName}] PSL> ");
return returnVal;
}
// TODO: if we are in block mode, sep the prome to ">> "
Pipeline pipeline = rs.CreatePipeline();
// TODO: if we are in block mode, sep the prompt to ">> "
Pipeline pipeline = rs.CreatePipeline();
Command promptCommand = new Command("prompt");
pipeline.Commands.Add(promptCommand);
@ -223,6 +218,7 @@ namespace Microsoft.Samples.PowerShell.Host
return returnVal;
}
/// <summary>
/// A helper class that builds and executes a pipeline that writes
/// to the default output path. Any exceptions that are thrown are
@ -409,7 +405,7 @@ namespace Microsoft.Samples.PowerShell.Host
/// reads a command from the user, executes it and repeats until the ShouldExit
/// flag is set.
/// </summary>
private void Run()
internal void Run()
{
// Set up the control-C handler.
Console.CancelKeyPress += new ConsoleCancelEventHandler(this.HandleControlC);
@ -422,7 +418,7 @@ namespace Microsoft.Samples.PowerShell.Host
string prompt = Prompt(this.myHost.Runspace);
this.myHost.UI.Write(ConsoleColor.White, ConsoleColor.Black, prompt);
string cmd = this.myHost.UI.ReadLine();
string cmd = consoleReadLine.Read(this.myHost.Runspace);
this.Execute(cmd);
}
@ -432,4 +428,3 @@ namespace Microsoft.Samples.PowerShell.Host
}
}
}

View File

@ -0,0 +1,28 @@
{
"version": "1.0.0-*",
"description": "PowerShell On Linux Console",
"authors": [ "andschwa" ],
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"Newtonsoft.Json": "8.0.1-beta3",
"Microsoft.PowerShell.Commands.Management": {
"type": "build",
"version": "1.0.0-*"
},
"Microsoft.PowerShell.Commands.Omi": {
"type": "build",
"version": "1.0.0-*"
},
"Microsoft.PowerShell.Commands.Utility": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } }
}

View File

@ -10,7 +10,7 @@ using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Microsoft.Samples.PowerShell.Host
namespace Microsoft.PowerShell.Linux.Host
{
// this is all from https://msdn.microsoft.com/en-us/library/ee706570%28v=vs.85%29.aspx

View File

@ -1,28 +1,79 @@
namespace Microsoft.Samples.PowerShell.Host
namespace Microsoft.PowerShell.Linux.Host
{
using System;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Text;
/// <summary>
/// This class is used to read the command line and color the text as
/// This class is used to read the command line and color the text as
/// it is entered. Tokens are determined using the PSParser.Tokenize
/// method.
/// </summary>
internal class ConsoleReadLine
{
/// <summary>
/// Holds a reference to the runspace (for history access).
/// </summary>
private Runspace runspace;
/// <summary>
/// Powershell instance for tabcompletion
/// </summary>
private PowerShell powershell = PowerShell.Create();
/// <summary>
/// The buffer used to edit.
/// </summary>
private StringBuilder buffer = new StringBuilder();
/// <summary>
/// integeger for tracking up and down arrow history
/// </summary>
private int historyIndex;
/// <summary>
/// Used for storing tab completion
/// </summary>
private CommandCompletion cmdCompleteOpt;
/// <summary>
/// The position of the cursor within the buffer.
/// </summary>
private int current;
/// <summary>
/// Detects previously pressed key for TabCompletion
/// </summary>
/// <summary>
private ConsoleKeyInfo previousKeyPress;
/// <summary>
/// Retains TabCompletion position
/// </summary>
private int tabCompletionPos;
/// <summary>
/// History Queue
/// </summary>
private Collection<PSObject> historyResult;
/// <summary>
/// Hashtable for command completion options
/// </summary>
private System.Collections.Hashtable options = new System.Collections.Hashtable();
/// <summary>
/// Retain original buffer for TabCompletion
/// </summary>
private StringBuilder tabBuffer;
/// <summary>
/// tabbuffer for storing result of tabcompletion
/// </summary>
private string tabResult;
/// The count of characters in buffer rendered.
/// </summary>
private int rendered;
@ -30,7 +81,7 @@ namespace Microsoft.Samples.PowerShell.Host
/// <summary>
/// Store the anchor and handle cursor movement
/// </summary>
//private Cursor cursor;
private Cursor cursor;
/// <summary>
/// The array of colors for tokens, indexed by PSTokenType
@ -69,7 +120,7 @@ namespace Microsoft.Samples.PowerShell.Host
ConsoleColor.DarkCyan, // StatementSeparator
this.defaultColor, // NewLine
this.defaultColor, // LineContinuation
this.defaultColor, // Position
this.defaultColor, // Position
};
}
@ -77,30 +128,27 @@ namespace Microsoft.Samples.PowerShell.Host
/// Read a line of text, colorizing while typing.
/// </summary>
/// <returns>The command line read</returns>
public string Read()
public string Read(Runspace runspace)
{
this.runspace = runspace;
this.Initialize();
while (true)
{
// no support for Console.ReadKey in CoreCLR yet
int key = Console.Read();
char keyChar = Convert.ToChar(key);
this.Insert(keyChar);
/*
ConsoleKeyInfo key = Console.ReadKey(true);
switch (key.Key)
{
case ConsoleKey.Backspace:
case ConsoleKey.Backspace:
this.OnBackspace();
break;
case ConsoleKey.Delete:
case ConsoleKey.Delete:
this.OnDelete();
break;
case ConsoleKey.Enter:
case ConsoleKey.Enter:
previousKeyPress = key;
return this.OnEnter();
case ConsoleKey.RightArrow:
case ConsoleKey.RightArrow:
this.OnRight(key.Modifiers);
break;
case ConsoleKey.LeftArrow:
@ -115,14 +163,21 @@ namespace Microsoft.Samples.PowerShell.Host
case ConsoleKey.End:
this.OnEnd();
break;
case ConsoleKey.Tab:
this.OnTab();
break;
case ConsoleKey.UpArrow:
this.OnUpArrow();
break;
case ConsoleKey.DownArrow:
case ConsoleKey.LeftWindows:
case ConsoleKey.RightWindows:
// ignore these
continue;
this.OnDownArrow();
break;
// TODO: case ConsoleKey.LeftWindows: not available in linux
// TODO: case ConsoleKey.RightWindows: not available in linux
default:
if (key.KeyChar == '\x0D')
{
goto case ConsoleKey.Enter; // Ctrl-M
@ -133,9 +188,12 @@ namespace Microsoft.Samples.PowerShell.Host
goto case ConsoleKey.Backspace; // Ctrl-H
}
this.Insert(key);
break;
}*/
this.Insert(key.KeyChar);
this.Render();
break;
}
previousKeyPress = key;
}
}
@ -144,10 +202,12 @@ namespace Microsoft.Samples.PowerShell.Host
/// </summary>
private void Initialize()
{
this.buffer.Length = 0;
this.tabCompletionPos = 0;
this.historyIndex = 0;
this.buffer.Length = 0;
this.current = 0;
this.rendered = 0;
//this.cursor = new Cursor();
this.cursor = new Cursor();
}
/// <summary>
@ -162,9 +222,8 @@ namespace Microsoft.Samples.PowerShell.Host
this.Render();
}
/*
/// <summary>
/// The End key was enetered..
/// The End key was entered.
/// </summary>
private void OnEnd()
{
@ -172,12 +231,77 @@ namespace Microsoft.Samples.PowerShell.Host
this.cursor.Place(this.rendered);
}
/// <summary>
/// The Tab key was entered
/// </summary>
private void OnTab()
{
//if the prompt is empty simply return
if (String.IsNullOrWhiteSpace(this.buffer.ToString()) || this.buffer.Length == 0){
return;
}
//if the buffer has been modified in any way, get the new command completion
if (previousKeyPress.Key != ConsoleKey.Tab || previousKeyPress.Key == ConsoleKey.Enter || previousKeyPress.Key == ConsoleKey.Escape || previousKeyPress.Key == ConsoleKey.Backspace || previousKeyPress.Key == ConsoleKey.Delete)
{
tabBuffer = this.buffer;
cmdCompleteOpt = CommandCompletion.CompleteInput(this.tabBuffer.ToString(), this.current, options, powershell);
}
try
{
tabResult = cmdCompleteOpt.CompletionMatches[tabCompletionPos].CompletionText;
}
catch (Exception)
{
return;
}
tabCompletionPos++;
//if there is a command for the user before the uncompleted option
if (!String.IsNullOrEmpty(tabResult))
{
//handle file path slashes
if (tabResult.Contains(".\\"))
{
tabResult = tabResult.Replace(".\\", "");
}
if (this.buffer.ToString().Contains(" "))
{
var replaceIndex = cmdCompleteOpt.ReplacementIndex;
string replaceBuffer = this.buffer.ToString();
replaceBuffer = replaceBuffer.Remove(replaceIndex);
tabResult = replaceBuffer + tabResult;
}
BufferFromString(tabResult);
this.Render();
}
} //end of OnTab()
/// <summary>
/// Set buffer to a string rather than inserting char by char
/// </summary>
private void BufferFromString(string endResult)
{
//reset prompt and buffer
OnEscape();
this.buffer.Append(endResult);
this.current += endResult.Length;
}
/// <summary>
/// The Home key was eneterd.
/// The Home key was entered.
/// </summary>
private void OnHome()
{
this.current = 0;
this.current = 0;
this.cursor.Reset();
}
@ -191,10 +315,96 @@ namespace Microsoft.Samples.PowerShell.Host
this.Render();
}
/// <summary>
/// The up arrow was pressed to retrieve history
/// </summary>
private void OnDownArrow() {
if (historyIndex == historyResult.Count)
{
OnEscape();
}
historyIndex++;
try
{
BufferFromString(historyResult[historyIndex].Members["CommandLine"].Value.ToString()); this.Render();
}
catch
{
return;
}
}
/// <summary>
/// Changes the history queue when the down arrow is pressed
/// </summary>
private void OnUpArrow()
{
if ((previousKeyPress.Key != ConsoleKey.DownArrow && previousKeyPress.Key != ConsoleKey.UpArrow) || previousKeyPress.Key == ConsoleKey.Enter)
{
//first time getting the history
using (Pipeline pipeline = this.runspace.CreatePipeline("Get-History"))
{
historyResult = pipeline.Invoke();
}
try
{
historyIndex = historyResult.Count -1;
BufferFromString(historyResult[historyIndex].Members["CommandLine"].Value.ToString());
this.Render();
historyIndex--;
}
catch
{
return;
}
}
else
{
if (historyIndex > historyResult.Count) //we hit the blank prompt using the down arrow
{
historyIndex = historyResult.Count -1;
}
if ( historyIndex < 0 )
{
historyIndex = 0;
}
try
{
BufferFromString(historyResult[historyIndex].Members["CommandLine"].Value.ToString());
this.Render();
if ( historyIndex == 0 )
{
return;
}
else
{
historyIndex--;
}
}
catch
{
return;
}
}
}
/// <summary>
/// Moves to the left of the cursor position.
/// </summary>
/// <param name="consoleModifiers">Enumeration for Alt, Control,
/// <param name="consoleModifiers">Enumeration for Alt, Control,
/// and Shift keys.</param>
private void OnLeft(ConsoleModifiers consoleModifiers)
{
@ -226,23 +436,22 @@ namespace Microsoft.Samples.PowerShell.Host
this.MoveLeft();
}
}
*/
/// <summary>
/// Determines if a character is a seperator.
/// </summary>
/// <param name="ch">Character to investigate.</param>
/// <returns>A value that indicates whether the character
/// <returns>A value that indicates whether the character
/// is a seperator.</returns>
private static bool IsSeperator(char ch)
{
return !Char.IsLetter(ch);
}
/*
/// <summary>
/// Moves to what is to the right of the cursor position.
/// </summary>
/// <param name="consoleModifiers">Enumeration for Alt, Control,
/// <param name="consoleModifiers">Enumeration for Alt, Control,
/// and Shift keys.</param>
private void OnRight(ConsoleModifiers consoleModifiers)
{
@ -311,7 +520,7 @@ namespace Microsoft.Samples.PowerShell.Host
/// <returns>A newline character.</returns>
private string OnEnter()
{
Console.Out.Write("\n");
Console.Out.WriteLine();
return this.buffer.ToString();
}
@ -339,12 +548,14 @@ namespace Microsoft.Samples.PowerShell.Host
this.Render();
}
}
*/
/// <summary>
/// Displays the line.
/// </summary>
private void Render()
{
this.cursor.Reset();
string text = this.buffer.ToString();
// The PowerShell tokenizer is used to decide how to colorize
@ -357,7 +568,8 @@ namespace Microsoft.Samples.PowerShell.Host
{
// We can skip rendering tokens that end before the cursor.
int i;
for (i = 0; i < tokens.Count; ++i)
for (i = 0; i < tokens.Count; ++i)
{
if (this.current >= tokens[i].Start)
{
@ -402,7 +614,7 @@ namespace Microsoft.Samples.PowerShell.Host
// If tokenization completely failed, just redraw the whole line. This
// happens most frequently when the first token is incomplete, like a string
// literal missing a closing quote.
//this.cursor.Reset();
this.cursor.Reset();
Console.Out.Write(text);
}
@ -413,10 +625,9 @@ namespace Microsoft.Samples.PowerShell.Host
}
this.rendered = text.Length;
//this.cursor.Place(this.current);
this.cursor.Place(this.current);
}
/*
/// <summary>
/// A helper class for maintaining the cursor while editing the command line.
/// </summary>
@ -479,7 +690,5 @@ namespace Microsoft.Samples.PowerShell.Host
Console.CursorTop = cursorTop;
}
} // End Cursor
*/
}
}

View File

@ -1,4 +1,4 @@
namespace Microsoft.Samples.PowerShell.Host
namespace Microsoft.PowerShell.Linux.Host
{
using System;
using System.Collections.Generic;
@ -47,7 +47,7 @@ namespace Microsoft.Samples.PowerShell.Host
this.Write(
ConsoleColor.White,
ConsoleColor.Black,
caption + "\n" + message + " ");
caption + System.Environment.NewLine + message + " ");
Dictionary<string, PSObject> results =
new Dictionary<string, PSObject>();
foreach (FieldDescription fd in descriptions)
@ -89,7 +89,7 @@ namespace Microsoft.Samples.PowerShell.Host
this.WriteLine(
ConsoleColor.Blue,
ConsoleColor.Black,
caption + "\n" + message + "\n");
caption + System.Environment.NewLine + message + System.Environment.NewLine);
// Convert the choice collection into something that is
// easier to work with. See the BuildHotkeysAndPlainLabels
@ -163,7 +163,7 @@ namespace Microsoft.Samples.PowerShell.Host
this.WriteLine(
ConsoleColor.Blue,
ConsoleColor.Black,
caption + "\n" + message + "\n");
caption + System.Environment.NewLine + message + System.Environment.NewLine);
// Convert the choice collection into something that is
// easier to work with. See the BuildHotkeysAndPlainLabels
@ -416,10 +416,27 @@ ReadNext:
/// </summary>
/// <param name="sourceId">Unique identifier of the source of the record. </param>
/// <param name="record">A ProgressReport object.</param>
public override void WriteProgress(long sourceId, ProgressRecord record)
{
public override void WriteProgress(long sourceId, ProgressRecord record)
{
if (record == null)
{
throw PSTraceSource.NewArgumentNullException("record");
}
}
string percentComplete = " [";
for (int i =0; i < record.PercentComplete; i++){
percentComplete = percentComplete + "0";
}
percentComplete = percentComplete + "]";
Console.Write ("\r{0} {1} {2} ", record.Activity, record.StatusDescription, percentComplete, "\r");
if (record.PercentComplete == 100){
Console.WriteLine(); //create a new line for the prompt
}
}
/// <summary>
/// Writes a verbose message to the output display of the host.

View File

@ -0,0 +1,166 @@
namespace PSTests
{
using System;
using System.Globalization;
using System.Management.Automation.Host;
/// <summary>
/// This is a sample implementation of the PSHost abstract class for
/// console applications. Not all members are implemented. Those that
/// are not implemented throw a NotImplementedException exception or
/// return nothing.
/// </summary>
internal class MyHost : PSHost
{
/// <summary>
/// A reference to the PSHost implementation.
/// </summary>
private RunspaceTests program;
/// <summary>
/// The culture information of the thread that created
/// this object.
/// </summary>
private CultureInfo originalCultureInfo =
CultureInfo.CurrentCulture;
// System.Threading.Thread.CurrentThread.CurrentCulture;
/// <summary>
/// The UI culture information of the thread that created
/// this object.
/// </summary>
private CultureInfo originalUICultureInfo =
CultureInfo.CurrentCulture;
// System.Threading.Thread.CurrentThread.CurrentUICulture;
/// <summary>
/// The identifier of this PSHost implementation.
/// </summary>
private Guid myId = Guid.NewGuid();
/// <summary>
/// Initializes a new instance of the MyHost class. Keep
/// a reference to the host application object so that it
/// can be informed of when to exit.
/// </summary>
/// <param name="program">
/// A reference to the host application object.
/// </param>
public MyHost(RunspaceTests program)
{
this.program = program;
}
/// <summary>
/// Return the culture information to use. This implementation
/// returns a snapshot of the culture information of the thread
/// that created this object.
/// </summary>
public override System.Globalization.CultureInfo CurrentCulture
{
get { return this.originalCultureInfo; }
}
/// <summary>
/// Return the UI culture information to use. This implementation
/// returns a snapshot of the UI culture information of the thread
/// that created this object.
/// </summary>
public override System.Globalization.CultureInfo CurrentUICulture
{
get { return this.originalUICultureInfo; }
}
/// <summary>
/// This implementation always returns the GUID allocated at
/// instantiation time.
/// </summary>
public override Guid InstanceId
{
get { return this.myId; }
}
/// <summary>
/// Return a string that contains the name of the host implementation.
/// Keep in mind that this string may be used by script writers to
/// identify when your host is being used.
/// </summary>
public override string Name
{
get { return "MySampleConsoleHostImplementation"; }
}
/// <summary>
/// This sample does not implement a PSHostUserInterface component so
/// this property simply returns null.
/// </summary>
public override PSHostUserInterface UI
{
get { return null; }
}
/// <summary>
/// Return the version object for this application. Typically this
/// should match the version resource in the application.
/// </summary>
public override Version Version
{
get { return new Version(1, 0, 0, 0); }
}
/// <summary>
/// Not implemented by this example class. The call fails with
/// a NotImplementedException exception.
/// </summary>
public override void EnterNestedPrompt()
{
throw new NotImplementedException(
"The method or operation is not implemented.");
}
/// <summary>
/// Not implemented by this example class. The call fails
/// with a NotImplementedException exception.
/// </summary>
public override void ExitNestedPrompt()
{
throw new NotImplementedException(
"The method or operation is not implemented.");
}
/// <summary>
/// This API is called before an external application process is
/// started. Typically it is used to save state so the parent can
/// restore state that has been modified by a child process (after
/// the child exits). In this example, this functionality is not
/// needed so the method returns nothing.
/// </summary>
public override void NotifyBeginApplication()
{
return;
}
/// <summary>
/// This API is called after an external application process finishes.
/// Typically it is used to restore state that a child process may
/// have altered. In this example, this functionality is not
/// needed so the method returns nothing.
/// </summary>
public override void NotifyEndApplication()
{
return;
}
/// <summary>
/// Indicate to the host application that exit has
/// been requested. Pass the exit code that the host
/// application should use when exiting the process.
/// </summary>
/// <param name="exitCode">The exit code to use.</param>
public override void SetShouldExit(int exitCode)
{
// this.program.ShouldExit = true;
// this.program.ExitCode = exitCode;
}
}
}

View File

@ -0,0 +1,17 @@
{
"version": "1.0.0-*",
"description": "PowerShell On Linux xUnit Tests",
"authors": [ "andschwa" ],
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"Microsoft.PowerShell.Linux.Host": {
"type": "build",
"version": "1.0.0-*"
},
"xunit": "2.1.0-*",
"xunit.runner.dnx": "2.1.0-*"
},
"frameworks": { "dnxcore50": { } }
}

View File

@ -0,0 +1,71 @@
using Xunit;
using System;
using System.Management.Automation;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace PSTests
{
public static class OmiInterfaceTests
{
[Fact]
public static void TestHostName()
{
const string ns = "root/omi";
const string cn = "OMI_Identify";
const string property = "SystemName";
string expected = null;
var startInfo = new ProcessStartInfo
{
FileName = @"/usr/bin/env",
Arguments = "hostname",
RedirectStandardOutput = true,
UseShellExecute = false
};
using (Process process = Process.Start(startInfo))
{
// Get output of call to hostname without trailing newline
expected = process.StandardOutput.ReadToEnd().Trim();
process.WaitForExit();
// The process should return an exit code of 0 on success
Assert.Equal(0, process.ExitCode);
}
string value = null;
OmiInterface oi = new OmiInterface();
oi.GetOmiValue(ns, cn, property, out value);
Assert.Equal(expected, value);
}
[Fact]
public static void TestXHugeNumberEnumerable()
{
const string ns = "interop";
const string cn = "X_HugeNumber";
OmiInterface oi = new OmiInterface();
IEnumerable<XElement> elements;
oi.GetOmiValues(ns, cn, out elements);
Assert.True(elements.FirstOrDefault() != null);
}
[Fact]
public static void TestXHugeNumberOmiData()
{
const string ns = "interop";
const string cn = "X_HugeNumber";
OmiInterface oi = new OmiInterface();
OmiData data;
oi.GetOmiValues(ns, cn, out data);
Assert.True(data != null);
Assert.Equal(data.Values.Count(), 22);
}
}
}

View File

@ -0,0 +1,141 @@
using Xunit;
using System;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
namespace PSTests
{
// NOTE: do not call AddCommand("out-host") after invoking or MergeMyResults,
// otherwise Invoke will not return any objects
public class RunspaceTests
{
private static int count = 3;
private static string script = String.Format($"get-process | select-object -first {count}");
[Fact]
public void TestRunspaceWithPipeline()
{
using (Runspace runspace = RunspaceFactory.CreateRunspace())
{
runspace.Open();
using (var pipeline = runspace.CreatePipeline(script))
{
int objCount = 0;
foreach (var result in pipeline.Invoke())
{
++objCount;
Assert.NotNull(result);
}
Assert.Equal(count, objCount);
}
runspace.Close();
}
}
[Fact]
public void TestRunspaceWithPowerShell()
{
using (var runspace = RunspaceFactory.CreateRunspace())
{
runspace.Open();
using (PowerShell powerShell = PowerShell.Create())
{
powerShell.Runspace = runspace;
powerShell.AddScript(script);
int objCount = 0;
foreach (var result in powerShell.Invoke())
{
++objCount;
Assert.NotNull(result);
}
Assert.Equal(count, objCount);
}
runspace.Close();
}
}
[Fact]
public void TestRunspaceWithPowerShellAndHost()
{
MyHost myHost = new MyHost(this);
using (var runspace = RunspaceFactory.CreateRunspace(myHost))
{
runspace.Open();
using (PowerShell powerShell = PowerShell.Create())
{
powerShell.Runspace = runspace;
powerShell.AddScript(script);
int objCount = 0;
foreach (var result in powerShell.Invoke())
{
++objCount;
Assert.NotNull(result);
}
Assert.Equal(count, objCount);
}
runspace.Close();
}
}
[Fact]
public void TestRunspaceWithFunction()
{
MyHost myHost = new MyHost(this);
using (var runspace = RunspaceFactory.CreateRunspace(myHost))
{
runspace.Open();
using (PowerShell powerShell = PowerShell.Create())
{
powerShell.Runspace = runspace;
powerShell.AddScript("{1}.Invoke()");
powerShell.Invoke();
}
runspace.Close();
}
}
[Fact]
public void TestRunspaceWithPowerShellAndInitialSessionState()
{
InitialSessionState iss = InitialSessionState.CreateDefault2();
// NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output
// in addition to just the PSObjects
using (Runspace runspace = RunspaceFactory.CreateRunspace(/*myHost,*/iss))
{
runspace.Open();
using (PowerShell powerShell = PowerShell.Create())
{
powerShell.Runspace = runspace;
powerShell.AddScript(script);
int objCount = 0;
foreach (var result in powerShell.Invoke())
{
// this is how an object would be captured here and looked at,
// each result is a PSObject with the data from the pipeline
++objCount;
Assert.NotNull(result);
}
Assert.Equal(count, objCount);
powerShell.Dispose();
}
}
}
}
}

View File

@ -0,0 +1,4 @@
using System.Reflection;
[assembly:AssemblyFileVersionAttribute("3.0.0.0")]
[assembly:AssemblyVersion("3.0.0.0")]

View File

@ -0,0 +1,45 @@
{
"version": "1.0.0-*",
"description": "Microsoft.PowerShell.Security Library",
"authors": [ "garretts", "andschwa" ],
"compilationOptions": {
"define": [
"CORECLR",
"_CORECLR",
"LINUX"
],
"allowUnsafe": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"System.Management.Automation": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } },
"compile": [ "../monad-build/gen/SECURITY/*.cs" ],
"compileFiles": [
"../monad/monad/src/security/AclCommands.cs",
"../monad/monad/src/security/CertificateProvider.cs",
"../monad/monad/src/security/CredentialCommands.cs",
"../monad/monad/src/security/ExecutionPolicyCommands.cs",
"../monad/monad/src/security/SecureStringCommands.cs",
"../monad/monad/src/security/SignatureCommands.cs",
"../monad/monad/src/security/Utils.cs",
"../monad/monad/src/security/certificateproviderexceptions.cs"
],
"namedResource": {
"CertificateProviderStrings": "../monad-build/gen/SECURITY/CertificateProviderStrings.resources",
"ExecutionPolicyCommands": "../monad-build/gen/SECURITY/ExecutionPolicyCommands.resources",
"SecureStringCommands": "../monad-build/gen/SECURITY/SecureStringCommands.resources",
"SignatureCommands": "../monad-build/gen/SECURITY/SignatureCommands.resources",
"UtilsStrings": "../monad-build/gen/SECURITY/UtilsStrings.resources"
}
}

View File

@ -0,0 +1,24 @@
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly:InternalsVisibleTo("Microsoft.PowerShell.Commands.Management")]
[assembly:InternalsVisibleTo("Microsoft.PowerShell.Commands.Utility")]
[assembly:InternalsVisibleTo("Microsoft.PowerShell.Security")]
[assembly:InternalsVisibleTo("Microsoft.PowerShell.CoreCLR.AssemblyLoadContext")]
[assembly:InternalsVisibleTo("Microsoft.PowerShell.Linux.Host")]
[assembly:InternalsVisibleTo("Microsoft.PowerShell.Linux.UnitTests")]
[assembly:AssemblyFileVersionAttribute("3.0.0.0")]
[assembly:AssemblyVersion("3.0.0.0")]
namespace System.Management.Automation
{
internal class NTVerpVars
{
internal const int PRODUCTMAJORVERSION = 10;
internal const int PRODUCTMINORVERSION = 0;
internal const int PRODUCTBUILD = 10032;
internal const int PRODUCTBUILD_QFE = 0;
internal const int PACKAGEBUILD_QFE = 814;
}
}

View File

@ -0,0 +1,703 @@
{
"name": "System.Management.Automation",
"version": "1.0.0-*",
"description": "System.Management.Automation Library",
"authors": [ "garretts", "andschwa" ],
"compilationOptions": {
"define": [
"CORECLR",
"_CORECLR",
"LINUX"
],
"allowUnsafe": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"Microsoft.CSharp": "4.0.1-rc2-23616",
"Microsoft.Win32.Registry.AccessControl": "4.0.0-rc2-23616",
"System.Collections.Specialized": "4.0.1-rc2-23616",
"System.ComponentModel.EventBasedAsync": "4.0.11-rc2-23616",
"System.ComponentModel.TypeConverter": "4.0.1-rc2-23616",
"System.Data.Common": "4.0.1-rc2-23616",
"System.Diagnostics.Contracts": "4.0.1-rc2-23616",
"System.Diagnostics.FileVersionInfo": "4.0.0-rc2-23616",
"System.Diagnostics.TraceSource": "4.0.0-rc2-23616",
"System.Dynamic.Runtime": "4.0.11-rc2-23616",
"System.IO.FileSystem.AccessControl": "4.0.0-rc2-23616",
"System.IO.FileSystem.DriveInfo": "4.0.0-rc2-23616",
"System.IO.FileSystem.Watcher": "4.0.0-rc2-23616",
"System.IO.Pipes": "4.0.0-rc2-23616",
"System.Linq.Expressions": "4.0.11-rc2-23616",
"System.Net.Http": "4.0.1-rc2-23616",
"System.Net.NetworkInformation": "4.1.0-rc2-23616",
"System.Reflection.Emit.Lightweight": "4.0.1-rc2-23616",
"System.Security.AccessControl": "4.0.0-rc2-23616",
"System.Security.Cryptography.Algorithms": "4.0.0-rc2-23616",
"System.Security.Cryptography.X509Certificates": "4.0.0-rc2-23616",
"System.Threading.Tasks.Parallel": "4.0.1-rc2-23616",
"System.Xml.XPath.XmlDocument": "4.0.1-rc2-23616",
"System.Xml.XmlDocument": "4.0.1-rc2-23616",
"System.Xml.XmlSerializer": "4.0.11-rc2-23616",
"Microsoft.Management.Infrastructure" : {
"type": "build",
"version": "1.0.0-*"
},
"Microsoft.PowerShell.CoreCLR.AssemblyLoadContext": {
"type": "build",
"version": "1.0.0-*"
}
},
"frameworks": { "dnxcore50": { } },
"compile" : [ "../monad-build/gen/SYS_AUTO/*.cs" ],
"compileFiles": [
"../monad/monad/src/CoreCLR/CorePsExtensions.cs",
"../monad/monad/src/CoreCLR/CorePsPlatform.cs",
"../monad/monad/src/CoreCLR/CorePsStub.cs",
"../monad/monad/src/DscSupport/CimDSCParser.cs",
"../monad/monad/src/cimSupport/cmdletization/EnumWriter.cs",
"../monad/monad/src/cimSupport/cmdletization/MethodInvocationInfo.cs",
"../monad/monad/src/cimSupport/cmdletization/MethodParameter.cs",
"../monad/monad/src/cimSupport/cmdletization/MethodParametersCollection.cs",
"../monad/monad/src/cimSupport/cmdletization/ObjectModelWrapper.cs",
"../monad/monad/src/cimSupport/cmdletization/QueryBuilder.cs",
"../monad/monad/src/cimSupport/cmdletization/ScriptWriter.cs",
"../monad/monad/src/cimSupport/cmdletization/cim/WildcardPatternToCimQueryParser.cs",
"../monad/monad/src/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.objectModel.autogen.cs",
"../monad/monad/src/cimSupport/cmdletization/xml/CoreCLR/cmdlets-over-objects.xmlSerializer.autogen.cs",
"../monad/monad/src/cimSupport/other/ciminstancetypeadapter.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/BaseCommand.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/BaseFormattingCommand.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/BaseFormattingCommandParameters.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/BaseOutputtingCommand.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/ColumnWidthManager.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/ComplexWriter.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/FormatTable.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/XmlLoaderBase.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/commands.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionDataMethods.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Complex.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Misc.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataQuery.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Complex.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_List.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Table.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Wide.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatGroupManager.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatMsgCtxManager.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatViewGenerator.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatViewGenerator_Complex.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatViewGenerator_List.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatViewGenerator_Table.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatViewGenerator_Wide.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatViewManager.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormatXMLWriter.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormattingObjects.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/FormattingObjectsDeserializer.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/ILineOutput.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/ListWriter.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/OutputManager.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/OutputQueue.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/TableWriter.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/Utilities/MshObjectUtil.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/Utilities/MshParameter.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/Utilities/MshParameterAssociation.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/common/Utilities/Mshexpression.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/format-default/format-default.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/out-console/ConsoleLineOutput.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/out-console/OutConsole.cs",
"../monad/monad/src/commands/utility/FormatAndOutput/out-textInterface/OutTextInterface.cs",
"../monad/monad/src/engine/AliasInfo.cs",
"../monad/monad/src/engine/ApplicationInfo.cs",
"../monad/monad/src/engine/ArgumentTypeConverterAttribute.cs",
"../monad/monad/src/engine/Attributes.cs",
"../monad/monad/src/engine/AutomationEngine.cs",
"../monad/monad/src/engine/AutomationNull.cs",
"../monad/monad/src/engine/COM/ComAdapter.cs",
"../monad/monad/src/engine/COM/ComDispatch.cs",
"../monad/monad/src/engine/COM/ComInvoker.cs",
"../monad/monad/src/engine/COM/ComMethod.cs",
"../monad/monad/src/engine/COM/ComProperty.cs",
"../monad/monad/src/engine/COM/ComTypeInfo.cs",
"../monad/monad/src/engine/COM/ComUtil.cs",
"../monad/monad/src/engine/ChildrenCmdletProviderInterfaces.cs",
"../monad/monad/src/engine/CmdletFamilyProviderInterfaces.cs",
"../monad/monad/src/engine/CmdletInfo.cs",
"../monad/monad/src/engine/CmdletParameterBinderController.cs",
"../monad/monad/src/engine/CommandBase.cs",
"../monad/monad/src/engine/CommandCompletion/CommandCompletion.cs",
"../monad/monad/src/engine/CommandCompletion/CompletionAnalysis.cs",
"../monad/monad/src/engine/CommandCompletion/CompletionCompleters.cs",
"../monad/monad/src/engine/CommandCompletion/CompletionExecutionHelper.cs",
"../monad/monad/src/engine/CommandCompletion/CompletionResult.cs",
"../monad/monad/src/engine/CommandCompletion/ExtensibleCompletion.cs",
"../monad/monad/src/engine/CommandCompletion/PseudoParameterBinder.cs",
"../monad/monad/src/engine/CommandDiscovery.cs",
"../monad/monad/src/engine/CommandFactory.cs",
"../monad/monad/src/engine/CommandInfo.cs",
"../monad/monad/src/engine/CommandMetadata.cs",
"../monad/monad/src/engine/CommandParameter.cs",
"../monad/monad/src/engine/CommandPathSearch.cs",
"../monad/monad/src/engine/CommandProcessor.cs",
"../monad/monad/src/engine/CommandProcessorBase.cs",
"../monad/monad/src/engine/CommandSearcher.cs",
"../monad/monad/src/engine/CommonCommandParameters.cs",
"../monad/monad/src/engine/CompiledCommandParameter.cs",
"../monad/monad/src/engine/ConfigurationInfo.cs",
"../monad/monad/src/engine/ContentCmdletProviderInterfaces.cs",
"../monad/monad/src/engine/CoreAdapter.cs",
"../monad/monad/src/engine/Credential.cs",
"../monad/monad/src/engine/CultureVariable.cs",
"../monad/monad/src/engine/DataStoreAdapter.cs",
"../monad/monad/src/engine/DataStoreAdapterProvider.cs",
"../monad/monad/src/engine/DefaultCommandRuntime.cs",
"../monad/monad/src/engine/DriveInterfaces.cs",
"../monad/monad/src/engine/DriveNames.cs",
"../monad/monad/src/engine/DscResourceInfo.cs",
"../monad/monad/src/engine/DscResourceSearcher.cs",
"../monad/monad/src/engine/EngineIntrinsics.cs",
"../monad/monad/src/engine/EnumExpressionEvaluator.cs",
"../monad/monad/src/engine/EnumMinimumDisambiguation.cs",
"../monad/monad/src/engine/ErrorPackage.cs",
"../monad/monad/src/engine/EventManager.cs",
"../monad/monad/src/engine/ExecutionContext.cs",
"../monad/monad/src/engine/ExtendedTypeSystemException.cs",
"../monad/monad/src/engine/ExternalScriptInfo.cs",
"../monad/monad/src/engine/FilterInfo.cs",
"../monad/monad/src/engine/FunctionInfo.cs",
"../monad/monad/src/engine/GetCommandCommand.cs",
"../monad/monad/src/engine/GetEvent_Types_Ps1Xml.generated.cs",
"../monad/monad/src/engine/ICommandRuntime.cs",
"../monad/monad/src/engine/InformationRecord.cs",
"../monad/monad/src/engine/InitialSessionState.cs",
"../monad/monad/src/engine/InternalCommands.cs",
"../monad/monad/src/engine/InvocationInfo.cs",
"../monad/monad/src/engine/ItemCmdletProviderInterfaces.cs",
"../monad/monad/src/engine/LanguagePrimitives.cs",
"../monad/monad/src/engine/MergedCommandParameterMetadata.cs",
"../monad/monad/src/engine/MinishellParameterBinderController.cs",
"../monad/monad/src/engine/Modules/AnalysisCache.cs",
"../monad/monad/src/engine/Modules/ExportModuleMemberCommand.cs",
"../monad/monad/src/engine/Modules/GetModuleCommand.cs",
"../monad/monad/src/engine/Modules/ImportModuleCommand.cs",
"../monad/monad/src/engine/Modules/ModuleCmdletBase.cs",
"../monad/monad/src/engine/Modules/ModuleIntrinsics.cs",
"../monad/monad/src/engine/Modules/ModuleSpecification.cs",
"../monad/monad/src/engine/Modules/ModuleUtils.cs",
"../monad/monad/src/engine/Modules/NewModuleCommand.cs",
"../monad/monad/src/engine/Modules/NewModuleManifestCommand.cs",
"../monad/monad/src/engine/Modules/PSModuleInfo.cs",
"../monad/monad/src/engine/Modules/RemoteDiscoveryHelper.cs",
"../monad/monad/src/engine/Modules/RemoveModuleCommand.cs",
"../monad/monad/src/engine/Modules/ScriptAnalysis.cs",
"../monad/monad/src/engine/Modules/TestModuleManifestCommand.cs",
"../monad/monad/src/engine/MshCmdlet.cs",
"../monad/monad/src/engine/MshCommandRuntime.cs",
"../monad/monad/src/engine/MshMemberInfo.cs",
"../monad/monad/src/engine/MshObject.cs",
"../monad/monad/src/engine/MshReference.cs",
"../monad/monad/src/engine/MshSecurityException.cs",
"../monad/monad/src/engine/MshSnapinQualifiedName.cs",
"../monad/monad/src/engine/NativeCommand.cs",
"../monad/monad/src/engine/NativeCommandParameterBinder.cs",
"../monad/monad/src/engine/NativeCommandParameterBinderController.cs",
"../monad/monad/src/engine/NativeCommandProcessor.cs",
"../monad/monad/src/engine/NullString.cs",
"../monad/monad/src/engine/ObjectEventRegistrationBase.cs",
"../monad/monad/src/engine/PSClassInfo.cs",
"../monad/monad/src/engine/PSClassSearcher.cs",
"../monad/monad/src/engine/PSVersionInfo.cs",
"../monad/monad/src/engine/ParameterBinderBase.cs",
"../monad/monad/src/engine/ParameterBinderController.cs",
"../monad/monad/src/engine/ParameterInfo.cs",
"../monad/monad/src/engine/ParameterSetInfo.cs",
"../monad/monad/src/engine/ParameterSetPromptingData.cs",
"../monad/monad/src/engine/ParameterSetSpecificMetadata.cs",
"../monad/monad/src/engine/PathInterfaces.cs",
"../monad/monad/src/engine/Pipe.cs",
"../monad/monad/src/engine/PositionalCommandParameter.cs",
"../monad/monad/src/engine/ProgressRecord.cs",
"../monad/monad/src/engine/PropertyCmdletProviderInterfaces.cs",
"../monad/monad/src/engine/ProviderInterfaces.cs",
"../monad/monad/src/engine/ProviderNames.cs",
"../monad/monad/src/engine/ProxyCommand.cs",
"../monad/monad/src/engine/PseudoParameterBinder.cs",
"../monad/monad/src/engine/PseudoParameters.cs",
"../monad/monad/src/engine/QuestionMarkVariable.cs",
"../monad/monad/src/engine/ReflectionParameterBinder.cs",
"../monad/monad/src/engine/ScopedItemSearcher.cs",
"../monad/monad/src/engine/ScriptCommand.cs",
"../monad/monad/src/engine/ScriptCommandProcessor.cs",
"../monad/monad/src/engine/ScriptInfo.cs",
"../monad/monad/src/engine/SecurityDescriptorCmdletProviderInterfaces.cs",
"../monad/monad/src/engine/SecurityManagerBase.cs",
"../monad/monad/src/engine/SerializationStrings.cs",
"../monad/monad/src/engine/SessionState.cs",
"../monad/monad/src/engine/SessionStateAliasAPIs.cs",
"../monad/monad/src/engine/SessionStateCapacityVariable.cs",
"../monad/monad/src/engine/SessionStateCmdletAPIs.cs",
"../monad/monad/src/engine/SessionStateContainer.cs",
"../monad/monad/src/engine/SessionStateContent.cs",
"../monad/monad/src/engine/SessionStateDriveAPIs.cs",
"../monad/monad/src/engine/SessionStateDynamicProperty.cs",
"../monad/monad/src/engine/SessionStateFunctionAPIs.cs",
"../monad/monad/src/engine/SessionStateItem.cs",
"../monad/monad/src/engine/SessionStateLocationAPIs.cs",
"../monad/monad/src/engine/SessionStateNavigation.cs",
"../monad/monad/src/engine/SessionStateProperty.cs",
"../monad/monad/src/engine/SessionStateProviderAPIs.cs",
"../monad/monad/src/engine/SessionStatePublic.cs",
"../monad/monad/src/engine/SessionStateScope.cs",
"../monad/monad/src/engine/SessionStateScopeAPIs.cs",
"../monad/monad/src/engine/SessionStateScopeEnumerator.cs",
"../monad/monad/src/engine/SessionStateSecurityDescriptorInterface.cs",
"../monad/monad/src/engine/SessionStateStrings.cs",
"../monad/monad/src/engine/SessionStateUtils.cs",
"../monad/monad/src/engine/SessionStateVariableAPIs.cs",
"../monad/monad/src/engine/ShellVariable.cs",
"../monad/monad/src/engine/SpecialVariables.cs",
"../monad/monad/src/engine/ThirdPartyAdapter.cs",
"../monad/monad/src/engine/TypeMetadata.cs",
"../monad/monad/src/engine/TypeTable.cs",
"../monad/monad/src/engine/TypesV3_Ps1Xml.generated.cs",
"../monad/monad/src/engine/Types_Ps1Xml.generated.cs",
"../monad/monad/src/engine/UserFeedbackParameters.cs",
"../monad/monad/src/engine/Utils.cs",
"../monad/monad/src/engine/VariableAttributeCollection.cs",
"../monad/monad/src/engine/VariableInterfaces.cs",
"../monad/monad/src/engine/VariablePath.cs",
"../monad/monad/src/engine/WinRT/IInspectable.cs",
"../monad/monad/src/engine/WorkflowInfo.cs",
"../monad/monad/src/engine/cmdlet.cs",
"../monad/monad/src/engine/debugger/Breakpoint.cs",
"../monad/monad/src/engine/debugger/debugger.cs",
"../monad/monad/src/engine/hostifaces/AsyncResult.cs",
"../monad/monad/src/engine/hostifaces/ChoiceDescription.cs",
"../monad/monad/src/engine/hostifaces/Command.cs",
"../monad/monad/src/engine/hostifaces/Connection.cs",
"../monad/monad/src/engine/hostifaces/ConnectionBase.cs",
"../monad/monad/src/engine/hostifaces/ConnectionFactory.cs",
"../monad/monad/src/engine/hostifaces/DefaultHost.cs",
"../monad/monad/src/engine/hostifaces/FieldDescription.cs",
"../monad/monad/src/engine/hostifaces/History.cs",
"../monad/monad/src/engine/hostifaces/HostUtilities.cs",
"../monad/monad/src/engine/hostifaces/InformationalRecord.cs",
"../monad/monad/src/engine/hostifaces/InternalHost.cs",
"../monad/monad/src/engine/hostifaces/InternalHostRawUserInterface.cs",
"../monad/monad/src/engine/hostifaces/InternalHostUserInterface.cs",
"../monad/monad/src/engine/hostifaces/ListModifier.cs",
"../monad/monad/src/engine/hostifaces/LocalConnection.cs",
"../monad/monad/src/engine/hostifaces/LocalPipeline.cs",
"../monad/monad/src/engine/hostifaces/MshHost.cs",
"../monad/monad/src/engine/hostifaces/MshHostRawUserInterface.cs",
"../monad/monad/src/engine/hostifaces/MshHostUserInterface.cs",
"../monad/monad/src/engine/hostifaces/PSCommand.cs",
"../monad/monad/src/engine/hostifaces/PSDataCollection.cs",
"../monad/monad/src/engine/hostifaces/Parameter.cs",
"../monad/monad/src/engine/hostifaces/Pipeline.cs",
"../monad/monad/src/engine/hostifaces/PowerShell.cs",
"../monad/monad/src/engine/hostifaces/PowerShellProcessInstance.cs",
"../monad/monad/src/engine/hostifaces/RunspaceInit.cs",
"../monad/monad/src/engine/hostifaces/RunspacePool.cs",
"../monad/monad/src/engine/hostifaces/RunspacePoolInternal.cs",
"../monad/monad/src/engine/hostifaces/internalHostuserInterfacesecurity.cs",
"../monad/monad/src/engine/hostifaces/pipelinebase.cs",
"../monad/monad/src/engine/interpreter/AddInstruction.cs",
"../monad/monad/src/engine/interpreter/ArrayOperations.cs",
"../monad/monad/src/engine/interpreter/BranchLabel.cs",
"../monad/monad/src/engine/interpreter/CallInstruction.Generated.cs",
"../monad/monad/src/engine/interpreter/CallInstruction.cs",
"../monad/monad/src/engine/interpreter/ControlFlowInstructions.cs",
"../monad/monad/src/engine/interpreter/DivInstruction.cs",
"../monad/monad/src/engine/interpreter/DynamicInstructionN.cs",
"../monad/monad/src/engine/interpreter/DynamicInstructions.Generated.cs",
"../monad/monad/src/engine/interpreter/DynamicSplatInstruction.cs",
"../monad/monad/src/engine/interpreter/EqualInstruction.cs",
"../monad/monad/src/engine/interpreter/FieldOperations.cs",
"../monad/monad/src/engine/interpreter/GreaterThanInstruction.cs",
"../monad/monad/src/engine/interpreter/ILightCallSiteBinder.cs",
"../monad/monad/src/engine/interpreter/Instruction.cs",
"../monad/monad/src/engine/interpreter/InstructionFactory.cs",
"../monad/monad/src/engine/interpreter/InstructionList.cs",
"../monad/monad/src/engine/interpreter/InterpretedFrame.cs",
"../monad/monad/src/engine/interpreter/Interpreter.cs",
"../monad/monad/src/engine/interpreter/LabelInfo.cs",
"../monad/monad/src/engine/interpreter/LessThanInstruction.cs",
"../monad/monad/src/engine/interpreter/LightCompiler.cs",
"../monad/monad/src/engine/interpreter/LightDelegateCreator.cs",
"../monad/monad/src/engine/interpreter/LightLambda.Generated.cs",
"../monad/monad/src/engine/interpreter/LightLambda.cs",
"../monad/monad/src/engine/interpreter/LightLambdaClosureVisitor.cs",
"../monad/monad/src/engine/interpreter/LocalAccess.cs",
"../monad/monad/src/engine/interpreter/LocalVariables.cs",
"../monad/monad/src/engine/interpreter/LoopCompiler.cs",
"../monad/monad/src/engine/interpreter/MulInstruction.cs",
"../monad/monad/src/engine/interpreter/NotEqualInstruction.cs",
"../monad/monad/src/engine/interpreter/NumericConvertInstruction.cs",
"../monad/monad/src/engine/interpreter/PowerShellInstructions.cs",
"../monad/monad/src/engine/interpreter/RuntimeVariables.cs",
"../monad/monad/src/engine/interpreter/StackOperations.cs",
"../monad/monad/src/engine/interpreter/SubInstruction.cs",
"../monad/monad/src/engine/interpreter/TypeOperations.cs",
"../monad/monad/src/engine/interpreter/Utilities.cs",
"../monad/monad/src/engine/lang/codegen.cs",
"../monad/monad/src/engine/lang/interface/PSParseError.cs",
"../monad/monad/src/engine/lang/interface/PSParser.cs",
"../monad/monad/src/engine/lang/interface/PSToken.cs",
"../monad/monad/src/engine/lang/parserutils.cs",
"../monad/monad/src/engine/lang/scriptblock.cs",
"../monad/monad/src/engine/parser/AstVisitor.cs",
"../monad/monad/src/engine/parser/CharTraits.cs",
"../monad/monad/src/engine/parser/Compiler.cs",
"../monad/monad/src/engine/parser/ConstantValues.cs",
"../monad/monad/src/engine/parser/DebugViewWriter.cs",
"../monad/monad/src/engine/parser/FusionAssemblyIdentity.cs",
"../monad/monad/src/engine/parser/GlobalAssemblyCache.cs",
"../monad/monad/src/engine/parser/PSType.cs",
"../monad/monad/src/engine/parser/Parser.cs",
"../monad/monad/src/engine/parser/Position.cs",
"../monad/monad/src/engine/parser/PreOrderVisitor.cs",
"../monad/monad/src/engine/parser/SafeValues.cs",
"../monad/monad/src/engine/parser/SemanticChecks.cs",
"../monad/monad/src/engine/parser/SymbolResolver.cs",
"../monad/monad/src/engine/parser/TypeResolver.cs",
"../monad/monad/src/engine/parser/VariableAnalysis.cs",
"../monad/monad/src/engine/parser/ast.cs",
"../monad/monad/src/engine/parser/token.cs",
"../monad/monad/src/engine/parser/tokenizer.cs",
"../monad/monad/src/engine/pipeline.cs",
"../monad/monad/src/engine/regex.cs",
"../monad/monad/src/engine/remoting/client/ClientMethodExecutor.cs",
"../monad/monad/src/engine/remoting/client/ClientRemotePowerShell.cs",
"../monad/monad/src/engine/remoting/client/Job.cs",
"../monad/monad/src/engine/remoting/client/Job2.cs",
"../monad/monad/src/engine/remoting/client/JobManager.cs",
"../monad/monad/src/engine/remoting/client/JobSourceAdapter.cs",
"../monad/monad/src/engine/remoting/client/PSProxyJob.cs",
"../monad/monad/src/engine/remoting/client/PowerShellStreams.cs",
"../monad/monad/src/engine/remoting/client/RemoteRunspacePoolInternal.cs",
"../monad/monad/src/engine/remoting/client/RemotingErrorRecord.cs",
"../monad/monad/src/engine/remoting/client/RemotingProtocol2.cs",
"../monad/monad/src/engine/remoting/client/RunspaceRef.cs",
"../monad/monad/src/engine/remoting/client/ThrottlingJob.cs",
"../monad/monad/src/engine/remoting/client/clientremotesession.cs",
"../monad/monad/src/engine/remoting/client/clientremotesessionprotocolstatemachine.cs",
"../monad/monad/src/engine/remoting/client/remotepipeline.cs",
"../monad/monad/src/engine/remoting/client/remoterunspace.cs",
"../monad/monad/src/engine/remoting/client/remoterunspaceinfo.cs",
"../monad/monad/src/engine/remoting/client/remotingprotocol.cs",
"../monad/monad/src/engine/remoting/client/remotingprotocolimplementation.cs",
"../monad/monad/src/engine/remoting/commands/ConnectPSSession.cs",
"../monad/monad/src/engine/remoting/commands/CustomShellCommands.cs",
"../monad/monad/src/engine/remoting/commands/DebugJob.cs",
"../monad/monad/src/engine/remoting/commands/DisconnectPSSession.cs",
"../monad/monad/src/engine/remoting/commands/EnterPSHostProcessCommand.cs",
"../monad/monad/src/engine/remoting/commands/GetJob.cs",
"../monad/monad/src/engine/remoting/commands/InvokeCommandCommand.cs",
"../monad/monad/src/engine/remoting/commands/JobRepository.cs",
"../monad/monad/src/engine/remoting/commands/NewPSSessionConfigurationFile.cs",
"../monad/monad/src/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs",
"../monad/monad/src/engine/remoting/commands/NewPSSessionOptionCommand.cs",
"../monad/monad/src/engine/remoting/commands/PSRemotingCmdlet.cs",
"../monad/monad/src/engine/remoting/commands/PopRunspaceCommand.cs",
"../monad/monad/src/engine/remoting/commands/PushRunspaceCommand.cs",
"../monad/monad/src/engine/remoting/commands/ReceiveJob.cs",
"../monad/monad/src/engine/remoting/commands/ReceivePSSession.cs",
"../monad/monad/src/engine/remoting/commands/RemoveJob.cs",
"../monad/monad/src/engine/remoting/commands/ResumeJob.cs",
"../monad/monad/src/engine/remoting/commands/StartJob.cs",
"../monad/monad/src/engine/remoting/commands/StopJob.cs",
"../monad/monad/src/engine/remoting/commands/SuspendJob.cs",
"../monad/monad/src/engine/remoting/commands/TestPSSessionConfigurationFile.cs",
"../monad/monad/src/engine/remoting/commands/WaitJob.cs",
"../monad/monad/src/engine/remoting/commands/getrunspacecommand.cs",
"../monad/monad/src/engine/remoting/commands/newrunspacecommand.cs",
"../monad/monad/src/engine/remoting/commands/remotingcommandutil.cs",
"../monad/monad/src/engine/remoting/commands/removerunspacecommand.cs",
"../monad/monad/src/engine/remoting/commands/runspacerepository.cs",
"../monad/monad/src/engine/remoting/common/AsyncObject.cs",
"../monad/monad/src/engine/remoting/common/DispatchTable.cs",
"../monad/monad/src/engine/remoting/common/Indexer.cs",
"../monad/monad/src/engine/remoting/common/ObjectRef.cs",
"../monad/monad/src/engine/remoting/common/PSETWTracer.cs",
"../monad/monad/src/engine/remoting/common/PSSessionConfigurationTypeOption.cs",
"../monad/monad/src/engine/remoting/common/RemoteSessionHyperVSocket.cs",
"../monad/monad/src/engine/remoting/common/RemoteSessionNamedPipe.cs",
"../monad/monad/src/engine/remoting/common/RunspaceConnectionInfo.cs",
"../monad/monad/src/engine/remoting/common/RunspaceInitInfo.cs",
"../monad/monad/src/engine/remoting/common/RunspacePoolStateInfo.cs",
"../monad/monad/src/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs",
"../monad/monad/src/engine/remoting/common/WireDataFormat/RemoteHost.cs",
"../monad/monad/src/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs",
"../monad/monad/src/engine/remoting/common/WireDataFormat/RemoteSessionCapability.cs",
"../monad/monad/src/engine/remoting/common/WireDataFormat/RemotingDataObject.cs",
"../monad/monad/src/engine/remoting/common/fragmentor.cs",
"../monad/monad/src/engine/remoting/common/misc.cs",
"../monad/monad/src/engine/remoting/common/psstreamobject.cs",
"../monad/monad/src/engine/remoting/common/remotesession.cs",
"../monad/monad/src/engine/remoting/common/remotingexceptions.cs",
"../monad/monad/src/engine/remoting/common/throttlemanager.cs",
"../monad/monad/src/engine/remoting/fanin/BaseTransportManager.cs",
"../monad/monad/src/engine/remoting/fanin/InitialSessionStateProvider.cs",
"../monad/monad/src/engine/remoting/fanin/OutOfProcTransportManager.cs",
"../monad/monad/src/engine/remoting/fanin/PSPrincipal.cs",
"../monad/monad/src/engine/remoting/fanin/PSSessionConfigurationData.cs",
"../monad/monad/src/engine/remoting/fanin/PriorityCollection.cs",
"../monad/monad/src/engine/remoting/fanin/WSManNativeAPI.cs",
"../monad/monad/src/engine/remoting/fanin/WSManPlugin.cs",
"../monad/monad/src/engine/remoting/fanin/WSManPluginFacade.cs",
"../monad/monad/src/engine/remoting/fanin/WSManPluginShellSession.cs",
"../monad/monad/src/engine/remoting/fanin/WSManPluginTransportManager.cs",
"../monad/monad/src/engine/remoting/fanin/WSManTransportManager.cs",
"../monad/monad/src/engine/remoting/host/RemoteHostMethodInfo.cs",
"../monad/monad/src/engine/remoting/server/OutOfProcServerMediator.cs",
"../monad/monad/src/engine/remoting/server/ServerMethodExecutor.cs",
"../monad/monad/src/engine/remoting/server/ServerPowerShellDriver.cs",
"../monad/monad/src/engine/remoting/server/ServerRemoteHost.cs",
"../monad/monad/src/engine/remoting/server/ServerRemoteHostRawUserInterface.cs",
"../monad/monad/src/engine/remoting/server/ServerRemoteHostUserInterface.cs",
"../monad/monad/src/engine/remoting/server/ServerRemotingProtocol2.cs",
"../monad/monad/src/engine/remoting/server/ServerRunspacePoolDriver.cs",
"../monad/monad/src/engine/remoting/server/ServerSteppablePipelineDriver.cs",
"../monad/monad/src/engine/remoting/server/ServerSteppablePipelineSubscriber.cs",
"../monad/monad/src/engine/remoting/server/WSManChannelEvents.cs",
"../monad/monad/src/engine/remoting/server/serverremotesession.cs",
"../monad/monad/src/engine/remoting/server/serverremotesessionstatemachine.cs",
"../monad/monad/src/engine/remoting/server/serverremotingprotocol.cs",
"../monad/monad/src/engine/remoting/server/serverremotingprotocolimplementation.cs",
"../monad/monad/src/engine/runtime/Binding/Binders.cs",
"../monad/monad/src/engine/runtime/CompiledScriptBlock.cs",
"../monad/monad/src/engine/runtime/MutableTuple.cs",
"../monad/monad/src/engine/runtime/Operations/ArrayOps.cs",
"../monad/monad/src/engine/runtime/Operations/ClassOps.cs",
"../monad/monad/src/engine/runtime/Operations/MiscOps.cs",
"../monad/monad/src/engine/runtime/Operations/NumericOps.cs",
"../monad/monad/src/engine/runtime/Operations/StringOps.cs",
"../monad/monad/src/engine/runtime/Operations/VariableOps.cs",
"../monad/monad/src/engine/runtime/ScriptBlockToPowerShell.cs",
"../monad/monad/src/engine/scriptparameterbinder.cs",
"../monad/monad/src/engine/scriptparameterbindercontroller.cs",
"../monad/monad/src/engine/serialization.cs",
"../monad/monad/src/help/AliasHelpInfo.cs",
"../monad/monad/src/help/AliasHelpProvider.cs",
"../monad/monad/src/help/BaseCommandHelpInfo.cs",
"../monad/monad/src/help/CabinetAPI.cs",
"../monad/monad/src/help/CabinetNativeApi.cs",
"../monad/monad/src/help/CommandHelpProvider.cs",
"../monad/monad/src/help/DefaultCommandHelpObjectBuilder.cs",
"../monad/monad/src/help/DefaultHelpProvider.cs",
"../monad/monad/src/help/DscResourceHelpProvider.cs",
"../monad/monad/src/help/FaqHelpInfo.cs",
"../monad/monad/src/help/FaqHelpProvider.cs",
"../monad/monad/src/help/GeneralHelpInfo.cs",
"../monad/monad/src/help/GeneralHelpProvider.cs",
"../monad/monad/src/help/GlossaryHelpInfo.cs",
"../monad/monad/src/help/GlossaryHelpProvider.cs",
"../monad/monad/src/help/HelpCategoryInvalidException.cs",
"../monad/monad/src/help/HelpCommands.cs",
"../monad/monad/src/help/HelpCommentsParser.cs",
"../monad/monad/src/help/HelpErrorTracer.cs",
"../monad/monad/src/help/HelpFileHelpInfo.cs",
"../monad/monad/src/help/HelpFileHelpProvider.cs",
"../monad/monad/src/help/HelpInfo.cs",
"../monad/monad/src/help/HelpNotFoundException.cs",
"../monad/monad/src/help/HelpProvider.cs",
"../monad/monad/src/help/HelpProviderWithCache.cs",
"../monad/monad/src/help/HelpProviderWithFullCache.cs",
"../monad/monad/src/help/HelpRequest.cs",
"../monad/monad/src/help/HelpSystem.cs",
"../monad/monad/src/help/MUIFileSearcher.cs",
"../monad/monad/src/help/MamlClassHelpInfo.cs",
"../monad/monad/src/help/MamlCommandHelpInfo.cs",
"../monad/monad/src/help/MamlNode.cs",
"../monad/monad/src/help/MamlUtil.cs",
"../monad/monad/src/help/PSClassHelpProvider.cs",
"../monad/monad/src/help/ProviderCommandHelpInfo.cs",
"../monad/monad/src/help/ProviderContext.cs",
"../monad/monad/src/help/ProviderHelpInfo.cs",
"../monad/monad/src/help/ProviderHelpProvider.cs",
"../monad/monad/src/help/RemoteHelpInfo.cs",
"../monad/monad/src/help/SaveHelpCommand.cs",
"../monad/monad/src/help/ScriptCommandHelpProvider.cs",
"../monad/monad/src/help/SyntaxHelpInfo.cs",
"../monad/monad/src/help/UpdatableHelpCommandBase.cs",
"../monad/monad/src/help/UpdatableHelpInfo.cs",
"../monad/monad/src/help/UpdatableHelpModuleInfo.cs",
"../monad/monad/src/help/UpdatableHelpSystem.cs",
"../monad/monad/src/help/UpdatableHelpUri.cs",
"../monad/monad/src/help/UpdateHelpCommand.cs",
"../monad/monad/src/logging/LogContext.cs",
"../monad/monad/src/logging/LogProvider.cs",
"../monad/monad/src/logging/MshLog.cs",
"../monad/monad/src/minishell/api/FormatAndTypeDataHelper.cs",
"../monad/monad/src/minishell/api/RunspaceConfiguration.cs",
"../monad/monad/src/minishell/api/RunspaceConfigurationAttributeException.cs",
"../monad/monad/src/minishell/api/RunspaceConfigurationEntry.cs",
"../monad/monad/src/minishell/api/RunspaceConfigurationEntryCollection.cs",
"../monad/monad/src/minishell/api/RunspaceConfigurationHelper.cs",
"../monad/monad/src/minishell/api/RunspaceConfigurationTypeAttribute.cs",
"../monad/monad/src/minishell/api/RunspaceConfigurationTypeException.cs",
"../monad/monad/src/namespaces/AliasProvider.cs",
"../monad/monad/src/namespaces/Buffer.cs",
"../monad/monad/src/namespaces/ContainerProviderBase.cs",
"../monad/monad/src/namespaces/CoreCommandContext.cs",
"../monad/monad/src/namespaces/DriveProviderBase.cs",
"../monad/monad/src/namespaces/EnvironmentProvider.cs",
"../monad/monad/src/namespaces/FileSystemContentStream.cs",
"../monad/monad/src/namespaces/FileSystemProvider.cs",
"../monad/monad/src/namespaces/FileSystemSecurity.cs",
"../monad/monad/src/namespaces/FunctionProvider.cs",
"../monad/monad/src/namespaces/IContentProvider.cs",
"../monad/monad/src/namespaces/IContentReader.cs",
"../monad/monad/src/namespaces/IContentWriter.cs",
"../monad/monad/src/namespaces/IDynamicPropertyProvider.cs",
"../monad/monad/src/namespaces/IPermissionProvider.cs",
"../monad/monad/src/namespaces/IPropertiesProvider.cs",
"../monad/monad/src/namespaces/ItemProviderBase.cs",
"../monad/monad/src/namespaces/LocationGlobber.cs",
"../monad/monad/src/namespaces/NavigationProviderBase.cs",
"../monad/monad/src/namespaces/PathInfo.cs",
"../monad/monad/src/namespaces/ProviderBase.cs",
"../monad/monad/src/namespaces/ProviderBaseSecurity.cs",
"../monad/monad/src/namespaces/ProviderDeclarationAttribute.cs",
"../monad/monad/src/namespaces/RegistryProvider.cs",
"../monad/monad/src/namespaces/RegistrySecurity.cs",
"../monad/monad/src/namespaces/RegistryWrapper.cs",
"../monad/monad/src/namespaces/SafeRegistryHandle.cs",
"../monad/monad/src/namespaces/SessionStateProviderBase.cs",
"../monad/monad/src/namespaces/StackInfo.cs",
"../monad/monad/src/namespaces/VariableProvider.cs",
"../monad/monad/src/namespaces/Win32Native.cs",
"../monad/monad/src/security/Authenticode.cs",
"../monad/monad/src/security/CredentialParameter.cs",
"../monad/monad/src/security/MshSignature.cs",
"../monad/monad/src/security/SecureStringHelper.cs",
"../monad/monad/src/security/SecurityManager.cs",
"../monad/monad/src/security/SecuritySupport.cs",
"../monad/monad/src/security/nativeMethods.cs",
"../monad/monad/src/singleshell/config/MshConsoleInfo.cs",
"../monad/monad/src/singleshell/config/MshConsoleLoadException.cs",
"../monad/monad/src/singleshell/config/MshSnapinInfo.cs",
"../monad/monad/src/singleshell/config/MshSnapinLoadException.cs",
"../monad/monad/src/singleshell/config/RunspaceConfigForSingleShell.cs",
"../monad/monad/src/utils/ArchitectureSensitiveAttribute.cs",
"../monad/monad/src/utils/ClrFacade.cs",
"../monad/monad/src/utils/CommandDiscoveryExceptions.cs",
"../monad/monad/src/utils/CommandProcessorExceptions.cs",
"../monad/monad/src/utils/CoreProviderCmdlets.cs",
"../monad/monad/src/utils/CryptoUtils.cs",
"../monad/monad/src/utils/ExecutionExceptions.cs",
"../monad/monad/src/utils/ExtensionMethods.cs",
"../monad/monad/src/utils/HostInterfacesExceptions.cs",
"../monad/monad/src/utils/IObjectReader.cs",
"../monad/monad/src/utils/IObjectWriter.cs",
"../monad/monad/src/utils/MetadataExceptions.cs",
"../monad/monad/src/utils/MshArgumentException.cs",
"../monad/monad/src/utils/MshArgumentNullException.cs",
"../monad/monad/src/utils/MshArgumentOutOfRangeException.cs",
"../monad/monad/src/utils/MshInvalidOperationException.cs",
"../monad/monad/src/utils/MshNotImplementedException.cs",
"../monad/monad/src/utils/MshNotSupportedException.cs",
"../monad/monad/src/utils/MshObjectDisposedException.cs",
"../monad/monad/src/utils/MshTraceSource.cs",
"../monad/monad/src/utils/ObjectReader.cs",
"../monad/monad/src/utils/ObjectStream.cs",
"../monad/monad/src/utils/ObjectWriter.cs",
"../monad/monad/src/utils/PInvokeDllNames.cs",
"../monad/monad/src/utils/PSTelemetryMethods.cs",
"../monad/monad/src/utils/PSTelemetryWrapper.cs",
"../monad/monad/src/utils/ParameterBinderExceptions.cs",
"../monad/monad/src/utils/ParserException.cs",
"../monad/monad/src/utils/PathUtils.cs",
"../monad/monad/src/utils/PlatformInvokes.cs",
"../monad/monad/src/utils/PsUtils.cs",
"../monad/monad/src/utils/ResourceManagerCache.cs",
"../monad/monad/src/utils/RuntimeException.cs",
"../monad/monad/src/utils/SessionStateExceptions.cs",
"../monad/monad/src/utils/StringUtil.cs",
"../monad/monad/src/utils/StructuredTraceSource.cs",
"../monad/monad/src/utils/Verbs.cs",
"../monad/monad/src/utils/assert.cs"
],
"namedResource": {
"Authenticode": "../monad-build/gen/SYS_AUTO/Authenticode.resources",
"AuthorizationManagerBase": "../monad-build/gen/SYS_AUTO/AuthorizationManagerBase.resources",
"AutomationExceptions": "../monad-build/gen/SYS_AUTO/AutomationExceptions.resources",
"CimInstanceTypeAdapterResources": "../monad-build/gen/SYS_AUTO/CimInstanceTypeAdapterResources.resources",
"CmdletizationCoreResources": "../monad-build/gen/SYS_AUTO/CmdletizationCoreResources.resources",
"CommandBaseStrings": "../monad-build/gen/SYS_AUTO/CommandBaseStrings.resources",
"ConsoleInfoErrorStrings": "../monad-build/gen/SYS_AUTO/ConsoleInfoErrorStrings.resources",
"CoreClrStubResources": "../monad-build/gen/SYS_AUTO/CoreClrStubResources.resources",
"CredUI": "../monad-build/gen/SYS_AUTO/CredUI.resources",
"Credential": "../monad-build/gen/SYS_AUTO/Credential.resources",
"CredentialAttributeStrings": "../monad-build/gen/SYS_AUTO/CredentialAttributeStrings.resources",
"DebuggerStrings": "../monad-build/gen/SYS_AUTO/DebuggerStrings.resources",
"DescriptionsStrings": "../monad-build/gen/SYS_AUTO/DescriptionsStrings.resources",
"DiscoveryExceptions": "../monad-build/gen/SYS_AUTO/DiscoveryExceptions.resources",
"EnumExpressionEvaluatorStrings": "../monad-build/gen/SYS_AUTO/EnumExpressionEvaluatorStrings.resources",
"ErrorCategoryStrings": "../monad-build/gen/SYS_AUTO/ErrorCategoryStrings.resources",
"ErrorPackage": "../monad-build/gen/SYS_AUTO/ErrorPackage.resources",
"EventingResources": "../monad-build/gen/SYS_AUTO/EventingResources.resources",
"ExtendedTypeSystem": "../monad-build/gen/SYS_AUTO/ExtendedTypeSystem.resources",
"FileSystemProviderStrings": "../monad-build/gen/SYS_AUTO/FileSystemProviderStrings.resources",
"FormatAndOutXmlLoadingStrings": "../monad-build/gen/SYS_AUTO/FormatAndOutXmlLoadingStrings.resources",
"FormatAndOut_MshParameter": "../monad-build/gen/SYS_AUTO/FormatAndOut_MshParameter.resources",
"FormatAndOut_format_xxx": "../monad-build/gen/SYS_AUTO/FormatAndOut_format_xxx.resources",
"FormatAndOut_out_xxx": "../monad-build/gen/SYS_AUTO/FormatAndOut_out_xxx.resources",
"GetErrorText": "../monad-build/gen/SYS_AUTO/GetErrorText.resources",
"HelpDisplayStrings": "../monad-build/gen/SYS_AUTO/HelpDisplayStrings.resources",
"HelpErrors": "../monad-build/gen/SYS_AUTO/HelpErrors.resources",
"HistoryStrings": "../monad-build/gen/SYS_AUTO/HistoryStrings.resources",
"HostInterfaceExceptionsStrings": "../monad-build/gen/SYS_AUTO/HostInterfaceExceptionsStrings.resources",
"InternalCommandStrings": "../monad-build/gen/SYS_AUTO/InternalCommandStrings.resources",
"InternalHostStrings": "../monad-build/gen/SYS_AUTO/InternalHostStrings.resources",
"InternalHostUserInterfaceStrings": "../monad-build/gen/SYS_AUTO/InternalHostUserInterfaceStrings.resources",
"Logging": "../monad-build/gen/SYS_AUTO/Logging.resources",
"Metadata": "../monad-build/gen/SYS_AUTO/Metadata.resources",
"MiniShellErrors": "../monad-build/gen/SYS_AUTO/MiniShellErrors.resources",
"Modules": "../monad-build/gen/SYS_AUTO/Modules.resources",
"MshHostRawUserInterfaceStrings": "../monad-build/gen/SYS_AUTO/MshHostRawUserInterfaceStrings.resources",
"MshSignature": "../monad-build/gen/SYS_AUTO/MshSignature.resources",
"MshSnapInCmdletResources": "../monad-build/gen/SYS_AUTO/MshSnapInCmdletResources.resources",
"MshSnapinInfo": "../monad-build/gen/SYS_AUTO/MshSnapinInfo.resources",
"NativeCP": "../monad-build/gen/SYS_AUTO/NativeCP.resources",
"PSCommandStrings": "../monad-build/gen/SYS_AUTO/PSCommandStrings.resources",
"PSDataBufferStrings": "../monad-build/gen/SYS_AUTO/PSDataBufferStrings.resources",
"PSListModifierStrings": "../monad-build/gen/SYS_AUTO/PSListModifierStrings.resources",
"ParameterBinderStrings": "../monad-build/gen/SYS_AUTO/ParameterBinderStrings.resources",
"ParserStrings": "../monad-build/gen/SYS_AUTO/ParserStrings.resources",
"PathUtilsStrings": "../monad-build/gen/SYS_AUTO/PathUtilsStrings.resources",
"PipelineStrings": "../monad-build/gen/SYS_AUTO/PipelineStrings.resources",
"PowerShellStrings": "../monad-build/gen/SYS_AUTO/PowerShellStrings.resources",
"ProgressRecordStrings": "../monad-build/gen/SYS_AUTO/ProgressRecordStrings.resources",
"ProviderBaseSecurity": "../monad-build/gen/SYS_AUTO/ProviderBaseSecurity.resources",
"ProxyCommandStrings": "../monad-build/gen/SYS_AUTO/ProxyCommandStrings.resources",
"RegistryProviderStrings": "../monad-build/gen/SYS_AUTO/RegistryProviderStrings.resources",
"RemotingErrorIdStrings": "../monad-build/gen/SYS_AUTO/RemotingErrorIdStrings.resources",
"RunspaceInit": "../monad-build/gen/SYS_AUTO/RunspaceInit.resources",
"RunspacePoolStrings": "../monad-build/gen/SYS_AUTO/RunspacePoolStrings.resources",
"RunspaceStrings": "../monad-build/gen/SYS_AUTO/RunspaceStrings.resources",
"SecuritySupportStrings": "../monad-build/gen/SYS_AUTO/SecuritySupportStrings.resources",
"Serialization": "../monad-build/gen/SYS_AUTO/Serialization.resources",
"SessionStateProviderBaseStrings": "../monad-build/gen/SYS_AUTO/SessionStateProviderBaseStrings.resources",
"SessionStateStrings": "../monad-build/gen/SYS_AUTO/SessionStateStrings.resources",
"SuggestionStrings": "../monad-build/gen/SYS_AUTO/SuggestionStrings.resources",
"TabCompletionStrings": "../monad-build/gen/SYS_AUTO/TabCompletionStrings.resources",
"TransactionStrings": "../monad-build/gen/SYS_AUTO/TransactionStrings.resources",
"TypesXmlStrings": "../monad-build/gen/SYS_AUTO/TypesXmlStrings.resources",
"WildcardPatternStrings": "../monad-build/gen/SYS_AUTO/WildcardPatternStrings.resources"
}
}

View File

@ -0,0 +1,353 @@
//
// System.Security.SecureString class
//
// Authors
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace System.Security {
public sealed class SecureString : IDisposable
{
private const int BlockSize = 16;
private const int MaxSize = 65536;
private int length;
private bool disposed;
private bool read_only;
private byte[] data;
static SecureString()
{
// ProtectedMemory has been moved to System.Security.dll
// we use reflection to call it (if available) or we'll
// throw an exception
}
public SecureString()
{
Alloc(BlockSize >> 1, false);
}
public unsafe SecureString(char* value, int length)
{
if (value == null)
throw new ArgumentNullException("value");
if ((length < 0) || (length > MaxSize))
throw new ArgumentOutOfRangeException("length", "< 0 || > 65536");
this.length = length; // real length
Alloc(length, false);
int n = 0;
for (int i = 0; i < length; i++)
{
char c = *value++;
data[n++] = (byte)c;
data[n++] = (byte)(c >> 8);
}
Encrypt();
}
// properties
public int Length
{
get
{
if (disposed)
throw new ObjectDisposedException("SecureString");
return length;
}
}
public void AppendChar(char c)
{
if (disposed)
throw new ObjectDisposedException("SecureString");
if (read_only)
{
throw new InvalidOperationException("SecureString is read-only.");
}
if (length == MaxSize)
throw new ArgumentOutOfRangeException("length", "> 65536");
try
{
Decrypt();
int n = length * 2;
Alloc(++length, true);
data[n++] = (byte)c;
data[n++] = (byte)(c >> 8);
}
finally
{
Encrypt();
}
}
public void Clear()
{
if (disposed)
throw new ObjectDisposedException("SecureString");
if (read_only)
{
throw new InvalidOperationException("SecureString is read-only.");
}
Array.Clear(data, 0, data.Length);
length = 0;
}
public SecureString Copy()
{
SecureString ss = new SecureString();
ss.data = (byte[])data.Clone();
ss.length = length;
return ss;
}
public void Dispose()
{
disposed = true;
// don't call clear because we could be either in read-only
// or already disposed - but DO CLEAR the data
if (data != null)
{
Array.Clear(data, 0, data.Length);
data = null;
}
length = 0;
}
public void InsertAt(int index, char c)
{
if (disposed)
throw new ObjectDisposedException("SecureString");
if (read_only)
{
throw new InvalidOperationException("SecureString is read-only.");
}
if ((index < 0) || (index > length))
throw new ArgumentOutOfRangeException("index", "< 0 || > length");
// insert increments length
if (length >= MaxSize)
{
string msg = $"Maximum string size is '{MaxSize}'.";
throw new ArgumentOutOfRangeException("index", msg);
}
try
{
Decrypt();
Alloc(++length, true);
int n = index * 2;
Buffer.BlockCopy(data, n, data, n + 2, data.Length - n - 2);
data[n++] = (byte)c;
data[n] = (byte)(c >> 8);
}
finally
{
Encrypt();
}
}
public bool IsReadOnly()
{
if (disposed)
throw new ObjectDisposedException("SecureString");
return read_only;
}
public void MakeReadOnly()
{
read_only = true;
}
public void RemoveAt(int index)
{
if (disposed)
throw new ObjectDisposedException("SecureString");
if (read_only)
{
throw new InvalidOperationException("SecureString is read-only.");
}
if ((index < 0) || (index >= length))
throw new ArgumentOutOfRangeException("index", "< 0 || > length");
try
{
Decrypt();
Buffer.BlockCopy(data, index * 2 + 2, data, index * 2, data.Length - index * 2 - 2);
Alloc(--length, true);
}
finally
{
Encrypt();
}
}
public void SetAt(int index, char c)
{
if (disposed)
throw new ObjectDisposedException("SecureString");
if (read_only)
{
throw new InvalidOperationException("SecureString is read-only.");
}
if ((index < 0) || (index >= length))
throw new ArgumentOutOfRangeException("index", "< 0 || > length");
try
{
Decrypt();
int n = index * 2;
data[n++] = (byte)c;
data[n] = (byte)(c >> 8);
}
finally
{
Encrypt();
}
}
// internal/private stuff
// [MethodImplAttribute(MethodImplOptions.InternalCall)]
// extern static void EncryptInternal (byte [] data, object scope);
// [MethodImplAttribute(MethodImplOptions.InternalCall)]
// extern static void DecryptInternal (byte [] data, object scope);
// static readonly object scope = Enum.Parse (
// Assembly.Load (Consts.AssemblySystem_Security)
// .GetType ("System.Security.Cryptography.MemoryProtectionScope"), "SameProcess");
// Note that ProtectedMemory is not supported on non-Windows environment right now.
private void Encrypt()
{
if ((data != null) && (data.Length > 0))
{
// It somehow causes nunit test breakage
// EncryptInternal (data, scope);
}
}
// Note that ProtectedMemory is not supported on non-Windows environment right now.
private void Decrypt()
{
if ((data != null) && (data.Length > 0))
{
// It somehow causes nunit test breakage
// DecryptInternal (data, scope);
}
}
// note: realloc only work for bigger buffers. Clear will
// reset buffers to default (and small) size.
private void Alloc(int length, bool realloc)
{
if ((length < 0) || (length > MaxSize))
throw new ArgumentOutOfRangeException("length", "< 0 || > 65536");
// (size / blocksize) + 1 * blocksize
// where size = length * 2 (unicode) and blocksize == 16 (ProtectedMemory)
// length * 2 (unicode) / 16 (blocksize)
int size = (length >> 3) + (((length & 0x7) == 0) ? 0 : 1) << 4;
// is re-allocation necessary ? (i.e. grow or shrink
// but do not re-allocate the same amount of memory)
if (realloc && (data != null) && (size == data.Length))
return;
if (realloc)
{
// copy, then clear
byte[] newdata = new byte[size];
Array.Copy(data, 0, newdata, 0, Math.Min(data.Length, newdata.Length));
Array.Clear(data, 0, data.Length);
data = newdata;
}
else
{
data = new byte[size];
}
}
// dangerous method (put a LinkDemand on it)
internal byte[] GetBuffer()
{
byte[] secret = new byte[length << 1];
try
{
Decrypt();
Buffer.BlockCopy(data, 0, secret, 0, secret.Length);
}
finally
{
Encrypt();
}
// NOTE: CALLER IS RESPONSIBLE TO ZEROIZE THE DATA
return secret;
}
internal IntPtr ToPtr()
{
var ptr = Marshal.AllocHGlobal((this.Length+1) *2 );
for (var i = 0; i < this.Length * 2; i++)
{
Marshal.WriteByte(ptr,i, this.data[i]);
}
Marshal.WriteByte(ptr,this.Length*2, 0);
Marshal.WriteByte(ptr,this.Length*2+1, 0);
return ptr;
}
}
public static class SecureStringMarshal
{
public static IntPtr SecureStringToCoTaskMemUnicode(SecureString s)
{
if (s == null)
{
throw new ArgumentNullException("s");
}
return s.ToPtr();
}
public static void ZeroFreeCoTaskMemUnicode(IntPtr s)
{
Marshal.ZeroFreeCoTaskMemUnicode(s);
}
}
}

View File

@ -0,0 +1,13 @@
{
"version": "1.0.0-*",
"description": "SecureString Stub",
"authors": [ "garretts" ],
"compilationOptions": { "allowUnsafe": true },
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616"
},
"frameworks": { "dnxcore50": { } }
}

View File

@ -0,0 +1,8 @@
# TypeCatalogGen
`./build.sh` runs the Core PowerShell `TypeCatalogGen.exe` under Mono
on Linux (using `dotnet-cli`). The `Runtime` folder is a facade
project that, when published, produces a list of the currently used
runtime assemblies for .NET Core. The output is
`CorePsTypeCatalog.cs`, which contains an "initialized" dictionary
that we copy into `typecatalog.cs` of `System.Management.Automation`

View File

@ -0,0 +1,40 @@
{
"version": "1.0.0-*",
"description": "Facade to generate folder of dependencies",
"authors": [ "andschwa" ],
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23616",
"Microsoft.CSharp": "4.0.1-rc2-23616",
"Microsoft.Win32.Registry.AccessControl": "4.0.0-rc2-23616",
"System.Collections.Specialized": "4.0.1-rc2-23616",
"System.ComponentModel.EventBasedAsync": "4.0.11-rc2-23616",
"System.ComponentModel.TypeConverter": "4.0.1-rc2-23616",
"System.Data.Common": "4.0.1-rc2-23616",
"System.Diagnostics.Contracts": "4.0.1-rc2-23616",
"System.Diagnostics.FileVersionInfo": "4.0.0-rc2-23616",
"System.Diagnostics.TraceSource": "4.0.0-rc2-23616",
"System.Dynamic.Runtime": "4.0.11-rc2-23616",
"System.IO.FileSystem.AccessControl": "4.0.0-rc2-23616",
"System.IO.FileSystem.DriveInfo": "4.0.0-rc2-23616",
"System.IO.FileSystem.Watcher": "4.0.0-rc2-23616",
"System.IO.Pipes": "4.0.0-rc2-23616",
"System.Linq.Expressions": "4.0.11-rc2-23616",
"System.Net.Http": "4.0.1-rc2-23616",
"System.Net.NetworkInformation": "4.1.0-rc2-23616",
"System.Reflection.Emit.Lightweight": "4.0.1-rc2-23616",
"System.Security.AccessControl": "4.0.0-rc2-23616",
"System.Security.Cryptography.Algorithms": "4.0.0-rc2-23616",
"System.Security.Cryptography.X509Certificates": "4.0.0-rc2-23616",
"System.Threading.Tasks.Parallel": "4.0.1-rc2-23616",
"System.Xml.XPath.XmlDocument": "4.0.1-rc2-23616",
"System.Xml.XmlDocument": "4.0.1-rc2-23616",
"System.Xml.XmlSerializer": "4.0.11-rc2-23616",
"System.ServiceProcess.ServiceController": "4.1.0-rc2-23616",
"System.Net.NameResolution": "4.0.0-rc2-23616"
},
"frameworks": { "dnxcore50": { } }
}

9
src/TypeCatalogGen/build.sh Executable file
View File

@ -0,0 +1,9 @@
. mono-snapshot mono
export DOTNET_REFERENCE_ASSEMBLIES_PATH=$MONO_PREFIX/lib/mono/xbuild-frameworks/
(cd Runtime && dotnet restore && dotnet publish --framework dnxcore50 --runtime ubuntu.14.04-x64 --output bin)
ls Runtime/bin/*.dll | sed ':a;N;$!ba;s/\n/;/g' > powershell.inc
dotnet restore
dotnet run CorePsTypeCatalog.cs powershell.inc
cp CorePsTypeCatalog.cs ../Microsoft.PowerShell.CoreCLR.AssemblyLoadContext/

View File

@ -0,0 +1,28 @@
{
"version": "1.0.0-*",
"description": "PowerShell TypeCatalogGen.exe",
"authors": [ "andschwa" ],
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"System.Reflection.Metadata": "1.1.1-beta-23516",
"System.Collections.Immutable": "1.1.38-beta-23516"
},
"compileFiles": [
"../monad/monad/nttargets/assemblies/core/PSAssemblyLoadContext/TypeCatalogGen/TypeCatalogGen.cs"
],
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.IO": "",
"System.Reflection.Primitives": ""
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +0,0 @@
# This is the makefile for all kinds of powershell hosts
#
# Currently there is powershell-run.exe, which is a very generic interactive and
# non-interactive host
POWERSHELL_RUN_FOLDER=$(MONAD)/src/host
POWERSHELL_RUN_SRCS=$(addprefix $(POWERSHELL_RUN_FOLDER)/, main.cs host.cs ui.cs rawui.cs readline.cs powershell.assembly-info.cs)
# direct dependencies to be linked in
POWERSHELL_RUN_DEPS=$(addprefix $(PSLIB)/, System.Management.Automation.dll Microsoft.PowerShell.Commands.Management.dll $(ASSEMBLY_LOAD_CONTEXT_TARGET))
POWERSHELL_RUN_REFS=$(addprefix -r:, $(POWERSHELL_RUN_DEPS))
$(PSLIB)/PSL_profile.ps1:
cp -f $(POWERSHELL_RUN_FOLDER)/$(notdir $@) $@
$(PSLIB)/powershell.exe: $(POWERSHELL_RUN_SRCS) $(POWERSHELL_RUN_DEPS) $(PSLIB)/PSL_profile.ps1
$(CSC) -out:$@ -noconfig -nostdlib -target:exe $(POWERSHELL_RUN_REFS) $(COREREF) $(POWERSHELL_RUN_SRCS)

View File

@ -1,4 +0,0 @@
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]

@ -1 +1 @@
Subproject commit 0720e033d9f241571d6d5d7378836773a50cc1cd
Subproject commit 0840d4fe5b837150810a643b3ecd8063c13dbdbc

@ -1 +1 @@
Subproject commit a4646ceb48bb8ccc6aa892c38d472d7782d0e84b
Subproject commit 1f3f6a086f2746ad88f4198e30277f4e672f683e

@ -1 +0,0 @@
Subproject commit 5e064121f6bdb9bff9a4b3783a5261ec355d9304

@ -1 +1 @@
Subproject commit 07a2f9fe80de510ad4bce9cedffb9a163ada849d
Subproject commit eb6099fb49242f21b01d41bdba1c22ea93898835

@ -1 +1 @@
Subproject commit 09563f5b104826d6835397e6a648bf51bec890d3
Subproject commit e9a8d957c146c6e23ac2dea508870717422f335b

@ -1 +1 @@
Subproject commit 7c3605bd38a0879a8faa76626299283251538d96
Subproject commit 7c4e7389d7aada5d9eeeef95291fdc2617ef821d

View File

@ -1,7 +1,10 @@
Describe "Export-Alias" {
$testAliasDirectory = $env:TEMP + "/ExportAliasTestDirectory"
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
. $here/Test-Common.ps1
Describe "Export-Alias" {
$testAliasDirectory = "$(GetTempDir)/ExportAliasTestDirectory"
$testAliases = "TestAliases"
$fulltestpath = $testAliasDirectory + "/" + $testAliases
$fulltestpath = "$($testAliasDirectory)/$($testAliases)"
BeforeEach {
New-Item -Path $testAliasDirectory -ItemType Directory -Force
@ -31,4 +34,4 @@
}
Remove-Item -Path $testAliasDirectory -Recurse -Force
}
}

View File

@ -0,0 +1,50 @@
Describe "Get-FileHash" {
New-Variable testDocument -Value $PSScriptRoot/assets/testablescript.ps1 -Scope Global -Force
# The MACTripleDES and RIPEMD160 algorithms are unsupported at the moment
$algorithms = @{"SHA1" ="01B865D143E07ECC875AB0EFC0A4429387FD0CF7";
"SHA256" = "4A6DA9F1C0827143BB19FC4B0F2A8057BC1DF55F6D1F62FA3B917BA458E8F570";
"SHA384" = "656215B6A07011E625206F43E57873F49AD7B36DFCABB70F6CDCE2303D7A603E55D052774D26F339A6D80A264340CB8C";
"SHA512" = "C688C33027D89ACAC920545471C8053D8F64A54E21D0415F1E03766DDCDA215420E74FAFD1DC399864C6B6B5723A3358BD337339906797A39090B02229BF31FE";
"MD5" = "7B09811D1631C9FD46B39D1D35522F0A";
}
Context "Cmdlet result tests" {
It "Should default to correct hash algorithm" {
$result = Get-FileHash $testDocument
$result.Algorithm | Should Be "SHA256"
}
It "Should be able to set the default hash algorithm" {
$PSDefaultParameterValues.add("Get-FileHash:Algorithm","MD5")
$result = Get-FileHash $testDocument
$result.Algorithm | Should Be "MD5"
$PSDefaultParameterValues.Remove("Get-FileHash:Algorithm")
}
It "Should list the path of the file under test" {
$result = Get-FileHash $testDocument
# regular expression for the forward/backslashes for linux/windows compatability
$result.Path | Should Match "assets[/|\\]testablescript.ps1"
}
}
Context "Algorithm tests" {
It "Should be able to get the correct hash from each algorithm" {
foreach ( $algorithm in $algorithms.Keys)
{
$algorithmResult = Get-FileHash $testDocument -Algorithm $algorithm
$algorithmResult.Hash | Should Be $algorithms[$algorithm]
}
#MACTripleDES and RIPEMD160 are unsupported in the existing Pester tests from windows team
{ Get-FileHash $testDocument -Algorithm MACTripleDES } | Should Throw "Algorithm 'MACTripleDES' is not supported in this system."
{ Get-FileHash $testDocument -Algorithm RIPEMD160 } | Should Throw "Algorithm 'RIPEMD160' is not supported in this system."
}
}
}

View File

@ -1,17 +0,0 @@
Describe "Get-TypeData" {
It "Should be able to call Get-TypeData with no arguments without throwing" {
{ Get-TypeData } | Should Not Throw
}
It "Should return an array of several elements when no arguments are used" {
$output = Get-TypeData
$output.Length | Should BeGreaterThan 1
}
It "Should be able to take wildcard input" {
$output = Get-TypeData *Sys*
$output.Length | Should BeGreaterThan 1
}
}

View File

@ -8,7 +8,7 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "Json.NET LINQ Parsing" {
# load third party Json.NET library
$path = "tools/Newtonsoft.Json.7.0.1/lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll"
$path = "$env:CORE_ROOT/Newtonsoft.Json.dll"
[Microsoft.PowerShell.CoreCLR.AssemblyExtensions]::LoadFrom($path)
BeforeEach {

View File

@ -126,7 +126,7 @@
}
Context "String tests" {
if ($env:TEMP -eq "/tmp")
if ($true) # TODO: test if Windows or Linux
{
$nl = "`n"
}

View File

@ -0,0 +1,46 @@
Describe "New-TimeSpan" {
It "Should be able to create a new timespan object" {
New-Variable -Name testObject -Value $(New-TimeSpan)
$testObject.GetType() | Should Be timespan
}
Context "Core Functionality Tests" {
New-Variable -Name testObject -Value $(New-TimeSpan -Days 2 -Hours 23 -Minutes 4 -Seconds 3) -Force
$expectedOutput = @{ "Days" = "2";
"Hours" = "23";
"Minutes" = "4";
"Seconds" = "3";
"Milliseconds" = "0";
"Ticks" = "2558430000000";
"TotalDays" = "2.96114583333333";
"TotalHours" = "71.0675";
"TotalMinutes" = "4264.05";
"TotalSeconds" = "255843";
"TotalMilliseconds" = "255843000"
}
$TEN_MILLION = 10000000
It "Should have expected values for time properties set during creation" {
$testObject.Days | Should Be $expectedOutput["Days"]
$testObject.Hours | Should Be $expectedOutput["Hours"]
$testObject.Minutes | Should Be $expectedOutput["Minutes"]
$testObject.Seconds | Should Be $expectedOutput["Seconds"]
$testObject.Ticks | Should Be $expectedOutput["Ticks"]
}
}
It "Should have matching output when using the Start switch vs piping from another cmdlet" {
# this file is guarenteed to exist
$inputObject = (Get-ChildItem $PSScriptRoot/New-TimeSpan.Tests.ps1)
$inputParameter = New-TimeSpan -Start $inputObject.lastwritetime
$pipedInput = $inputObject | New-TimeSpan
$difference = [math]::Abs($inputParameter.Milliseconds - $pipedInput.Milliseconds)
# The difference between commands should be minimal
$difference | Should BeLessThan 10
}
}

View File

@ -0,0 +1,76 @@
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "Remove-PSBreakpoint" {
# Set up test script
$testScript = "$here/assets/psbreakpointtestscript.ps1"
$script = "`$var = 1
`$var2 = Get-Process
# this is a comment
Get-Date
"
$script > $testScript
BeforeEach {
# set some breakpoints
$line = Set-PSBreakpoint -Line 1,2,3 -Script $testScript
$command = Set-PSBreakpoint -Command "Get-Date" -Script $testScript
$variable = Set-PSBreakpoint -Variable var2 -Script $testScript
}
Context "Basic Removal Methods Tests" {
It "Should be able to remove a breakpoint by breakpoint Id" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
$BreakID = $(Get-PSBreakpoint).Id[0]
Remove-PSBreakpoint -Id $BreakID
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
It "Should be able to remove a breakpoint by variable" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
Remove-PSBreakpoint -Breakpoint $variable
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
It "Should be able to remove a breakpoint by command" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
Remove-PSBreakpoint -Breakpoint $command
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
It "Should be able to pipe breakpoint objects to Remove-PSBreakpoint" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
$variable | Remove-PSBreakpoint
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
}
Context "Alias Tests" {
It "Should remove a breakpoint using the rbp alias" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
$BreakID = $(Get-PSBreakpoint).Id[0]
rbp -Id $BreakID
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
}
It "Should Remove all breakpoints" {
$(Get-PSBreakpoint).Id.Length | Should Not BeNullOrEmpty
Get-PSBreakpoint | Remove-PSBreakpoint
$(Get-PSBreakpoint).Id.Length | Should Be 0
}
#Clean up after ourselves
Remove-Item $testScript
}

View File

@ -1,14 +1,34 @@
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "Set-PSBreakpoint" {
New-Variable -Name script -Value $here/assets/testablescript.ps1 -Scope Global -Force
It "Should be able to called with script and line parameters without error " {
{ Set-PSBreakpoint -Script $script -Line 1 } | Should Not Throw
}
It "Should be able to be called using the command switch" {
# Note- we don't actually require the command to exist in the script- it will simply not get a breakpoint
{ Set-PSBreakpoint -Script $script -Command aoeuaoeu } | Should Not Throw
}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "Set-PSBreakpoint" {
# Set up test script
$testScript = "$here/psbreakpointtestscript.ps1"
"`$var = 1 " > $testScript
It "Should be able to set a psbreakpoint on a line" {
$lineNumber = 1
$(Set-PSBreakpoint -Line $lineNumber -Script $testScript).Line | Should Be $lineNumber
}
It "Should throw when a string is entered for a line number" {
{
$lineNumber = "one"
$(Set-PSBreakpoint -Line $lineNumber -Script $testScript).Line
} | Should Throw
}
It "Should be able to set a psbreakpoint on a Command" {
$command = "theCommand"
$(Set-PSBreakpoint -Command $command -Script $testScript).Command | Should Be $command
}
It "Should be able to set a psbreakpoint on a variable" {
$var = "theVariable"
$(Set-PSBreakpoint -Command $var -Script $testScript).Command | Should Be $var
}
# clean up after ourselves
Remove-Item -Path $testScript
}

View File

@ -4,41 +4,20 @@
Describe "Start-Process" {
$pingCommand = (Get-Command -CommandType Application ping)[0].Definition
$pingDirectory = Split-Path $pingCommand -Parent
$tempDir = GetTempDir
$tempFile = $tempDir + "PSTest"
$tempFile = "$(GetTempDir)/PSTest"
$assetsFile = $here + "/assets/SortTest.txt"
$windows = IsWindows
if ($windows)
{
$pingParamNoStop = "localhost -t"
$pingParamStop = "localhost -n 2"
$pingParam = "localhost -n 4"
}
else
{
$pingParamNoStop = "localhost"
$pingParamStop = "localhost -c 2"
}
AfterEach {
Stop-Process -Name ping -ErrorAction SilentlyContinue
}
It "Should start a process without error" {
{ Start-Process ping } | Should Not Throw
$pingParam = "localhost -c 4"
}
It "Should process arguments without error" {
{ Start-Process ping -ArgumentList $pingParamNoStop} | Should Not Throw
$process = Get-Process -Name ping
$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
$process.ProcessName | Should Be "ping"
}
It "Should create process object when used with PassThru argument" {
$process = Start-Process ping -ArgumentList $pingParamNoStop -PassThru
$process = Start-Process ping -ArgumentList $pingParam -PassThru
$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
@ -46,7 +25,7 @@ Describe "Start-Process" {
}
It "Should work correctly when used with full path name" {
$process = Start-Process $pingCommand -ArgumentList $pingParamNoStop -PassThru
$process = Start-Process $pingCommand -ArgumentList $pingParam -PassThru
$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
@ -54,7 +33,7 @@ Describe "Start-Process" {
}
It "Should invoke correct path when used with FilePath argument" {
$process = Start-Process -FilePath $pingCommand -ArgumentList $pingParamNoStop -PassThru
$process = Start-Process -FilePath $pingCommand -ArgumentList $pingParam -PassThru
$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
@ -62,15 +41,11 @@ Describe "Start-Process" {
}
It "Should wait for command completion if used with Wait argument" {
Start-Process ping -ArgumentList $pingParamStop -Wait
$process = Get-Process -Name ping -ErrorAction SilentlyContinue
$process.Length | Should Be 0
$process = Start-Process ping -ArgumentList $pingParam -Wait -PassThru
}
It "Should work correctly with WorkingDirectory argument" {
$process = Start-Process ping -WorkingDirectory $pingDirectory -ArgumentList $pingParamNoStop -PassThru
$process = Start-Process ping -WorkingDirectory $pingDirectory -ArgumentList $pingParam -PassThru
$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
@ -78,7 +53,7 @@ Describe "Start-Process" {
}
It "Should should handle stderr redirection without error" {
$process = Start-Process ping -ArgumentList $pingParamNoStop -PassThru -RedirectStandardError $tempFile
$process = Start-Process ping -ArgumentList $pingParam -PassThru -RedirectStandardError $tempFile
$process.Length | Should Be 1
$process.Id | Should BeGreaterThan 1
@ -86,19 +61,14 @@ Describe "Start-Process" {
}
It "Should should handle stdout redirection without error" {
$process = Start-Process ping -ArgumentList $pingParamStop -Wait -RedirectStandardOutput $tempFile
$process = Start-Process ping -ArgumentList $pingParam -Wait -RedirectStandardOutput $tempFile
$dirEntry = dir $tempFile
$dirEntry.Length | Should BeGreaterThan 0
$dirEntry.Length | Should BeGreaterThan 0
}
It "Should should handle stdin redirection without error" {
$process = Start-Process sort -Wait -RedirectStandardOutput $tempFile -RedirectStandardInput $assetsFile
$process = Start-Process sort -Wait -RedirectStandardOutput $tempFile -RedirectStandardInput $assetsFile
$dirEntry = dir $tempFile
$dirEntry.Length | Should BeGreaterThan 0
$dirEntry.Length | Should BeGreaterThan 0
}
}

View File

@ -16,7 +16,7 @@ Function GetTempDir
}
else
{
return "/tmp/"
return "/tmp"
}
}

View File

@ -1,9 +1,14 @@
Describe "Wait-Event" {
Context "Validate Wait-Event is waiting for events" {
It "Should verify Wait-Event is waiting for at least a second" {
$waiteventtime = Measure-Command { Wait-Event -timeout 1 }
$waiteventtime.Seconds | Should BeGreaterThan 0
It "Should time out when it does not receive a FakeEvent" {
# Don't depend on Measure-Command
$stopwatch = [System.Diagnostics.Stopwatch]::startNew()
# Testing the the timeout, so wait for an event that will never be
# raised because it is fake
Wait-Event -Timeout 1 -SourceIdentifier "FakeEvent"
$stopwatch.Stop()
$stopwatch.ElapsedMilliseconds | Should BeGreaterThan 1000
}
}
}

View File

@ -0,0 +1,68 @@
Describe "Write-Output" {
$testString = $testString
Context "Input Tests" {
It "Should allow piped input" {
{ $testString | Write-Output } | Should Not Throw
}
It "Should write output to the output stream when using piped input" {
$testString | Write-Output | Should Be $testString
}
It "Should use inputobject switch" {
{ Write-Output -InputObject $testString } | Should Not Throw
}
It "Should write output to the output stream when using inputobject switch" {
Write-Output -InputObject $testString | Should Be $testString
}
It "Should be able to write to a variable" {
Write-Output -InputObject $testString -OutVariable var
$var | Should Be $testString
}
}
Context "Pipeline Command Tests" {
It "Should send object to the next command in the pipeline" {
Write-Output -InputObject (1+1) | Should Be 2
}
It "Should have the same result between inputobject switch and piped input" {
Write-Output -InputObject (1+1) | Should Be 2
1+1 | Write-Output | Should Be 2
}
}
Context "Alias Tests" {
It "Should have the same result between the echo alias and the cmdlet" {
$alias = echo -InputObject $testString
$cmdlet = Write-Output -InputObject $testString
$alias | Should Be $cmdlet
}
It "Should have the same result between the write alias and the cmdlet" {
$alias = write -InputObject $testString
$cmdlet = Write-Output -InputObject $testString
$alias | Should Be $cmdlet
}
}
Context "Enumerate Objects" {
$enumerationObject = @(1,2,3)
It "Should see individual objects when not using the NoEnumerate switch" {
$singleCollection = $(Write-Output $enumerationObject| Measure-Object).Count
$singleCollection | Should Be $enumerationObject.length
}
It "Should be able to treat a collection as a single object using the NoEnumerate switch" {
$singleCollection = $(Write-Output $enumerationObject -NoEnumerate | Measure-Object).Count
$singleCollection | Should Be 1
}
}
}

View File

@ -0,0 +1,71 @@
Describe "Stream writer tests" {
$targetfile = "writeoutput.txt"
# A custom function is defined here do handle the debug stream dealing with the confirm prompt
# that would normally
function Write-Messages
{
[CmdletBinding()]
param()
If ($PSBoundParameters['Debug']) { $DebugPreference = 'Continue' }
Write-Verbose "Verbose message"
Write-Debug "Debug message"
}
function Get-OutputResults
{
# Get the contents of the targetfile.
# Make the array a string for less brittle testing
$output = $(Get-Content $args[0])
[String]::Join([Environment]::NewLine, $output )
return $output
}
Context "Redirect Stream Tests" {
# These tests validate that a stream is actually being written to by redirecting the output of that stream
AfterEach { Remove-Item $targetfile }
It "Should write warnings to the warning stream" {
Write-Warning "Test Warning" 3>&1 > $targetfile
Get-Content $targetfile | Should Be "Test Warning"
}
It "Should write error messages to the error stream" {
Write-Error "Testing Error" 2>&1 > $targetfile
$result = Get-OutputResults $targetfile
# The contents of the error stream should contain the expected text
$result -match ": Testing Error" | Should Be $true
}
It "Should write debug messages to the debug stream" {
Write-Messages -Debug -EA SilentlyContinue 5>&1 > $targetfile
$result = Get-OutputResults $targetfile
# The contents of the debug stream should contain the expected text
$result -match "Debug Message" | Should Be $true
}
It "Should write messages to the verbose stream" {
Write-Messages -Verbose 4>&1 > $targetfile
$result = Get-OutputResults $targetfile
# The contents of the debug stream should contain the expected text
$result -match "Verbose Message" | Should Be $true
}
}
Context "Error automatic variable" {
It "Should write error messages to the `$Error automatic variable" {
Write-Error "Test Error Message" -ErrorAction SilentlyContinue
$Error[0] | Should Match "Test Error Message"
}
}
}

View File

@ -0,0 +1,29 @@
Describe "Write-Verbose" {
It "Should be able to call cmdlet without error" {
{ Write-Verbose -Message "test" -ErrorAction SilentlyContinue } | Should Not Throw
}
It "Should not display verbose output by default" {
$VerbosePreference | Should Be SilentlyContinue
Write-Verbose -Message "test" | Should BeNullOrEmpty
}
It "Should be able to set verbose output to display by changing the `$VerbosePreference automatic variable" {
$VerbosePreference = "Continue"
Write-Verbose -Message "test" 4>&1 | Should Not BeNullOrEmpty
$VerbosePreference = "SilentlyContinue"
}
It "Should be able to set verbose output to display by using the verbose switch" {
Write-Verbose -Message "test" -Verbose 4>&1 | Should Be "test"
}
It "Should be able to set verbose switch using a colon and boolean" {
{ Write-Verbose -Message "test" -Verbose:$false } | Should Not Throw
$(Write-Verbose -Message "test" -Verbose:$true) 4>&1 | Should Be "test"
}
}

View File

@ -0,0 +1,2 @@
api-ms-win-core-registry-l1-1-0.dll: api-ms-win-core-registry-l1-1-0.c
gcc -o $@ -fPIC -shared -Wall $^

View File

@ -0,0 +1,20 @@
This stubs the `RegCloseKey` function provided on Windows by
`api-ms-win-core-registry-l1-1-0.dll`.
Without this DLL in the library path, the following exception is
thrown upon shutdown of PowerShell. While I do not like hiding this
error, it is neccesary for the rest of PowerShell to shutdown
properly, and release its file descriptors. Otherwise the shell will
mess up Bash, and it needs to be reset.
This must be removed as soon as it can be addressed in a better way.
```
Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'api-ms-win-core-registry-l1-1-0.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
at Interop.mincore.RegCloseKey(IntPtr hKey)
at Microsoft.Win32.SafeHandles.SafeRegistryHandle.ReleaseHandle()
at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
at System.Runtime.InteropServices.SafeHandle.Finalize()
```

View File

@ -1,12 +1,11 @@
#include <stdint.h>
int32_t RegCloseKey(void* handle)
{
return 0;
}
int32_t RegOpenKeyExW(void* hKey,uint16_t* lpSubKey,uint32_t ulOptions,uint32_t samDesired,void* phkResult)
{
return 1;
}
int32_t RegCloseKey(void* handle)
{
return 0;
}

View File

@ -1,3 +0,0 @@
This folder holds sources to stubbed out windows dlls that are needed at the current state
of CoreCLR, but should not be required in the long run.

View File

@ -1,48 +0,0 @@
using Xunit;
using System;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
namespace PSTests
{
public static class RunspaceTests
{
[Fact]
public static void TestMethod()
{
InitialSessionState iss = InitialSessionState.CreateDefault2();
// NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output
// in addition to just the PSObjects
using (Runspace rs = RunspaceFactory.CreateRunspace(/*myHost,*/iss))
{
rs.Open();
using (PowerShell ps = PowerShell.Create())
{
ps.Runspace = rs;
string script = "get-process | select-object -first 3";
ps.AddScript(script);
// IMPORTANT NOTE: do not call AddCommand("out-host") here or
// MergeMyResults, otherwise Invoke will not return any objects
var results = ps.Invoke();
// check that there are 3 captured objects
int objCount = 0;
foreach (var result in results)
{
// this is how an object would be captured here and looked at,
// each result is a PSObject with the data from the pipeline
++objCount;
Assert.NotNull(result);
}
Assert.Equal(3,objCount);
ps.Dispose();
}
}
}
}
}

View File

@ -1,12 +0,0 @@
# xUnit tests for PowerShell
# - results in xunit-tests.xml
# - see https://xunit.github.io/
TEST_FOLDER=$(MONAD)/src/xunit-tests
TEST_SRCS=$(TEST_FOLDER)/test_*.cs
TEST_TARGETS=$(addprefix $(PSLIB)/, System.Management.Automation.dll Microsoft.PowerShell.Commands.Management.dll)
$(PSLIB)/PowerShell.Linux.Test.dll: $(TEST_SRCS) $(TEST_TARGETS)
$(CSC) $(CSCOPTS_LIB) -out:$@ $(addprefix -r:$(MONAD_EXT)/xunit/, xunit.core.dll xunit.assert.dll) $(addprefix -r:, $(TEST_TARGETS)) $(COREREF) $(TEST_SRCS)
test: $(PSLIB)/PowerShell.Linux.Test.dll
$(POWERSHELL) $(PSLIB)/xunit.console.netcore.exe $< -xml $(MONAD)/xunit-tests.xml

Binary file not shown.