33
44using System ;
55using System . Collections . Generic ;
6+ using System . Collections . ObjectModel ;
67using System . IO ;
8+ using System . Management . Automation ;
9+ using System . Management . Automation . Host ;
710using System . Management . Automation . Runspaces ;
11+ using System . Security ;
812using System . Threading ;
913using System . Threading . Tasks ;
1014using Microsoft . Extensions . Logging ;
1115using Microsoft . Extensions . Logging . Abstractions ;
1216using Microsoft . PowerShell . EditorServices . Hosting ;
13- using Microsoft . PowerShell . EditorServices . Services ;
17+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
1418using Microsoft . PowerShell . EditorServices . Test . Shared ;
1519using Microsoft . PowerShell . EditorServices . Utility ;
1620
1721namespace Microsoft . PowerShell . EditorServices . Test
1822{
19- /*
20- internal static class PowerShellContextFactory
23+ internal static class PsesHostFactory
2124 {
2225 // NOTE: These paths are arbitrarily chosen just to verify that the profile paths
2326 // can be set to whatever they need to be for the given host.
@@ -38,10 +41,8 @@ internal static class PowerShellContextFactory
3841
3942 public static System . Management . Automation . Runspaces . Runspace InitialRunspace ;
4043
41- public static PowerShellContextService Create(ILogger logger )
44+ public static PsesInternalHost Create ( ILoggerFactory loggerFactory )
4245 {
43- PowerShellContextService powerShellContext = new PowerShellContextService(logger, null, isPSReadLineEnabled: false);
44-
4546 // We intentionally use `CreateDefault2()` as it loads `Microsoft.PowerShell.Core` only,
4647 // which is a more minimal and therefore safer state.
4748 var initialSessionState = InitialSessionState . CreateDefault2 ( ) ;
@@ -60,67 +61,23 @@ public static PowerShellContextService Create(ILogger logger)
6061 "PowerShell Editor Services Test Host" ,
6162 "Test.PowerShellEditorServices" ,
6263 new Version ( "1.0.0" ) ,
63- null,
64+ psHost : null ,
6465 TestProfilePaths ,
65- new List <string>(),
66- new List <string>(),
66+ featureFlags : Array . Empty < string > ( ) ,
67+ additionalModules : Array . Empty < string > ( ) ,
6768 initialSessionState ,
68- null,
69- 0 ,
69+ logPath : null ,
70+ ( int ) LogLevel . None ,
7071 consoleReplEnabled : false ,
7172 usesLegacyReadLine : false ,
7273 bundledModulePath : BundledModulePath ) ;
7374
74- InitialRunspace = PowerShellContextService.CreateTestRunspace(
75- testHostDetails,
76- powerShellContext,
77- new TestPSHostUserInterface(powerShellContext, logger),
78- logger);
75+ var psesHost = new PsesInternalHost ( loggerFactory , null , testHostDetails ) ;
7976
80- powerShellContext.Initialize(
81- TestProfilePaths,
82- InitialRunspace,
83- ownsInitialRunspace: true,
84- consoleHost: null);
77+ psesHost . StartAsync ( new HostStartOptions { LoadProfiles = true } , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
8578
86- return powerShellContext ;
79+ return psesHost ;
8780 }
8881 }
89-
90- internal class TestPSHostUserInterface : EditorServicesPSHostUserInterface
91- {
92- public TestPSHostUserInterface(
93- PowerShellContextService powerShellContext,
94- ILogger logger)
95- : base(
96- powerShellContext,
97- new SimplePSHostRawUserInterface(logger),
98- NullLogger.Instance)
99- {
100- }
101-
102- public override void WriteOutput(string outputString, bool includeNewLine, OutputType outputType, ConsoleColor foregroundColor, ConsoleColor backgroundColor)
103- {
104- }
105-
106- protected override ChoicePromptHandler OnCreateChoicePromptHandler()
107- {
108- throw new NotImplementedException();
109- }
110-
111- protected override InputPromptHandler OnCreateInputPromptHandler()
112- {
113- throw new NotImplementedException();
114- }
115-
116- protected override Task<string> ReadCommandLineAsync(CancellationToken cancellationToken)
117- {
118- return Task.FromResult("USER COMMAND");
119- }
120-
121- protected override void UpdateProgress(long sourceId, ProgressDetails progressDetails)
122- {
123- }
124- }
125- */
12682}
83+
0 commit comments