@@ -18,12 +18,9 @@ internal static class RunspaceExtensions
18
18
static RunspaceExtensions ( )
19
19
{
20
20
// PowerShell ApartmentState APIs aren't available in PSStandard, so we need to use reflection.
21
- if ( ! VersionUtils . IsNetCore || VersionUtils . IsPS7OrGreater )
22
- {
23
- MethodInfo setterInfo = typeof ( Runspace ) . GetProperty ( "ApartmentState" ) . GetSetMethod ( ) ;
24
- Delegate setter = Delegate . CreateDelegate ( typeof ( Action < Runspace , ApartmentState > ) , firstArgument : null , method : setterInfo ) ;
25
- s_runspaceApartmentStateSetter = ( Action < Runspace , ApartmentState > ) setter ;
26
- }
21
+ MethodInfo setterInfo = typeof ( Runspace ) . GetProperty ( "ApartmentState" ) . GetSetMethod ( ) ;
22
+ Delegate setter = Delegate . CreateDelegate ( typeof ( Action < Runspace , ApartmentState > ) , firstArgument : null , method : setterInfo ) ;
23
+ s_runspaceApartmentStateSetter = ( Action < Runspace , ApartmentState > ) setter ;
27
24
28
25
MethodInfo getRemotePromptMethod = typeof ( HostUtilities ) . GetMethod ( "GetRemotePrompt" , BindingFlags . NonPublic | BindingFlags . Static ) ;
29
26
ParameterExpression runspaceParam = Expression . Parameter ( typeof ( Runspace ) ) ;
@@ -45,6 +42,13 @@ public static void SetApartmentStateToSta(this Runspace runspace)
45
42
s_runspaceApartmentStateSetter ? . Invoke ( runspace , ApartmentState . STA ) ;
46
43
}
47
44
45
+ /// <summary>
46
+ /// Augment a given prompt string with a remote decoration.
47
+ /// This is an internal method on <c>Runspace</c> in PowerShell that we reuse via reflection.
48
+ /// </summary>
49
+ /// <param name="runspace">The runspace the prompt is for.</param>
50
+ /// <param name="basePrompt">The base prompt to decorate.</param>
51
+ /// <returns>A prompt string decorated with remote connection details.</returns>
48
52
public static string GetRemotePrompt ( this Runspace runspace , string basePrompt )
49
53
{
50
54
return s_getRemotePromptFunc ( runspace , basePrompt ) ;
0 commit comments