This repository was archived by the owner on Apr 27, 2026. It is now read-only.
Repository navigation
Initial PowerShelll kernel prototype #9
Merged
jonsequitur
merged 27 commits into
dotnet:master
from
TylerLeonhardt:add-powershell-subkernel
Jan 31, 2020
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
542a675
add PowerShell subkernel
TylerLeonhardt 8e41f9e
simplify code and address feedback
TylerLeonhardt 36f2ec3
misc cleanup
TylerLeonhardt 1e0754a
add empty test project like csharp
TylerLeonhardt b7668fc
Add test project to sln
TylerLeonhardt df9ef5b
fix up psd1 and update headers
TylerLeonhardt ba3d16d
PR feedback
TylerLeonhardt ff4ac7c
analyzer fixes
TylerLeonhardt f73e071
additional comment
TylerLeonhardt 0802ffe
remove manditory from InputObject
TylerLeonhardt 6c8095e
handle parse errors and fix trace-pipelineobjectcommand param
TylerLeonhardt bcf0295
signing file change
TylerLeonhardt 24b0ced
whitespace
TylerLeonhardt dd2a0c6
one more signing
TylerLeonhardt d4b3018
change to none
TylerLeonhardt 3bc49d7
remove IExtensibleKernel for now until we understand what we want tha…
TylerLeonhardt 8d61e78
some tests and small changes to formatting
TylerLeonhardt 1913ea2
refactor tests
TylerLeonhardt e3839bb
powershell telemetry & hook up forgotten Progress stream
TylerLeonhardt 9ae44d5
updating progresses!
TylerLeonhardt 807977c
add progress test
TylerLeonhardt dfcded8
help for ci failures
TylerLeonhardt 9318b4e
exclude files from symbols packages
brettfo bc99793
rewrite package file stripper in pure MSBuild for cross-plat
brettfo 1cb3994
workaround PowerShell bug
TylerLeonhardt ed4dac7
Jon feedback
TylerLeonhardt d9f25ab
remove timeout on new tests
TylerLeonhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
....DotNet.Interactive.PowerShell.Tests/Microsoft.DotNet.Interactive.PowerShell.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| <LangVersion>latest</LangVersion> | ||
| <Deterministic Condition="'$(NCrunch)' == '1'">false</Deterministic> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Remove="TestResults\**" /> | ||
| <Compile Remove="TestProjects\**" /> | ||
| <EmbeddedResource Remove="TestResults\**" /> | ||
| <None Remove="TestResults\**" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Microsoft.DotNet.Interactive.PowerShell\Microsoft.DotNet.Interactive.PowerShell.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
17 changes: 17 additions & 0 deletions
17
Microsoft.DotNet.Interactive.PowerShell/Commands/CommandUtils.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System.Management.Automation; | ||
| using Microsoft.PowerShell.Commands; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive.PowerShell.Commands | ||
| { | ||
| internal class CommandUtils | ||
| { | ||
| internal readonly static CmdletInfo OutStringCmdletInfo = new CmdletInfo("Out-String", typeof(OutStringCommand)); | ||
| internal readonly static CmdletInfo WriteInformationCmdletInfo = new CmdletInfo("Write-Information", typeof(WriteInformationCommand)); | ||
|
|
||
| internal readonly static object BoxedTrue = (object)true; | ||
| internal readonly static object BoxedFalse = (object)false; | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
Microsoft.DotNet.Interactive.PowerShell/Commands/TracePipelineObjectCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.DotNet.Interactive.PowerShell.Commands | ||
| { | ||
| using System.Management.Automation; | ||
|
|
||
| /// <summary> | ||
| /// Writes the formatted output of the pipeline object to the information stream before passing the object down to the pipeline. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This Cmdlet behaves like 'Tee-Object'. | ||
| /// An input pipeline object is first pushed through a steppable pipeline that consists of 'Out-String | Write-Information -Tags "__PipelineObject__"', | ||
| /// and then it's written out back to the pipeline without change. In this approach, we can intercept and trace the pipeline objects in a streaming way | ||
| /// and keep the objects in pipeline at the same time. | ||
| /// </remarks> | ||
| [Cmdlet(VerbsDiagnostic.Trace, "PipelineObject")] | ||
| public sealed class TracePipelineObjectCommand : PSCmdlet | ||
| { | ||
| /// <summary> | ||
| /// The object from pipeline. | ||
| /// </summary> | ||
| [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] | ||
| [AllowNull] | ||
| public object InputObject { get; set; } | ||
|
|
||
| private static PowerShell _pwsh; | ||
| private SteppablePipeline _stepPipeline; | ||
|
|
||
| static TracePipelineObjectCommand() | ||
| { | ||
| _pwsh = PowerShell.Create(); | ||
| _pwsh.AddCommand(CommandUtils.OutStringCmdletInfo).AddParameter("Stream", CommandUtils.BoxedTrue) | ||
| .AddCommand(CommandUtils.WriteInformationCmdletInfo).AddParameter("Tags", "__PipelineObject__"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// BeginProcessing override. | ||
| /// </summary> | ||
| protected override void BeginProcessing() | ||
| { | ||
| _stepPipeline = _pwsh.GetSteppablePipeline(); | ||
| _stepPipeline.Begin(this); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// ProcessRecord override. | ||
| /// </summary> | ||
| protected override void ProcessRecord() | ||
| { | ||
| _stepPipeline.Process(InputObject); | ||
| WriteObject(InputObject); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// EndProcessing override. | ||
| /// </summary> | ||
| protected override void EndProcessing() | ||
| { | ||
| _stepPipeline.End(); | ||
| } | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
Microsoft.DotNet.Interactive.PowerShell/Microsoft.DotNet.Interactive.PowerShell.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
|
TylerLeonhardt marked this conversation as resolved.
Resolved
|
||
| <LangVersion>latest</LangVersion> | ||
| <NoWarn>$(NoWarn);2003;CS8002;NU1608;</NoWarn> <!-- AssemblyInformationalVersionAttribute contains a non-standard value --> | ||
| <Deterministic Condition="'$(NCrunch)' == '1'">false</Deterministic> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
| <NoWarn>;NU5104;2003;8002</NoWarn> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Microsoft.DotNet.Interactive.Formatting\Microsoft.DotNet.Interactive.Formatting.csproj" /> | ||
| <ProjectReference Include="..\Microsoft.DotNet.Interactive\Microsoft.DotNet.Interactive.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.PowerShell.SDK" Version="7.0.0-rc.1" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Content Include="Modules\**" PackageCopyToOutput="true"> | ||
| <Link>Modules\%(RecursiveDir)\%(FileName)%(Extension)</Link> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </Content> | ||
| </ItemGroup> | ||
| </Project> | ||
94 changes: 94 additions & 0 deletions
94
...ules/Microsoft.DotNet.Interactive.PowerShell/Microsoft.DotNet.Interactive.PowerShell.psd1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| # Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| @{ | ||
| # Version number of this module. | ||
| ModuleVersion = '0.1.0' | ||
|
|
||
| # Supported PSEditions | ||
| CompatiblePSEditions = @('Core') | ||
|
|
||
| # ID used to uniquely identify this module | ||
| GUID = 'c3ca4cca-fd49-4b1e-a79e-b12afb026068' | ||
|
|
||
| # Author of this module | ||
| Author = 'Microsoft Corporation' | ||
|
|
||
| # Company or vendor of this module | ||
| CompanyName = 'Microsoft Corporation' | ||
|
|
||
| # Copyright statement for this module | ||
| Copyright = 'Copyright (c) .NET Foundation and contributors. All rights reserved.' | ||
|
|
||
| # Description of the functionality provided by this module | ||
| # Description = '' | ||
|
|
||
| # Minimum version of the PowerShell engine required by this module | ||
| PowerShellVersion = '7.0.0' | ||
|
|
||
| # Modules that must be imported into the global environment prior to importing this module | ||
| RequiredModules = @() | ||
|
|
||
| # Assemblies that must be loaded prior to importing this module | ||
| RequiredAssemblies = @() | ||
|
|
||
| # Script files (.ps1) that are run in the caller's environment prior to importing this module. | ||
| ScriptsToProcess = @() | ||
|
|
||
| # Type files (.ps1xml) to be loaded when importing this module | ||
| TypesToProcess = @() | ||
|
|
||
| # Format files (.ps1xml) to be loaded when importing this module | ||
| FormatsToProcess = @() | ||
|
|
||
| # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess | ||
| NestedModules = @('Microsoft.DotNet.Interactive.PowerShell.dll') | ||
|
|
||
| # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. | ||
| FunctionsToExport = @() | ||
|
|
||
| # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. | ||
| CmdletsToExport = @('Trace-PipelineObject') | ||
|
|
||
| # Variables to export from this module | ||
| VariablesToExport = '*' | ||
|
|
||
| # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. | ||
| AliasesToExport = @() | ||
|
|
||
| # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. | ||
| PrivateData = @{ | ||
|
|
||
| PSData = @{ | ||
|
|
||
| # Tags applied to this module. These help with module discovery in online galleries. | ||
| Tags = @('Microsoft', '.NET', 'Jupyter', 'dotnet') | ||
|
|
||
| # A URL to the license for this module. | ||
| LicenseUri = 'https://github.com/dotnet/interactive/blob/master/License.txt' | ||
|
|
||
| # A URL to the main website for this project. | ||
| ProjectUri = 'https://github.com/dotnet/interactive' | ||
|
|
||
| # A URL to an icon representing this module. | ||
| # IconUri = '' | ||
|
|
||
| # ReleaseNotes of this module | ||
| ReleaseNotes = '# v0.1.0 | ||
|
|
||
| Initial release. | ||
| ' | ||
|
|
||
| # Prerelease string of this module | ||
| # Prerelease = '' | ||
| } # End of PSData hashtable | ||
|
|
||
| } # End of PrivateData hashtable | ||
|
|
||
| # HelpInfo URI of this module | ||
| # HelpInfoURI = '' | ||
|
|
||
| # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. | ||
| # DefaultCommandPrefix = '' | ||
|
|
||
| } |
81 changes: 81 additions & 0 deletions
81
Microsoft.DotNet.Interactive.PowerShell/PowerShellExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System.Collections; | ||
| using System.Collections.ObjectModel; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.DotNet.Interactive.PowerShell | ||
| { | ||
| using System.Management.Automation; | ||
|
jonsequitur marked this conversation as resolved.
Resolved
|
||
|
|
||
| internal static class PowerShellExtensions | ||
| { | ||
| public static void InvokeAndClearCommands(this PowerShell pwsh) | ||
| { | ||
| try | ||
| { | ||
| pwsh.Invoke(); | ||
| } | ||
| finally | ||
| { | ||
| pwsh.Streams.ClearStreams(); | ||
| pwsh.Commands.Clear(); | ||
| } | ||
| } | ||
|
|
||
| public static async Task InvokeAndClearCommandsAsync(this PowerShell pwsh) | ||
| { | ||
| try | ||
| { | ||
| await pwsh.InvokeAsync().ConfigureAwait(false); | ||
| } | ||
| finally | ||
| { | ||
| pwsh.Streams.ClearStreams(); | ||
| pwsh.Commands.Clear(); | ||
| } | ||
| } | ||
|
|
||
| public static void InvokeAndClearCommands(this PowerShell pwsh, IEnumerable input) | ||
| { | ||
| try | ||
| { | ||
| pwsh.Invoke(input); | ||
| } | ||
| finally | ||
| { | ||
| pwsh.Streams.ClearStreams(); | ||
| pwsh.Commands.Clear(); | ||
| } | ||
| } | ||
|
|
||
| public static Collection<T> InvokeAndClearCommands<T>(this PowerShell pwsh) | ||
| { | ||
| try | ||
| { | ||
| var result = pwsh.Invoke<T>(); | ||
| return result; | ||
| } | ||
| finally | ||
| { | ||
| pwsh.Streams.ClearStreams(); | ||
| pwsh.Commands.Clear(); | ||
| } | ||
| } | ||
|
|
||
| public static Collection<T> InvokeAndClearCommands<T>(this PowerShell pwsh, IEnumerable input) | ||
| { | ||
| try | ||
| { | ||
| var result = pwsh.Invoke<T>(input); | ||
| return result; | ||
| } | ||
| finally | ||
| { | ||
| pwsh.Streams.ClearStreams(); | ||
| pwsh.Commands.Clear(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.