3
3
--********************************************************************/
4
4
5
5
using System ;
6
+ using System . Diagnostics . CodeAnalysis ;
7
+ using System . Globalization ;
6
8
using System . Linq ;
7
9
using System . Management . Automation ;
8
10
using System . Management . Automation . Language ;
11
+ using System . Management . Automation . Runspaces ;
9
12
10
13
namespace Microsoft . PowerShell
11
14
{
@@ -14,6 +17,7 @@ public partial class PSConsoleReadLine
14
17
/// <summary>
15
18
/// Insert the key
16
19
/// </summary>
20
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
17
21
public static void SelfInsert ( ConsoleKeyInfo ? key = null , object arg = null )
18
22
{
19
23
if ( ! key . HasValue )
@@ -59,6 +63,7 @@ public static void SelfInsert(ConsoleKeyInfo? key = null, object arg = null)
59
63
/// <summary>
60
64
/// Reverts all of the input to the current input.
61
65
/// </summary>
66
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
62
67
public static void RevertLine ( ConsoleKeyInfo ? key = null , object arg = null )
63
68
{
64
69
if ( _singleton . _statusIsErrorMessage )
@@ -79,6 +84,7 @@ public static void RevertLine(ConsoleKeyInfo? key = null, object arg = null)
79
84
/// Cancel the current input, leaving the input on the screen,
80
85
/// but returns back to the host so the prompt is evaluated again.
81
86
/// </summary>
87
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
82
88
public static void CancelLine ( ConsoleKeyInfo ? key = null , object arg = null )
83
89
{
84
90
_singleton . ClearStatusMessage ( false ) ;
@@ -113,6 +119,7 @@ public static void CancelLine(ConsoleKeyInfo? key = null, object arg = null)
113
119
/// Like ForwardKillLine - deletes text from the point to the end of the line,
114
120
/// but does not put the deleted text in the kill ring.
115
121
/// </summary>
122
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
116
123
public static void ForwardDeleteLine ( ConsoleKeyInfo ? key = null , object arg = null )
117
124
{
118
125
var current = _singleton . _current ;
@@ -131,6 +138,7 @@ public static void ForwardDeleteLine(ConsoleKeyInfo? key = null, object arg = nu
131
138
/// Like BackwardKillLine - deletes text from the point to the start of the line,
132
139
/// but does not put the deleted text in the kill ring.
133
140
/// </summary>
141
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
134
142
public static void BackwardDeleteLine ( ConsoleKeyInfo ? key = null , object arg = null )
135
143
{
136
144
if ( _singleton . _current > 0 )
@@ -146,6 +154,7 @@ public static void BackwardDeleteLine(ConsoleKeyInfo? key = null, object arg = n
146
154
/// <summary>
147
155
/// Delete the character before the cursor.
148
156
/// </summary>
157
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
149
158
public static void BackwardDeleteChar ( ConsoleKeyInfo ? key = null , object arg = null )
150
159
{
151
160
if ( _singleton . _visualSelectionCommandCount > 0 )
@@ -195,6 +204,7 @@ private void DeleteCharImpl(bool orExit)
195
204
/// <summary>
196
205
/// Delete the character under the cursor.
197
206
/// </summary>
207
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
198
208
public static void DeleteChar ( ConsoleKeyInfo ? key = null , object arg = null )
199
209
{
200
210
_singleton . DeleteCharImpl ( orExit : false ) ;
@@ -203,6 +213,7 @@ public static void DeleteChar(ConsoleKeyInfo? key = null, object arg = null)
203
213
/// <summary>
204
214
/// Delete the character under the cursor, or if the line is empty, exit the process
205
215
/// </summary>
216
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
206
217
public static void DeleteCharOrExit ( ConsoleKeyInfo ? key = null , object arg = null )
207
218
{
208
219
_singleton . DeleteCharImpl ( orExit : true ) ;
@@ -284,7 +295,7 @@ public override AstVisitAction VisitCommand(CommandAst commandAst)
284
295
if ( commandInfo == null && ! _singleton . UnresolvedCommandCouldSucceed ( commandName , _rootAst ) )
285
296
{
286
297
_singleton . _current = commandAst . CommandElements [ 0 ] . Extent . EndOffset ;
287
- detectedError = string . Format ( PSReadLineResources . CommandNotFoundError , commandName ) ;
298
+ detectedError = string . Format ( CultureInfo . CurrentCulture , PSReadLineResources . CommandNotFoundError , commandName ) ;
288
299
return AstVisitAction . StopVisit ;
289
300
}
290
301
}
@@ -419,6 +430,7 @@ static bool StaticParameterBindingSupported(CommandInfo commandInfo)
419
430
/// continuation prompt is displayed on the next line and PSReadline waits for
420
431
/// keys to edit the current input.
421
432
/// </summary>
433
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
422
434
public static void AcceptLine ( ConsoleKeyInfo ? key = null , object arg = null )
423
435
{
424
436
_singleton . AcceptLineImpl ( false ) ;
@@ -430,6 +442,7 @@ public static void AcceptLine(ConsoleKeyInfo? key = null, object arg = null)
430
442
/// continuation prompt is displayed on the next line and PSReadline waits for
431
443
/// keys to edit the current input.
432
444
/// </summary>
445
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
433
446
public static void ValidateAndAcceptLine ( ConsoleKeyInfo ? key = null , object arg = null )
434
447
{
435
448
_singleton . AcceptLineImpl ( true ) ;
@@ -439,6 +452,7 @@ public static void ValidateAndAcceptLine(ConsoleKeyInfo? key = null, object arg
439
452
/// Attempt to execute the current input. If it can be executed (like AcceptLine),
440
453
/// then recall the next item from history the next time Readline is called.
441
454
/// </summary>
455
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
442
456
public static void AcceptAndGetNext ( ConsoleKeyInfo ? key = null , object arg = null )
443
457
{
444
458
if ( _singleton . AcceptLineImpl ( false ) )
@@ -459,6 +473,7 @@ public static void AcceptAndGetNext(ConsoleKeyInfo? key = null, object arg = nul
459
473
/// keys to edit the current input. This is useful to enter multi-line input as
460
474
/// a single command even when a single line is complete input by itself.
461
475
/// </summary>
476
+ [ SuppressMessage ( "Microsoft.Design" , "CA1026:DefaultParametersShouldNotBeUsed" ) ]
462
477
public static void AddLine ( ConsoleKeyInfo ? key = null , object arg = null )
463
478
{
464
479
Insert ( '\n ' ) ;
0 commit comments