Skip to content

Commit a02554d

Browse files
committed
Use expression body property/method
1 parent 4aba251 commit a02554d

8 files changed

Lines changed: 104 additions & 152 deletions

File tree

PSReadLine/Cmdlets.cs

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@ public PSConsoleReadlineOptions(string hostName)
233233
public BellStyle BellStyle { get; set; }
234234

235235
public bool HistorySearchCaseSensitive { get; set; }
236-
internal StringComparison HistoryStringComparison
237-
{
238-
get { return HistorySearchCaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; }
239-
}
236+
internal StringComparison HistoryStringComparison => HistorySearchCaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
240237

241238
#region vi
242239
public ViModeStyle ViModeIndicator { get; set; }
@@ -359,8 +356,8 @@ public class SetPSReadlineOption : PSCmdlet
359356
[Parameter(ParameterSetName = "OptionsSet")]
360357
public EditMode EditMode
361358
{
362-
get { return _editMode.GetValueOrDefault(); }
363-
set { _editMode = value; }
359+
get => _editMode.GetValueOrDefault();
360+
set => _editMode = value;
364361
}
365362
internal EditMode? _editMode;
366363

@@ -371,64 +368,64 @@ public EditMode EditMode
371368
[Parameter(ParameterSetName = "OptionsSet")]
372369
public ConsoleColor ContinuationPromptForegroundColor
373370
{
374-
get { return _continuationPromptForegroundColor.GetValueOrDefault(); }
375-
set { _continuationPromptForegroundColor = value; }
371+
get => _continuationPromptForegroundColor.GetValueOrDefault();
372+
set => _continuationPromptForegroundColor = value;
376373
}
377374
internal ConsoleColor? _continuationPromptForegroundColor;
378375

379376
[Parameter(ParameterSetName = "OptionsSet")]
380377
public ConsoleColor ContinuationPromptBackgroundColor
381378
{
382-
get { return _continuationPromptBackgroundColor.GetValueOrDefault(); }
383-
set { _continuationPromptBackgroundColor = value; }
379+
get => _continuationPromptBackgroundColor.GetValueOrDefault();
380+
set => _continuationPromptBackgroundColor = value;
384381
}
385382
internal ConsoleColor? _continuationPromptBackgroundColor;
386383

387384
[Parameter(ParameterSetName = "OptionsSet")]
388385
public ConsoleColor EmphasisForegroundColor
389386
{
390-
get { return _emphasisForegroundColor.GetValueOrDefault(); }
391-
set { _emphasisForegroundColor = value; }
387+
get => _emphasisForegroundColor.GetValueOrDefault();
388+
set => _emphasisForegroundColor = value;
392389
}
393390
internal ConsoleColor? _emphasisForegroundColor;
394391

395392
[Parameter(ParameterSetName = "OptionsSet")]
396393
public ConsoleColor EmphasisBackgroundColor
397394
{
398-
get { return _emphasisBackgroundColor.GetValueOrDefault(); }
399-
set { _emphasisBackgroundColor = value; }
395+
get => _emphasisBackgroundColor.GetValueOrDefault();
396+
set => _emphasisBackgroundColor = value;
400397
}
401398
internal ConsoleColor? _emphasisBackgroundColor;
402399

403400
[Parameter(ParameterSetName = "OptionsSet")]
404401
public ConsoleColor ErrorForegroundColor
405402
{
406-
get { return _errorForegroundColor.GetValueOrDefault(); }
407-
set { _errorForegroundColor = value; }
403+
get => _errorForegroundColor.GetValueOrDefault();
404+
set => _errorForegroundColor = value;
408405
}
409406
internal ConsoleColor? _errorForegroundColor;
410407

411408
[Parameter(ParameterSetName = "OptionsSet")]
412409
public ConsoleColor ErrorBackgroundColor
413410
{
414-
get { return _errorBackgroundColor.GetValueOrDefault(); }
415-
set { _errorBackgroundColor = value; }
411+
get => _errorBackgroundColor.GetValueOrDefault();
412+
set => _errorBackgroundColor = value;
416413
}
417414
internal ConsoleColor? _errorBackgroundColor;
418415

419416
[Parameter(ParameterSetName = "OptionsSet")]
420417
public SwitchParameter HistoryNoDuplicates
421418
{
422-
get { return _historyNoDuplicates.GetValueOrDefault(); }
423-
set { _historyNoDuplicates = value; }
419+
get => _historyNoDuplicates.GetValueOrDefault();
420+
set => _historyNoDuplicates = value;
424421
}
425422
internal SwitchParameter? _historyNoDuplicates;
426423

427424
[Parameter(ParameterSetName = "OptionsSet")]
428425
[AllowNull]
429426
public Func<string, bool> AddToHistoryHandler
430427
{
431-
get { return _addToHistoryHandler; }
428+
get => _addToHistoryHandler;
432429
set
433430
{
434431
_addToHistoryHandler = value;
@@ -442,7 +439,7 @@ public Func<string, bool> AddToHistoryHandler
442439
[AllowNull]
443440
public Action<CommandAst> CommandValidationHandler
444441
{
445-
get { return _commandValidationHandler; }
442+
get => _commandValidationHandler;
446443
set
447444
{
448445
_commandValidationHandler = value;
@@ -455,81 +452,81 @@ public Action<CommandAst> CommandValidationHandler
455452
[Parameter(ParameterSetName = "OptionsSet")]
456453
public SwitchParameter HistorySearchCursorMovesToEnd
457454
{
458-
get { return _historySearchCursorMovesToEnd.GetValueOrDefault(); }
459-
set { _historySearchCursorMovesToEnd = value; }
455+
get => _historySearchCursorMovesToEnd.GetValueOrDefault();
456+
set => _historySearchCursorMovesToEnd = value;
460457
}
461458
internal SwitchParameter? _historySearchCursorMovesToEnd;
462459

463460
[Parameter(ParameterSetName = "OptionsSet")]
464461
[ValidateRange(1, int.MaxValue)]
465462
public int MaximumHistoryCount
466463
{
467-
get { return _maximumHistoryCount.GetValueOrDefault(); }
468-
set { _maximumHistoryCount = value; }
464+
get => _maximumHistoryCount.GetValueOrDefault();
465+
set => _maximumHistoryCount = value;
469466
}
470467
internal int? _maximumHistoryCount;
471468

472469
[Parameter(ParameterSetName = "OptionsSet")]
473470
public int MaximumKillRingCount
474471
{
475-
get { return _maximumKillRingCount.GetValueOrDefault(); }
476-
set { _maximumKillRingCount = value; }
472+
get => _maximumKillRingCount.GetValueOrDefault();
473+
set => _maximumKillRingCount = value;
477474
}
478475
internal int? _maximumKillRingCount;
479476

480477
[Parameter(ParameterSetName = "OptionsSet")]
481478
public SwitchParameter ResetTokenColors
482479
{
483-
get { return _resetTokenColors.GetValueOrDefault(); }
484-
set { _resetTokenColors = value; }
480+
get => _resetTokenColors.GetValueOrDefault();
481+
set => _resetTokenColors = value;
485482
}
486483
internal SwitchParameter? _resetTokenColors;
487484

488485
[Parameter(ParameterSetName = "OptionsSet")]
489486
public SwitchParameter ShowToolTips
490487
{
491-
get { return _showToolTips.GetValueOrDefault(); }
492-
set { _showToolTips = value; }
488+
get => _showToolTips.GetValueOrDefault();
489+
set => _showToolTips = value;
493490
}
494491
internal SwitchParameter? _showToolTips;
495492

496493
[Parameter(ParameterSetName = "OptionsSet")]
497494
public int ExtraPromptLineCount
498495
{
499-
get { return _extraPromptLineCount.GetValueOrDefault(); }
500-
set { _extraPromptLineCount = value; }
496+
get => _extraPromptLineCount.GetValueOrDefault();
497+
set => _extraPromptLineCount = value;
501498
}
502499
internal int? _extraPromptLineCount;
503500

504501
[Parameter(ParameterSetName = "OptionsSet")]
505502
public int DingTone
506503
{
507-
get { return _dingTone.GetValueOrDefault(); }
508-
set { _dingTone = value; }
504+
get => _dingTone.GetValueOrDefault();
505+
set => _dingTone = value;
509506
}
510507
internal int? _dingTone;
511508

512509
[Parameter(ParameterSetName = "OptionsSet")]
513510
public int DingDuration
514511
{
515-
get { return _dingDuration.GetValueOrDefault(); }
516-
set { _dingDuration = value; }
512+
get => _dingDuration.GetValueOrDefault();
513+
set => _dingDuration = value;
517514
}
518515
internal int? _dingDuration;
519516

520517
[Parameter(ParameterSetName = "OptionsSet")]
521518
public BellStyle BellStyle
522519
{
523-
get { return _bellStyle.GetValueOrDefault(); }
524-
set { _bellStyle = value; }
520+
get => _bellStyle.GetValueOrDefault();
521+
set => _bellStyle = value;
525522
}
526523
internal BellStyle? _bellStyle;
527524

528525
[Parameter(ParameterSetName = "OptionsSet")]
529526
public int CompletionQueryItems
530527
{
531-
get { return _completionQueryItems.GetValueOrDefault(); }
532-
set { _completionQueryItems = value; }
528+
get => _completionQueryItems.GetValueOrDefault();
529+
set => _completionQueryItems = value;
533530
}
534531
internal int? _completionQueryItems;
535532

@@ -539,16 +536,16 @@ public int CompletionQueryItems
539536
[Parameter(ParameterSetName = "OptionsSet")]
540537
public SwitchParameter HistorySearchCaseSensitive
541538
{
542-
get { return _historySearchCaseSensitive.GetValueOrDefault(); }
543-
set { _historySearchCaseSensitive = value; }
539+
get => _historySearchCaseSensitive.GetValueOrDefault();
540+
set => _historySearchCaseSensitive = value;
544541
}
545542
internal SwitchParameter? _historySearchCaseSensitive;
546543

547544
[Parameter(ParameterSetName = "OptionsSet")]
548545
public HistorySaveStyle HistorySaveStyle
549546
{
550-
get { return _historySaveStyle.GetValueOrDefault(); }
551-
set { _historySaveStyle = value; }
547+
get => _historySaveStyle.GetValueOrDefault();
548+
set => _historySaveStyle = value;
552549
}
553550
internal HistorySaveStyle? _historySaveStyle;
554551

@@ -560,33 +557,33 @@ public HistorySaveStyle HistorySaveStyle
560557
[Parameter(ParameterSetName = "OptionsSet")]
561558
public ViModeStyle ViModeIndicator
562559
{
563-
get { return _viModeIndicator.GetValueOrDefault(); }
564-
set { _viModeIndicator = value; }
560+
get => _viModeIndicator.GetValueOrDefault();
561+
set => _viModeIndicator = value;
565562
}
566563
internal ViModeStyle? _viModeIndicator;
567564
#endregion vi
568565

569566
[Parameter(ParameterSetName = "ColorSet", Position = 0, Mandatory = true)]
570567
public TokenClassification TokenKind
571568
{
572-
get { return _tokenKind.GetValueOrDefault(); }
573-
set { _tokenKind = value; }
569+
get => _tokenKind.GetValueOrDefault();
570+
set => _tokenKind = value;
574571
}
575572
internal TokenClassification? _tokenKind;
576573

577574
[Parameter(ParameterSetName = "ColorSet", Position = 1)]
578575
public ConsoleColor ForegroundColor
579576
{
580-
get { return _foregroundColor.GetValueOrDefault(); }
581-
set { _foregroundColor = value; }
577+
get => _foregroundColor.GetValueOrDefault();
578+
set => _foregroundColor = value;
582579
}
583580
internal ConsoleColor? _foregroundColor;
584581

585582
[Parameter(ParameterSetName = "ColorSet", Position = 2)]
586583
public ConsoleColor BackgroundColor
587584
{
588-
get { return _backgroundColor.GetValueOrDefault(); }
589-
set { _backgroundColor = value; }
585+
get => _backgroundColor.GetValueOrDefault();
586+
set => _backgroundColor = value;
590587
}
591588
internal ConsoleColor? _backgroundColor;
592589

@@ -716,16 +713,16 @@ public class GetKeyHandlerCommand : PSCmdlet
716713
[Parameter]
717714
public SwitchParameter Bound
718715
{
719-
get { return _bound.GetValueOrDefault(); }
720-
set { _bound = value; }
716+
get => _bound.GetValueOrDefault();
717+
set => _bound = value;
721718
}
722719
private SwitchParameter? _bound;
723720

724721
[Parameter]
725722
public SwitchParameter Unbound
726723
{
727-
get { return _unbound.GetValueOrDefault(); }
728-
set { _unbound = value; }
724+
get => _unbound.GetValueOrDefault();
725+
set => _unbound = value;
729726
}
730727
private SwitchParameter? _unbound;
731728

PSReadLine/ConsoleBufferBuilder.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ public CHAR_INFO[] ToArray()
4949
return buffer.ToArray();
5050
}
5151

52-
public int Length
53-
{
54-
get { return buffer.Count; }
55-
}
52+
public int Length => buffer.Count;
5653
}
5754
}
5855

0 commit comments

Comments
 (0)