Skip to content

Commit ae5e861

Browse files
committed
Fix #46: Clear-Host causes error while debugging
This change updates the SessionPSHostRawUserInterface class to get rid of most instances of throwing NotImplementedException. When debugging, if a script invokes a method that causes the raw UI interface to be touched, those methods shouldn't cause errors to appear. This change reduces the possibility of the user seeing errors due to this reason.
1 parent dfc0f22 commit ae5e861

File tree

1 file changed

+32
-39
lines changed

1 file changed

+32
-39
lines changed

src/PowerShellEditorServices/Session/SessionPSHostRawUserInterface.cs

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
//
55

6+
using Microsoft.PowerShell.EditorServices.Utility;
67
using System;
78
using System.Management.Automation.Host;
89

@@ -80,59 +81,35 @@ public override Size BufferSize
8081
/// </summary>
8182
public override Coordinates CursorPosition
8283
{
83-
get
84-
{
85-
throw new System.NotImplementedException();
86-
}
87-
set
88-
{
89-
throw new System.NotImplementedException();
90-
}
84+
get;
85+
set;
9186
}
9287

9388
/// <summary>
9489
/// Gets or sets the size of the cursor in the console buffer.
9590
/// </summary>
9691
public override int CursorSize
9792
{
98-
get
99-
{
100-
throw new System.NotImplementedException();
101-
}
102-
set
103-
{
104-
throw new System.NotImplementedException();
105-
}
93+
get;
94+
set;
10695
}
10796

10897
/// <summary>
10998
/// Gets or sets the position of the console's window.
11099
/// </summary>
111100
public override Coordinates WindowPosition
112101
{
113-
get
114-
{
115-
throw new System.NotImplementedException();
116-
}
117-
set
118-
{
119-
throw new System.NotImplementedException();
120-
}
102+
get;
103+
set;
121104
}
122105

123106
/// <summary>
124107
/// Gets or sets the size of the console's window.
125108
/// </summary>
126109
public override Size WindowSize
127110
{
128-
get
129-
{
130-
throw new System.NotImplementedException();
131-
}
132-
set
133-
{
134-
throw new System.NotImplementedException();
135-
}
111+
get;
112+
set;
136113
}
137114

138115
/// <summary>
@@ -149,23 +126,23 @@ public override string WindowTitle
149126
/// </summary>
150127
public override bool KeyAvailable
151128
{
152-
get { throw new System.NotImplementedException(); }
129+
get { return false; }
153130
}
154131

155132
/// <summary>
156133
/// Gets the maximum physical size of the console window.
157134
/// </summary>
158135
public override Size MaxPhysicalWindowSize
159136
{
160-
get { throw new System.NotImplementedException(); }
137+
get { return new Size(80, 20); }
161138
}
162139

163140
/// <summary>
164141
/// Gets the maximum size of the console window.
165142
/// </summary>
166143
public override Size MaxWindowSize
167144
{
168-
get { throw new System.NotImplementedException(); }
145+
get { return new Size(80, 20); }
169146
}
170147

171148
/// <summary>
@@ -175,6 +152,10 @@ public override Size MaxWindowSize
175152
/// <returns>A KeyInfo struct with details about the current keypress.</returns>
176153
public override KeyInfo ReadKey(ReadKeyOptions options)
177154
{
155+
Logger.Write(
156+
LogLevel.Warning,
157+
"PSHostRawUserInterface.ReadKey was called");
158+
178159
throw new System.NotImplementedException();
179160
}
180161

@@ -183,7 +164,9 @@ public override KeyInfo ReadKey(ReadKeyOptions options)
183164
/// </summary>
184165
public override void FlushInputBuffer()
185166
{
186-
throw new System.NotImplementedException();
167+
Logger.Write(
168+
LogLevel.Warning,
169+
"PSHostRawUserInterface.FlushInputBuffer was called");
187170
}
188171

189172
/// <summary>
@@ -193,6 +176,10 @@ public override void FlushInputBuffer()
193176
/// <returns>A BufferCell array with the requested buffer contents.</returns>
194177
public override BufferCell[,] GetBufferContents(Rectangle rectangle)
195178
{
179+
Logger.Write(
180+
LogLevel.Warning,
181+
"PSHostRawUserInterface.GetBufferContents was called");
182+
196183
throw new System.NotImplementedException();
197184
}
198185

@@ -209,7 +196,9 @@ public override void ScrollBufferContents(
209196
Rectangle clip,
210197
BufferCell fill)
211198
{
212-
throw new System.NotImplementedException();
199+
Logger.Write(
200+
LogLevel.Warning,
201+
"PSHostRawUserInterface.ScrollBufferContents was called");
213202
}
214203

215204
/// <summary>
@@ -221,7 +210,9 @@ public override void SetBufferContents(
221210
Rectangle rectangle,
222211
BufferCell fill)
223212
{
224-
throw new System.NotImplementedException();
213+
Logger.Write(
214+
LogLevel.Warning,
215+
"PSHostRawUserInterface.SetBufferContents was called");
225216
}
226217

227218
/// <summary>
@@ -233,7 +224,9 @@ public override void SetBufferContents(
233224
Coordinates origin,
234225
BufferCell[,] contents)
235226
{
236-
throw new System.NotImplementedException();
227+
Logger.Write(
228+
LogLevel.Warning,
229+
"PSHostRawUserInterface.SetBufferContents was called");
237230
}
238231

239232
#endregion

0 commit comments

Comments
 (0)