Skip to content

Commit a430513

Browse files
committed
Clean up NullPSHost classes
1 parent d1c4eba commit a430513

File tree

2 files changed

+41
-63
lines changed

2 files changed

+41
-63
lines changed

src/PowerShellEditorServices/Services/PowerShell/Host/NullPSHostRawUI.cs

+18-24
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,38 @@ internal class NullPSHostRawUI : PSHostRawUserInterface
1212

1313
public NullPSHostRawUI() => _buffer = new BufferCell[0, 0];
1414

15-
public override ConsoleColor BackgroundColor { get; set; }
16-
public override Size BufferSize { get; set; }
17-
public override Coordinates CursorPosition { get; set; }
18-
public override int CursorSize { get; set; }
19-
public override ConsoleColor ForegroundColor { get; set; }
15+
public override Coordinates WindowPosition { get; set; }
2016

21-
public override bool KeyAvailable => false;
17+
public override Size MaxWindowSize => new() { Width = _buffer.GetLength(0), Height = _buffer.GetLength(1) };
2218

2319
public override Size MaxPhysicalWindowSize => MaxWindowSize;
2420

25-
public override Size MaxWindowSize => new() { Width = _buffer.GetLength(0), Height = _buffer.GetLength(1) };
21+
public override bool KeyAvailable => false;
22+
23+
public override ConsoleColor ForegroundColor { get; set; }
24+
25+
public override int CursorSize { get; set; }
26+
27+
public override Coordinates CursorPosition { get; set; }
28+
29+
public override Size BufferSize { get; set; }
30+
31+
public override ConsoleColor BackgroundColor { get; set; }
2632

27-
public override Coordinates WindowPosition { get; set; }
2833
public override Size WindowSize { get; set; }
34+
2935
public override string WindowTitle { get; set; }
3036

31-
public override void FlushInputBuffer()
32-
{
33-
// Do nothing
34-
}
37+
public override void FlushInputBuffer() { }
3538

3639
public override BufferCell[,] GetBufferContents(Rectangle rectangle) => _buffer;
3740

3841
public override KeyInfo ReadKey(ReadKeyOptions options) => default;
3942

40-
public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill)
41-
{
42-
// Do nothing
43-
}
43+
public override void ScrollBufferContents(Rectangle source, Coordinates destination, Rectangle clip, BufferCell fill) { }
4444

45-
public override void SetBufferContents(Coordinates origin, BufferCell[,] contents)
46-
{
47-
// Do nothing
48-
}
45+
public override void SetBufferContents(Coordinates origin, BufferCell[,] contents) { }
4946

50-
public override void SetBufferContents(Rectangle rectangle, BufferCell fill)
51-
{
52-
// Do nothing
53-
}
47+
public override void SetBufferContents(Rectangle rectangle, BufferCell fill) { }
5448
}
5549
}

src/PowerShellEditorServices/Services/PowerShell/Host/NullPSHostUI.cs

+23-39
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ internal class NullPSHostUI : PSHostUserInterface
1414
{
1515
public NullPSHostUI() => RawUI = new NullPSHostRawUI();
1616

17+
public override bool SupportsVirtualTerminal => false;
18+
1719
public override PSHostRawUserInterface RawUI { get; }
1820

1921
public override Dictionary<string, PSObject> Prompt(string caption, string message, Collection<FieldDescription> descriptions) => new();
@@ -29,44 +31,26 @@ public override PSCredential PromptForCredential(string caption, string message,
2931

3032
public override SecureString ReadLineAsSecureString() => new();
3133

32-
public override void Write(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value)
33-
{
34-
// Do nothing
35-
}
36-
37-
public override void Write(string value)
38-
{
39-
// Do nothing
40-
}
41-
42-
public override void WriteDebugLine(string message)
43-
{
44-
// Do nothing
45-
}
46-
47-
public override void WriteErrorLine(string value)
48-
{
49-
// Do nothing
50-
}
51-
52-
public override void WriteLine(string value)
53-
{
54-
// Do nothing
55-
}
56-
57-
public override void WriteProgress(long sourceId, ProgressRecord record)
58-
{
59-
// Do nothing
60-
}
61-
62-
public override void WriteVerboseLine(string message)
63-
{
64-
// Do nothing
65-
}
66-
67-
public override void WriteWarningLine(string message)
68-
{
69-
// Do nothing
70-
}
34+
public override void Write(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value) { }
35+
36+
public override void Write(string value) { }
37+
38+
public override void WriteDebugLine(string message) { }
39+
40+
public override void WriteErrorLine(string value) { }
41+
42+
public override void WriteInformation(InformationRecord record) { }
43+
44+
public override void WriteLine() { }
45+
46+
public override void WriteLine(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value) { }
47+
48+
public override void WriteLine(string value) { }
49+
50+
public override void WriteProgress(long sourceId, ProgressRecord record) { }
51+
52+
public override void WriteVerboseLine(string message) { }
53+
54+
public override void WriteWarningLine(string message) { }
7155
}
7256
}

0 commit comments

Comments
 (0)