Skip to content

Commit bae2e93

Browse files
committed
Finish public interface comments for core library
This change also makes XML comments mandatory on all public interfaces for Release builds of the core library project.
1 parent 64714c7 commit bae2e93

9 files changed

+202
-21
lines changed

src/PowerShellEditorServices/Console/ConsoleService.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ public class ConsoleService : IDisposable
3030

3131
#region Constructors
3232

33+
/// <summary>
34+
/// Creates an instance of the ConsoleService class using the
35+
/// given IConsoleHost implementation to invoke host operations
36+
/// on behalf of the ConsolePSHost. An InitialSessionState may
37+
/// be provided to create the console runspace using a particular
38+
/// configuraiton.
39+
/// </summary>
40+
/// <param name="consoleHost">
41+
/// An IConsoleHost implementation which handles host operations.
42+
/// </param>
43+
/// <param name="initialSessionState">
44+
/// An optional InitialSessionState to use in creating the console runspace.
45+
/// </param>
3346
public ConsoleService(
3447
IConsoleHost consoleHost,
3548
InitialSessionState initialSessionState = null)
@@ -56,6 +69,11 @@ public ConsoleService(
5669

5770
#region Public Methods
5871

72+
/// <summary>
73+
/// Executes a command in the console runspace.
74+
/// </summary>
75+
/// <param name="commandString">The command string to execute.</param>
76+
/// <returns>A Task that can be awaited for the command completion.</returns>
5977
public async Task ExecuteCommand(string commandString)
6078
{
6179
PowerShell powerShell = PowerShell.Create();
@@ -101,6 +119,15 @@ await Task.Factory.StartNew(
101119
}
102120
}
103121

122+
/// <summary>
123+
/// Sends a user's prompt choice response back to the specified prompt ID.
124+
/// </summary>
125+
/// <param name="promptId">
126+
/// The ID of the prompt to which the user is responding.
127+
/// </param>
128+
/// <param name="choiceResult">
129+
/// The index of the choice that the user selected.
130+
/// </param>
104131
public void ReceiveChoicePromptResult(
105132
int promptId,
106133
int choiceResult)
@@ -109,6 +136,10 @@ public void ReceiveChoicePromptResult(
109136
this.consoleHost.PromptForChoiceResult(promptId, choiceResult);
110137
}
111138

139+
/// <summary>
140+
/// Sends a CTRL+C signal to the console to halt execution of
141+
/// the current command.
142+
/// </summary>
112143
public void SendControlC()
113144
{
114145
// TODO: Cancel the current pipeline execution
@@ -118,6 +149,9 @@ public void SendControlC()
118149

119150
#region IDisposable Implementation
120151

152+
/// <summary>
153+
/// Disposes the runspace in use by the ConsoleService.
154+
/// </summary>
121155
public void Dispose()
122156
{
123157
if (this.currentRunspace != null)

src/PowerShellEditorServices/Console/IConsoleHost.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,39 @@ void WriteOutput(
4747
/// <summary>
4848
/// Prompts the user to make a choice using the provided details.
4949
/// </summary>
50-
/// <param name="caption">
50+
/// <param name="promptCaption">
5151
/// The caption string which will be displayed to the user.
5252
/// </param>
53-
/// <param name="message">
53+
/// <param name="promptMessage">
5454
/// The descriptive message which will be displayed to the user.
5555
/// </param>
56-
/// <param name="choices">
56+
/// <param name="choiceDescriptions">
5757
/// The list of choices from which the user will select.
5858
/// </param>
5959
/// <param name="defaultChoice">
6060
/// The default choice to highlight for the user.
6161
/// </param>
6262
/// <returns>
6363
/// A Task instance that can be monitored for completion to get
64-
/// the user's choice.</returns>
64+
/// the user's choice.
65+
/// </returns>
6566
Task<int> PromptForChoice(
6667
string promptCaption,
6768
string promptMessage,
6869
IEnumerable<ChoiceDescription> choiceDescriptions,
6970
int defaultChoice);
7071

71-
// TODO: Get rid of this!
72+
// TODO: Get rid of this method! Leaky abstraction.
73+
74+
/// <summary>
75+
/// Sends a user's prompt choice response back to the specified prompt ID.
76+
/// </summary>
77+
/// <param name="promptId">
78+
/// The ID of the prompt to which the user is responding.
79+
/// </param>
80+
/// <param name="choiceResult">
81+
/// The index of the choice that the user selected.
82+
/// </param>
7283
void PromptForChoiceResult(
7384
int promptId,
7485
int choiceResult);

src/PowerShellEditorServices/Console/SynchronizingConsoleHostWrapper.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public class SynchronizingConsoleHostWrapper : IConsoleHost
3131

3232
#region Constructors
3333

34+
/// <summary>
35+
/// Creates an instance of the SynchronizingConsoleHostWrapper
36+
/// class that wraps the given IConsoleHost implementation and
37+
/// invokes its calls through the given SynchronizationContext.
38+
/// </summary>
39+
/// <param name="wrappedConsoleHost">
40+
/// The IConsoleHost implementation that will be wrapped.
41+
/// </param>
42+
/// <param name="syncContext">
43+
/// The SynchronizationContext which will be used for invoking
44+
/// host operations calls on the proper thread.
45+
/// </param>
3446
public SynchronizingConsoleHostWrapper(
3547
IConsoleHost wrappedConsoleHost,
3648
SynchronizationContext syncContext)

src/PowerShellEditorServices/Language/AstOperations.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ namespace Microsoft.PowerShell.EditorServices.Language
1616
/// </summary>
1717
public static class AstOperations
1818
{
19+
/// <summary>
20+
/// Gets completions for the symbol found in the Ast at
21+
/// the given file offset.
22+
/// </summary>
23+
/// <param name="scriptAst">
24+
/// The Ast which will be traversed to find a completable symbol.
25+
/// </param>
26+
/// <param name="currentTokens">
27+
/// The array of tokens corresponding to the scriptAst parameter.
28+
/// </param>
29+
/// <param name="fileOffset">
30+
/// The 1-based file offset at which a symbol will be located.
31+
/// </param>
32+
/// <param name="runspace">
33+
/// The Runspace to use for gathering completions.
34+
/// </param>
35+
/// <returns>
36+
/// A CommandCompletion instance that contains completions for the
37+
/// symbol at the given offset.
38+
/// </returns>
1939
static public CommandCompletion GetCompletions(
2040
Ast scriptAst,
2141
Token[] currentTokens,

src/PowerShellEditorServices/Language/LanguageService.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,54 @@ namespace Microsoft.PowerShell.EditorServices.Language
1313
using System.Management.Automation;
1414
using System.Management.Automation.Runspaces;
1515

16+
/// <summary>
17+
/// Provides a high-level service for performing code completion and
18+
/// navigation operations on PowerShell scripts.
19+
/// </summary>
1620
public class LanguageService
1721
{
22+
#region Private Fields
23+
1824
private Runspace runspace;
1925

26+
#endregion
27+
28+
#region Constructors
29+
30+
/// <summary>
31+
/// Constructs an instance of the LanguageService class and uses
32+
/// the given Runspace to execute language service operations.
33+
/// </summary>
34+
/// <param name="languageServiceRunspace">
35+
/// The Runspace in which language service operations will be executed.
36+
/// </param>
2037
public LanguageService(Runspace languageServiceRunspace)
2138
{
2239
Validate.IsNotNull("languageServiceRunspace", languageServiceRunspace);
2340

2441
this.runspace = languageServiceRunspace;
2542
}
2643

44+
#endregion
45+
46+
#region Public Methods
47+
48+
/// <summary>
49+
/// Gets completions for a statement contained in the given
50+
/// script file at the specified line and column position.
51+
/// </summary>
52+
/// <param name="scriptFile">
53+
/// The script file in which completions will be gathered.
54+
/// </param>
55+
/// <param name="lineNumber">
56+
/// The 1-based line number at which completions will be gathered.
57+
/// </param>
58+
/// <param name="columnNumber">
59+
/// The 1-based column number at which completions will be gathered.
60+
/// </param>
61+
/// <returns>
62+
/// A CommandCompletion instance completions for the identified statement.
63+
/// </returns>
2764
public CommandCompletion GetCompletionsInFile(
2865
ScriptFile scriptFile,
2966
int lineNumber,
@@ -47,5 +84,7 @@ public CommandCompletion GetCompletionsInFile(
4784

4885
return completionSuggestions;
4986
}
87+
88+
#endregion
5089
}
5190
}

src/PowerShellEditorServices/Language/ScriptExtent.cs

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,101 @@
1212

1313
namespace Microsoft.PowerShell.EditorServices.Language
1414
{
15+
/// <summary>
16+
/// Provides a default IScriptExtent implementation
17+
/// containing details about a section of script content
18+
/// in a file.
19+
/// </summary>
1520
public class ScriptExtent : IScriptExtent
1621
{
17-
public int EndColumnNumber
22+
#region Properties
23+
24+
/// <summary>
25+
/// Gets the file path of the script file in which this extent is contained.
26+
/// </summary>
27+
public string File
28+
{
29+
get { throw new NotImplementedException(); }
30+
}
31+
32+
/// <summary>
33+
/// Gets or sets the starting column number of the extent.
34+
/// </summary>
35+
public int StartColumnNumber
1836
{
1937
get;
2038
set;
2139
}
2240

23-
public int EndLineNumber
41+
/// <summary>
42+
/// Gets or sets the starting line number of the extent.
43+
/// </summary>
44+
public int StartLineNumber
2445
{
2546
get;
2647
set;
2748
}
2849

29-
public int EndOffset
50+
/// <summary>
51+
/// Gets or sets the starting file offset of the extent.
52+
/// </summary>
53+
public int StartOffset
3054
{
3155
get;
3256
set;
3357
}
3458

35-
public IScriptPosition EndScriptPosition
59+
/// <summary>
60+
/// Gets or sets the starting script position of the extent.
61+
/// </summary>
62+
public IScriptPosition StartScriptPosition
3663
{
3764
get { throw new NotImplementedException(); }
3865
}
39-
40-
public string File
66+
/// <summary>
67+
/// Gets or sets the text that is contained within the extent.
68+
/// </summary>
69+
public string Text
4170
{
42-
get { throw new NotImplementedException(); }
71+
get;
72+
set;
4373
}
4474

45-
public int StartColumnNumber
75+
/// <summary>
76+
/// Gets or sets the ending column number of the extent.
77+
/// </summary>
78+
public int EndColumnNumber
4679
{
4780
get;
4881
set;
4982
}
5083

51-
public int StartLineNumber
84+
/// <summary>
85+
/// Gets or sets the ending line number of the extent.
86+
/// </summary>
87+
public int EndLineNumber
5288
{
5389
get;
5490
set;
5591
}
5692

57-
public int StartOffset
93+
/// <summary>
94+
/// Gets or sets the ending file offset of the extent.
95+
/// </summary>
96+
public int EndOffset
5897
{
5998
get;
6099
set;
61100
}
62101

63-
public IScriptPosition StartScriptPosition
102+
/// <summary>
103+
/// Gets the ending script position of the extent.
104+
/// </summary>
105+
public IScriptPosition EndScriptPosition
64106
{
65107
get { throw new NotImplementedException(); }
66108
}
67109

68-
public string Text
69-
{
70-
get;
71-
set;
72-
}
110+
#endregion
73111
}
74112
}

src/PowerShellEditorServices/PowerShellEditorServices.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
<DefineConstants>TRACE</DefineConstants>
3232
<ErrorReport>prompt</ErrorReport>
3333
<WarningLevel>4</WarningLevel>
34+
<WarningsAsErrors>1591,1573,1572</WarningsAsErrors>
35+
<DocumentationFile>bin\Release\Microsoft.PowerShell.EditorServices.XML</DocumentationFile>
3436
</PropertyGroup>
3537
<ItemGroup>
3638
<Reference Include="Nito.AsyncEx, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">

src/PowerShellEditorServices/Session/EditorSession.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ public IEnumerable<ScriptFile> GetOpenFiles()
123123

124124
#region IDisposable Implementation
125125

126+
/// <summary>
127+
/// Disposes of any Runspaces that were created for the
128+
/// services used in this session.
129+
/// </summary>
126130
public void Dispose()
127131
{
128132
// Dispose all necessary services

0 commit comments

Comments
 (0)